Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.6.1 breaks compiling for android. #34

Closed
evant opened this issue Sep 21, 2014 · 6 comments
Closed

Version 1.6.1 breaks compiling for android. #34

evant opened this issue Sep 21, 2014 · 6 comments

Comments

@evant
Copy link
Contributor

evant commented Sep 21, 2014

In the latest version, I'm getting the error when using gradle-retrolambda. 1.6.0 works fine.

Retrolambda 1.6.1                                          
Bytecode version: 51 (Java 7)                              
Input directory:  /home/evan/android/lambdatestProject/lambdaTestAndroid/build/retrolambda/debug
Output directory: /home/evan/android/lambdatestProject/lambdaTestAndroid/build/intermediates/classes/debug
Classpath:        /home/evan/android/lambdatestProject/lambdaTestAndroid/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/classes.jar:/home/evan/android/lambdatestProject/lambdaTestAndroid/build/intermediates/exploded-aar/lambdatestProject/lambdaTestAndroidLib/unspecified/classes.jar:/home/evan/android/lambdatestProject/lambdaTestAndroid/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/libs/internal_impl-20.0.0.jar:/opt/android-sdk/extras/android/m2repository/com/android/support/support-annotations/20.0.0/support-annotations-20.0.0.jar:/home/evan/android/lambdatestProject/lambdaTestAndroid/build/retrolambda/debug:/opt/android-sdk/platforms/android-20/android.jar

Error! Failed to transform some classes                         
java.lang.SecurityException: Prohibited package name: java.lang 
        at java.lang.ClassLoader.preDefineClass(ClassLoader.java:659)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at net.orfjackal.retrolambda.NonDelegatingClassLoader.loadClass(NonDelegatingClassLoader.java:22)
        at java.lang.ClassLoader.defineClass1(Native Method)    
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at net.orfjackal.retrolambda.NonDelegatingClassLoader.loadClass(NonDelegatingClassLoader.java:22)
        at net.orfjackal.retrolambda.LambdaUsageBackporter$InvokeDynamicInsnConvertingMethodVisitor.loadClass(LambdaUsageBackporter.java:173)
        at net.orfjackal.retrolambda.LambdaUsageBackporter$InvokeDynamicInsnConvertingMethodVisitor.backportLambda(LambdaUsageBackporter.java:161)
        at net.orfjackal.retrolambda.LambdaUsageBackporter$InvokeDynamicInsnConvertingMethodVisitor.visitInvokeDynamicInsn(LambdaUsageBackporter.java:154)
        at net.orfjackal.retrolambda.asm.ClassReader.readCode(ClassReader.java:1439)
        at net.orfjackal.retrolambda.asm.ClassReader.readMethod(ClassReader.java:1017)
        at net.orfjackal.retrolambda.asm.ClassReader.accept(ClassReader.java:693)
        at net.orfjackal.retrolambda.asm.ClassReader.accept(ClassReader.java:506)
        at net.orfjackal.retrolambda.LambdaUsageBackporter.transform(LambdaUsageBackporter.java:22)
        at net.orfjackal.retrolambda.Retrolambda$1.transform(Retrolambda.java:42)
        at net.orfjackal.retrolambda.BytecodeTransformingFileVisitor.visitFile(BytecodeTransformingFileVisitor.java:25)
        at net.orfjackal.retrolytecodeTransformingFileVisitor.visitFile(BytecodeTransformingFileVisitor.java:11)
        at java.nio.file.Files.walkFileTree(Files.java:2670)    
        at java.nio.file.Files.walkFileTree(Files.java:2742)    
        at net.orfjackal.retrolambda.Retrolambda.visitFiles(Retrolambda.java:52)
        at net.orfjackal.retrolambda.Retrolambda.run(Retrolambda.java:39)
        at net.orfjackal.retrolambda.Main.main(Main.java:26)

Note that compiling with gradle-retrolambda uses a custom --bootclasspath which contains the android.jar patched with some necessary classes taken from the java 8 runtime.

@evant evant changed the title Version 1.6.1 breaks compling for android. Version 1.6.1 breaks compiling for android. Sep 21, 2014
@luontola
Copy link
Owner

This is caused by java.* classes on the classpath - only JVM's own class loaders (or just the bootstrap class loader?) may load classes in those packages. Retrolambda 1.6.1 added the ability to mask e.g. com.sun.javafx.* packages (see #29 and 0ec45c6), but apparently it should avoid masking java.* because that's just not allowed by the JVM.

Does android.jar contain java.* packages? Please try if removing those classes from android.jar (temporarily) avoids this problem. Also you may try if adding the following line to the beginning of net.orfjackal.retrolambda.NonDelegatingClassLoader#loadClass fixes it:

    if (name.startsWith("java.")) {
        return super.loadClass(name);
    }

I'll try reproducing this in a few days, when I'm less busy.

@evant
Copy link
Contributor Author

evant commented Sep 26, 2014

Thanks for the help. Yes android.jar includes java.* classes, and yes, adding that if statement solves the issue.

@luontola
Copy link
Owner

luontola commented Oct 3, 2014

I did a sligthly different fix for this issue, so please double-check whether the current version in master fixes it also.

@luontola
Copy link
Owner

luontola commented Oct 3, 2014

Or actually, don't try it yet. I found a bug myself...

@luontola luontola reopened this Oct 3, 2014
@luontola
Copy link
Owner

luontola commented Oct 3, 2014

OK, there is now the same fix as you tried before. That works when the classpath contains a JAR which contains java.* classes.

@luontola
Copy link
Owner

luontola commented Oct 3, 2014

This has been fixed in Retrolambda 1.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants