File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
end-to-end-tests/src/test/java
net/orfjackal/retrolambda/test
retrolambda/src/main/java/net/orfjackal/retrolambda/interfaces Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright © 2013-2014 Esko Luontola <www.orfjackal.net>
2
+ // This software is released under the Apache License 2.0.
3
+ // The license text is at http://www.apache.org/licenses/LICENSE-2.0
4
+
5
+ package java .lang ;
6
+
7
+ import net .orfjackal .retrolambda .test .ClasspathTest ;
8
+
9
+ /**
10
+ * @see ClasspathTest#ignores_classes_in_explicit_classpath_that_are_under_the_java_package
11
+ */
12
+ @ SuppressWarnings ("UnusedDeclaration" )
13
+ public class Math {
14
+
15
+ public Math () {
16
+ // some lambdas to cause Retrolambda try backporting this class
17
+ Runnable r = () -> {
18
+ };
19
+ }
20
+ }
Original file line number Diff line number Diff line change @@ -57,4 +57,15 @@ public Runnable foo() {
57
57
public void prefers_classes_in_explicit_classpath_over_classes_in_the_JRE () {
58
58
assertNotNull (getClass ().getResource ("/com/sun/javafx/application/LauncherImpl$$Lambda$1.class" ));
59
59
}
60
+
61
+ /**
62
+ * Classes in the {@code java.*} packages can be loaded only by the bootstrap
63
+ * class loader, so we must not try to load them with our custom class loader.
64
+ * This situation arises when backporting Android applications, because android.jar
65
+ * contains {@code java.*} classes.
66
+ */
67
+ @ Test
68
+ public void ignores_classes_in_explicit_classpath_that_are_under_the_java_package () {
69
+ assertNotNull (getClass ().getResource ("/java/lang/Math.class" ));
70
+ }
60
71
}
Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ public class ClassHierarchyAnalyzer implements MethodRelocations {
23
23
24
24
public void analyze (byte [] bytecode ) {
25
25
ClassReader cr = new ClassReader (bytecode );
26
- Type clazz = classNameToType (cr .getClassName ());
26
+ String className = cr .getClassName ();
27
+ if (className .startsWith ("java/" )) {
28
+ // the JVM disallows user classes in java.* packages, so don't even try backporting them
29
+ return ;
30
+ }
31
+ Type clazz = classNameToType (className );
27
32
28
33
if (Flags .hasFlag (cr .getAccess (), ACC_INTERFACE )) {
29
34
interfaces .add (cr );
You can’t perform that action at this time.
0 commit comments