Update ASM & JDT for Java11 sourceLevel support. Bug: #9649 Bug-Link: https://github.com/gwtproject/gwt/issues/9649 Change-Id: I2b56d72d8a99b8beee1f31ee6c8be87b806e5c27
diff --git a/.gitignore b/.gitignore index d3c9a94..72762e9 100644 --- a/.gitignore +++ b/.gitignore
@@ -4,3 +4,5 @@ # Working folder of ant build script /build/ +# Generated poms +/maven/poms/**/pom.xml
diff --git a/dev/build.xml b/dev/build.xml index 263e641..9c13138 100755 --- a/dev/build.xml +++ b/dev/build.xml
@@ -74,11 +74,11 @@ <include name="apache/tapestry-util-text-4.0.2.jar"/> <include name="apache/ant-1.6.5.jar"/> <include name="colt/colt-1.2.jar"/> - <include name="eclipse/org.eclipse.jdt.core_3.13.102-CUSTOM-GWT-20180415.jar"/> - <include name="eclipse/jdtCompilerAdapter_3.13.102-CUSTOM-GWT-20180415.jar"/> - <include name="objectweb/asm-6.1.1/asm-6.1.1.jar"/> - <include name="objectweb/asm-6.1.1/asm-commons-6.1.1.jar"/> - <include name="objectweb/asm-6.1.1/asm-util-6.1.1.jar"/> + <include name="eclipse/org.eclipse.jdt.core_3.17.0.v20190306-2240.jar"/> + <include name="eclipse/jdtCompilerAdapter_3.17.0.v20190306-2240.jar"/> + <include name="objectweb/asm-7.1/asm-7.1.jar"/> + <include name="objectweb/asm-7.1/asm-commons-7.1.jar"/> + <include name="objectweb/asm-7.1/asm-util-7.1.jar"/> <include name="guava/guava-19.0/guava-19.0-rebased.jar"/> <include name="icu4j/63.1/icu4j.jar"/> <include name="jetty/jetty-9.2.14.v20151106/jetty-all-9.2.14.v20151106.jar"/> @@ -128,16 +128,16 @@ <provider classname="org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer"/> <provider classname="org.eclipse.jetty.apache.jsp.JettyJasperInitializer"/> </service> - <zipfileset src="${gwt.tools.lib}/objectweb/asm-6.1.1/asm-6.1.1.jar"/> - <zipfileset src="${gwt.tools.lib}/objectweb/asm-6.1.1/asm-commons-6.1.1.jar"/> - <zipfileset src="${gwt.tools.lib}/objectweb/asm-6.1.1/asm-util-6.1.1.jar"/> + <zipfileset src="${gwt.tools.lib}/objectweb/asm-7.1/asm-7.1.jar"/> + <zipfileset src="${gwt.tools.lib}/objectweb/asm-7.1/asm-commons-7.1.jar"/> + <zipfileset src="${gwt.tools.lib}/objectweb/asm-7.1/asm-util-7.1.jar"/> <zipfileset src="${gwt.tools.lib}/apache/tapestry-util-text-4.0.2.jar"/> <zipfileset src="${gwt.tools.lib}/apache/ant-1.6.5.jar"/> <zipfileset src="${gwt.tools.lib}/colt/colt-1.2.jar"/> <zipfileset - src="${gwt.tools.lib}/eclipse/org.eclipse.jdt.core_3.13.102-CUSTOM-GWT-20180415.jar"/> + src="${gwt.tools.lib}/eclipse/org.eclipse.jdt.core_3.17.0.v20190306-2240.jar"/> <zipfileset - src="${gwt.tools.lib}/eclipse/jdtCompilerAdapter_3.13.102-CUSTOM-GWT-20180415.jar"/> + src="${gwt.tools.lib}/eclipse/jdtCompilerAdapter_3.17.0.v20190306-2240.jar"/> <zipfileset src="${gwt.tools.lib}/guava/guava-19.0/guava-19.0-rebased.jar"/> <zipfileset src="${gwt.tools.lib}/icu4j/63.1/icu4j.jar"/> <zipfileset @@ -222,15 +222,15 @@ <classpath> <pathelement location="${gwt.tools.lib}/apache/ant-1.6.5.jar"/> <pathelement location="${gwt.tools.lib}/colt/colt-1.2.jar"/> - <pathelement location="${gwt.tools.lib}/objectweb/asm-6.1.1/asm-6.1.1.jar"/> - <pathelement location="${gwt.tools.lib}/objectweb/asm-6.1.1/asm-commons-6.1.1.jar"/> - <pathelement location="${gwt.tools.lib}/objectweb/asm-6.1.1/asm-util-6.1.1.jar"/> + <pathelement location="${gwt.tools.lib}/objectweb/asm-7.1/asm-7.1.jar"/> + <pathelement location="${gwt.tools.lib}/objectweb/asm-7.1/asm-commons-7.1.jar"/> + <pathelement location="${gwt.tools.lib}/objectweb/asm-7.1/asm-util-7.1.jar"/> <pathelement location="${gwt.tools.lib}/apache/commons/commons-collections-3.2.2.jar"/> <pathelement - location="${gwt.tools.lib}/eclipse/org.eclipse.jdt.core_3.13.102-CUSTOM-GWT-20180415.jar"/> + location="${gwt.tools.lib}/eclipse/org.eclipse.jdt.core_3.17.0.v20190306-2240.jar"/> <pathelement - location="${gwt.tools.lib}/eclipse/jdtCompilerAdapter_3.13.102-CUSTOM-GWT-20180415.jar"/> + location="${gwt.tools.lib}/eclipse/jdtCompilerAdapter_3.17.0.v20190306-2240.jar"/> <pathelement location="${gwt.tools.lib}/guava/guava-19.0/guava-19.0-rebased.jar"/> <pathelement location="${gwt.tools.lib}/gson/gson-2.6.2.jar"/>
diff --git a/dev/core/src/com/google/gwt/dev/javac/BytecodeSignatureMaker.java b/dev/core/src/com/google/gwt/dev/javac/BytecodeSignatureMaker.java index 9933f6c..762c422 100644 --- a/dev/core/src/com/google/gwt/dev/javac/BytecodeSignatureMaker.java +++ b/dev/core/src/com/google/gwt/dev/javac/BytecodeSignatureMaker.java
@@ -56,7 +56,7 @@ private Map<String, String> methods = new HashMap<String, String>(); public CompileDependencyVisitor() { - super(Opcodes.ASM6); + super(Opcodes.ASM7); } public String getSignature() {
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java index d2bb682..6f7f003 100644 --- a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java +++ b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
@@ -66,7 +66,7 @@ public AnonymousClassVisitor() { - this.mv = new org.objectweb.asm.MethodVisitor(Opcodes.ASM6, this.mv) { + this.mv = new org.objectweb.asm.MethodVisitor(Opcodes.ASM7, this.mv) { @Override public void visitCode() { ++sawCode;
diff --git a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java index af7e4c5..c0e5748 100644 --- a/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java +++ b/dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java
@@ -786,7 +786,8 @@ ImmutableMap.<SourceLevel, Long>of( SourceLevel.JAVA8, ClassFileConstants.JDK1_8, SourceLevel.JAVA9, ClassFileConstants.JDK9, - SourceLevel.JAVA10, ClassFileConstants.JDK10); + SourceLevel.JAVA10, ClassFileConstants.JDK10, + SourceLevel.JAVA11, ClassFileConstants.JDK11); public JdtCompiler(CompilerContext compilerContext, UnitProcessor processor) { this.compilerContext = compilerContext;
diff --git a/dev/core/src/com/google/gwt/dev/javac/asm/CollectAnnotationData.java b/dev/core/src/com/google/gwt/dev/javac/asm/CollectAnnotationData.java index 6bc844b..95fcc52 100644 --- a/dev/core/src/com/google/gwt/dev/javac/asm/CollectAnnotationData.java +++ b/dev/core/src/com/google/gwt/dev/javac/asm/CollectAnnotationData.java
@@ -79,7 +79,7 @@ private final List<Object> values = new ArrayList<Object>(); public MyAnnotationArrayVisitor(Callback<Object> callback) { - super(Opcodes.ASM6); + super(Opcodes.ASM7); this.callback = callback; } @@ -158,7 +158,7 @@ */ CollectAnnotationData(String desc, boolean visible, Callback<CollectAnnotationData.AnnotationData> callback) { - super(Opcodes.ASM6); + super(Opcodes.ASM7); annotation = new AnnotationData(desc, visible); this.callback = callback; }
diff --git a/dev/core/src/com/google/gwt/dev/javac/asm/CollectFieldData.java b/dev/core/src/com/google/gwt/dev/javac/asm/CollectFieldData.java index 7d59164..3bfb434 100644 --- a/dev/core/src/com/google/gwt/dev/javac/asm/CollectFieldData.java +++ b/dev/core/src/com/google/gwt/dev/javac/asm/CollectFieldData.java
@@ -36,7 +36,7 @@ public CollectFieldData(int access, String name, String desc, String signature, Object value) { - super(Opcodes.ASM6); + super(Opcodes.ASM7); this.access = access; this.name = name; this.desc = desc;
diff --git a/dev/core/src/com/google/gwt/dev/javac/asm/CollectMethodData.java b/dev/core/src/com/google/gwt/dev/javac/asm/CollectMethodData.java index c3f72d4..95f17a4 100644 --- a/dev/core/src/com/google/gwt/dev/javac/asm/CollectMethodData.java +++ b/dev/core/src/com/google/gwt/dev/javac/asm/CollectMethodData.java
@@ -58,7 +58,7 @@ // for new List[] public CollectMethodData(CollectClassData.ClassType classType, int access, String name, String desc, String signature, String[] exceptions) { - super(Opcodes.ASM6); + super(Opcodes.ASM7); this.access = access; this.name = name; this.desc = desc;
diff --git a/dev/core/src/com/google/gwt/dev/javac/asm/CollectReferencesVisitor.java b/dev/core/src/com/google/gwt/dev/javac/asm/CollectReferencesVisitor.java index 7a523d9..17b3293 100644 --- a/dev/core/src/com/google/gwt/dev/javac/asm/CollectReferencesVisitor.java +++ b/dev/core/src/com/google/gwt/dev/javac/asm/CollectReferencesVisitor.java
@@ -42,7 +42,7 @@ private class CollectGenericTypes extends SignatureVisitor { public CollectGenericTypes() { - super(Opcodes.ASM6); + super(Opcodes.ASM7); } @Override @@ -121,7 +121,7 @@ } CollectReferencesVisitor() { - this.av = new AnnotationVisitor(Opcodes.ASM6, this.av) { + this.av = new AnnotationVisitor(Opcodes.ASM7, this.av) { @Override public void visitEnum(String name, String desc, String value) { addTypeIfClass(desc);
diff --git a/dev/core/src/com/google/gwt/dev/javac/asm/EmptySignatureVisitor.java b/dev/core/src/com/google/gwt/dev/javac/asm/EmptySignatureVisitor.java index 1ce3cd8..fe53857 100644 --- a/dev/core/src/com/google/gwt/dev/javac/asm/EmptySignatureVisitor.java +++ b/dev/core/src/com/google/gwt/dev/javac/asm/EmptySignatureVisitor.java
@@ -34,7 +34,7 @@ protected static EmptySignatureVisitor ignore = new EmptySignatureVisitor(); public EmptySignatureVisitor() { - super(Opcodes.ASM6); + super(Opcodes.ASM7); } /**
diff --git a/dev/core/src/com/google/gwt/dev/javac/asmbridge/EmptyVisitor.java b/dev/core/src/com/google/gwt/dev/javac/asmbridge/EmptyVisitor.java index 4fa5fde..ffa3ba4 100644 --- a/dev/core/src/com/google/gwt/dev/javac/asmbridge/EmptyVisitor.java +++ b/dev/core/src/com/google/gwt/dev/javac/asmbridge/EmptyVisitor.java
@@ -27,7 +27,7 @@ */ public class EmptyVisitor extends ClassVisitor { - protected AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM6) { + protected AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM7) { @Override public AnnotationVisitor visitAnnotation(String name, String desc) { @@ -41,10 +41,10 @@ }; public EmptyVisitor() { - super(Opcodes.ASM6); + super(Opcodes.ASM7); } - protected MethodVisitor mv = new MethodVisitor(Opcodes.ASM6) { + protected MethodVisitor mv = new MethodVisitor(Opcodes.ASM7) { @Override public AnnotationVisitor visitAnnotationDefault() { @@ -63,7 +63,7 @@ } }; - protected FieldVisitor fv = new FieldVisitor(Opcodes.ASM6) { + protected FieldVisitor fv = new FieldVisitor(Opcodes.ASM7) { @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
diff --git a/dev/core/src/com/google/gwt/dev/shell/rewrite/ForceClassVersion15.java b/dev/core/src/com/google/gwt/dev/shell/rewrite/ForceClassVersion15.java index 1be0d79..52c5e75 100644 --- a/dev/core/src/com/google/gwt/dev/shell/rewrite/ForceClassVersion15.java +++ b/dev/core/src/com/google/gwt/dev/shell/rewrite/ForceClassVersion15.java
@@ -25,7 +25,7 @@ class ForceClassVersion15 extends ClassVisitor { public ForceClassVersion15(ClassVisitor v) { - super(Opcodes.ASM6, v); + super(Opcodes.ASM7, v); } @Override
diff --git a/dev/core/src/com/google/gwt/dev/shell/rewrite/HasAnnotation.java b/dev/core/src/com/google/gwt/dev/shell/rewrite/HasAnnotation.java index b99e5c7..15f0d15 100644 --- a/dev/core/src/com/google/gwt/dev/shell/rewrite/HasAnnotation.java +++ b/dev/core/src/com/google/gwt/dev/shell/rewrite/HasAnnotation.java
@@ -54,7 +54,7 @@ private final String targetDesc; public HasAnnotation(ClassVisitor v, Class<? extends Annotation> annotation) { - super(Opcodes.ASM6, v); + super(Opcodes.ASM7, v); targetDesc = Type.getDescriptor(annotation); }
diff --git a/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteJsniMethods.java b/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteJsniMethods.java index e2fdafb..6ce96eb 100644 --- a/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteJsniMethods.java +++ b/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteJsniMethods.java
@@ -206,7 +206,7 @@ public MyMethodAdapter(MethodVisitor mv, int access, String name, String desc) { - super(Opcodes.ASM6, mv, access, name, desc); + super(Opcodes.ASM7, mv, access, name, desc); this.descriptor = desc; this.name = name; isStatic = (access & Opcodes.ACC_STATIC) != 0; @@ -329,7 +329,7 @@ public RewriteJsniMethods(ClassVisitor v, Map<String, String> anonymousClassMap) { - super(Opcodes.ASM6, v); + super(Opcodes.ASM7, v); this.anonymousClassMap = anonymousClassMap; }
diff --git a/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteRefsToJsoClasses.java b/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteRefsToJsoClasses.java index d860ab7..1911d51 100644 --- a/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteRefsToJsoClasses.java +++ b/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteRefsToJsoClasses.java
@@ -54,7 +54,7 @@ }; public MyMethodAdapter(MethodVisitor mv) { - super(Opcodes.ASM6, mv); + super(Opcodes.ASM7, mv); } @Override @@ -132,7 +132,7 @@ */ public RewriteRefsToJsoClasses(ClassVisitor cv, Set<String> jsoDescriptors, InstanceMethodOracle mapper) { - super(Opcodes.ASM6, cv); + super(Opcodes.ASM7, cv); this.jsoDescriptors = jsoDescriptors; this.mapper = mapper; }
diff --git a/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteSingleJsoImplDispatches.java b/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteSingleJsoImplDispatches.java index 7246b55..ff38213 100644 --- a/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteSingleJsoImplDispatches.java +++ b/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteSingleJsoImplDispatches.java
@@ -57,7 +57,7 @@ public class RewriteSingleJsoImplDispatches extends ClassVisitor { private class MyMethodVisitor extends MethodVisitor { public MyMethodVisitor(MethodVisitor mv) { - super(Opcodes.ASM6, mv); + super(Opcodes.ASM7, mv); } /* @@ -133,7 +133,7 @@ public RewriteSingleJsoImplDispatches(ClassVisitor v, TypeOracle typeOracle, SingleJsoImplData jsoData) { - super(Opcodes.ASM6, v); + super(Opcodes.ASM7, v); this.typeOracle = typeOracle; this.jsoData = jsoData; }
diff --git a/dev/core/src/com/google/gwt/dev/shell/rewrite/UseMirroredClasses.java b/dev/core/src/com/google/gwt/dev/shell/rewrite/UseMirroredClasses.java index 70dba63..51ac42d 100644 --- a/dev/core/src/com/google/gwt/dev/shell/rewrite/UseMirroredClasses.java +++ b/dev/core/src/com/google/gwt/dev/shell/rewrite/UseMirroredClasses.java
@@ -72,7 +72,7 @@ private String className; protected MethodInterceptor(MethodVisitor mv, String className) { - super(Opcodes.ASM6, mv); + super(Opcodes.ASM7, mv); this.className = className; } @@ -144,7 +144,7 @@ private String className; public UseMirroredClasses(ClassVisitor cv, String className) { - super(Opcodes.ASM6, cv); + super(Opcodes.ASM7, cv); this.className = className; }
diff --git a/dev/core/src/com/google/gwt/dev/shell/rewrite/WriteJsoImpl.java b/dev/core/src/com/google/gwt/dev/shell/rewrite/WriteJsoImpl.java index d06602e..8d46073 100644 --- a/dev/core/src/com/google/gwt/dev/shell/rewrite/WriteJsoImpl.java +++ b/dev/core/src/com/google/gwt/dev/shell/rewrite/WriteJsoImpl.java
@@ -264,7 +264,7 @@ * @param mapper maps methods to the class in which they are declared */ private WriteJsoImpl(ClassVisitor cv, InstanceMethodOracle mapper) { - super(Opcodes.ASM6, cv); + super(Opcodes.ASM7, cv); this.mapper = mapper; }
diff --git a/dev/core/src/com/google/gwt/dev/util/arg/SourceLevel.java b/dev/core/src/com/google/gwt/dev/util/arg/SourceLevel.java index 1243189..d78d573 100644 --- a/dev/core/src/com/google/gwt/dev/util/arg/SourceLevel.java +++ b/dev/core/src/com/google/gwt/dev/util/arg/SourceLevel.java
@@ -25,7 +25,8 @@ // Source levels must appear in ascending order for the default setting logic to work. JAVA8("1.8", "8"), JAVA9("1.9", "9"), - JAVA10("1.10", "10"); + JAVA10("1.10", "10"), + JAVA11("1.11", "11"); /** * The default java sourceLevel.
diff --git a/dev/core/test/com/google/gwt/dev/CompilerTest.java b/dev/core/test/com/google/gwt/dev/CompilerTest.java index 88fce34..4d75a17 100644 --- a/dev/core/test/com/google/gwt/dev/CompilerTest.java +++ b/dev/core/test/com/google/gwt/dev/CompilerTest.java
@@ -959,6 +959,7 @@ assertEquals(SourceLevel.JAVA8, SourceLevel.getBestMatchingVersion("1.8")); assertEquals(SourceLevel.JAVA9, SourceLevel.getBestMatchingVersion("1.9")); assertEquals(SourceLevel.JAVA10, SourceLevel.getBestMatchingVersion("1.10")); + assertEquals(SourceLevel.JAVA11, SourceLevel.getBestMatchingVersion("1.11")); // not proper version strings => default to JAVA8. assertEquals(SourceLevel.JAVA8, SourceLevel.getBestMatchingVersion("1.6u3")); @@ -1701,7 +1702,7 @@ File applicationDir = Files.createTempDir(); CompilerOptions compilerOptions = new CompilerOptionsImpl(); compilerOptions.setUseDetailedTypeIds(true); - compilerOptions.setSourceLevel(SourceLevel.JAVA10); + compilerOptions.setSourceLevel(SourceLevel.JAVA11); // Compile the application with no errors. compileToJs(TreeLogger.NULL, compilerOptions, applicationDir, "com.foo.Errors", @@ -1764,7 +1765,7 @@ File applicationDir = Files.createTempDir(); CompilerOptions compilerOptions = new CompilerOptionsImpl(); compilerOptions.setUseDetailedTypeIds(true); - compilerOptions.setSourceLevel(SourceLevel.JAVA10); + compilerOptions.setSourceLevel(SourceLevel.JAVA11); compilerOptions.setGenerateJsInteropExports(false); // Compile the application with no errors. @@ -2115,7 +2116,7 @@ CompilerOptions compilerOptions = new CompilerOptionsImpl(); compilerOptions.setUseDetailedTypeIds(true); - compilerOptions.setSourceLevel(SourceLevel.JAVA10); + compilerOptions.setSourceLevel(SourceLevel.JAVA11); checkRecompiledModifiedApp(compilerOptions, "com.foo.DefaultMethod", Lists.newArrayList(moduleResource, entryPointResource, aSubclass,
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/GwtAstBuilderTest.java b/dev/core/test/com/google/gwt/dev/jjs/impl/GwtAstBuilderTest.java index 251d27c..f9a830f 100644 --- a/dev/core/test/com/google/gwt/dev/jjs/impl/GwtAstBuilderTest.java +++ b/dev/core/test/com/google/gwt/dev/jjs/impl/GwtAstBuilderTest.java
@@ -26,17 +26,13 @@ import com.google.gwt.dev.jjs.JavaAstConstructor; import com.google.gwt.dev.jjs.ast.Context; import com.google.gwt.dev.jjs.ast.JArrayType; -import com.google.gwt.dev.jjs.ast.JCastOperation; import com.google.gwt.dev.jjs.ast.JClassLiteral; import com.google.gwt.dev.jjs.ast.JDeclaredType; import com.google.gwt.dev.jjs.ast.JExpression; -import com.google.gwt.dev.jjs.ast.JExpressionStatement; import com.google.gwt.dev.jjs.ast.JMethod; -import com.google.gwt.dev.jjs.ast.JMethodBody; import com.google.gwt.dev.jjs.ast.JMethodCall; import com.google.gwt.dev.jjs.ast.JProgram; import com.google.gwt.dev.jjs.ast.JReferenceType; -import com.google.gwt.dev.jjs.ast.JStatement; import com.google.gwt.dev.jjs.ast.JType; import com.google.gwt.dev.jjs.ast.JVariable; import com.google.gwt.dev.jjs.ast.JVisitor; @@ -233,41 +229,25 @@ } public void testIntersectionBound() throws UnableToCompleteException { - sources.add(JavaResourceBase.createMockJavaResource("test.IntersectionBound", + addAll(JavaResourceBase.createMockJavaResource("test.IntersectionBound", "package test;", + "interface A<T> { void a(); }", + "interface B { void b(); }", + "interface C { void c(); }", "public class IntersectionBound {", - " public void main() {", - " get().f();", - " get().g();", - " get().h();", - " }", - " public interface A<T> { void f(); }", - " public interface B { void g(); }", - " public interface C { void h(); }", " <T extends B & A<String> & C> T get() { return null;} ", "}" )); - JProgram program = compileProgram("test.IntersectionBound"); - JMethod mainMethod = findQualifiedMethod(program, "test.IntersectionBound.main"); - for (JStatement statement : ((JMethodBody) mainMethod.getBody()).getStatements()) { - // TODO: should have inserted only a cast to the type needed in the specific context context, - // but that would require some redesign. For now make sure all the casts from the intersection - // type are emitted. - JExpression maybeCastOperation = - ((JMethodCall) ((JExpressionStatement) statement).getExpr()).getInstance(); - Set<String> castToTypeNames = Sets.newHashSet(); - while (maybeCastOperation instanceof JCastOperation) { - JCastOperation castOperation = (JCastOperation) maybeCastOperation; - castToTypeNames.add(castOperation.getCastType().getName()); - maybeCastOperation = castOperation.getExpr(); - } - - assertEquals( - Sets.newHashSet(Arrays.asList( - "test.IntersectionBound$A", "test.IntersectionBound$B", "test.IntersectionBound$C")), - castToTypeNames); - } + assertEqualBlock( + "((C)(B)(A)(new IntersectionBound()).get()).a();", + "new IntersectionBound().get().a();"); + assertEqualBlock( + "(new IntersectionBound()).get().b();", + "new IntersectionBound().get().b();"); + assertEqualBlock( + "((C)(new IntersectionBound()).get()).c();", + "new IntersectionBound().get().c();"); } public void testBridgeMethodResolution() throws UnableToCompleteException {
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/Java11AstTest.java b/dev/core/test/com/google/gwt/dev/jjs/impl/Java11AstTest.java new file mode 100644 index 0000000..f0e9ab2 --- /dev/null +++ b/dev/core/test/com/google/gwt/dev/jjs/impl/Java11AstTest.java
@@ -0,0 +1,74 @@ +/* + * Copyright 2019 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.dev.jjs.impl; + +import com.google.gwt.dev.javac.testing.impl.JavaResourceBase; +import com.google.gwt.dev.jjs.ast.JMethod; +import com.google.gwt.dev.jjs.ast.JProgram; +import com.google.gwt.thirdparty.guava.common.base.Joiner; + +/** + * Tests that {@link com.google.gwt.dev.jjs.impl.GwtAstBuilder} correctly builds the AST for + * features introduced in Java 11. + */ +public class Java11AstTest extends FullCompileTestBase { + + @Override + public void setUp() throws Exception { + super.setUp(); + addAll(JavaResourceBase.createMockJavaResource("test.NotNull", + "package test;", + "public @interface NotNull {", + "}" + )); + addAll(JavaResourceBase.createMockJavaResource("test.Lambda", + "package test;", + "public interface Lambda<T> {", + " T run(String a, int b);", + "}" + )); + addAll(JavaResourceBase.createMockJavaResource("test.Function", + "package test;", + "public interface Function<T, R> {", + " R apply(T value);", + "}" + )); + addAll(JavaResourceBase.createMockJavaResource("test.Mappable", + "package test;", + "public interface Mappable<T> {", + " <R> Mappable<R> map(Function<? super T, ? extends R> mapper);", + "}" + )); + } + + public void testLambdaParametersVarType() throws Exception { + JProgram program = compileSnippet("void", + "Lambda<String> l = (@NotNull var a, var b) -> a + b;"); + JMethod lambdaMethod = findMethod(program, "lambda$0"); + assertEquals("lambda$0(Ljava/lang/String;I)Ljava/lang/String;", lambdaMethod.getSignature()); + } + + public void testLambdaParametersVarType_function() throws Exception { + JProgram program = compileSnippet("void", Joiner.on('\n').join( + "Mappable<String> m = null;", + "Mappable<String> mapped = m.map((var s) -> s);" + )); + JMethod lambdaMethod = findMethod(program, "lambda$0"); + assertEquals("lambda$0(Ljava/lang/String;)Ljava/lang/String;", lambdaMethod.getSignature()); + } + + @Override + protected void optimizeJava() { + } +}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/Java8AstTest.java b/dev/core/test/com/google/gwt/dev/jjs/impl/Java8AstTest.java index 62f8b83..a85cb10 100644 --- a/dev/core/test/com/google/gwt/dev/jjs/impl/Java8AstTest.java +++ b/dev/core/test/com/google/gwt/dev/jjs/impl/Java8AstTest.java
@@ -1024,7 +1024,7 @@ addSnippetClassDecl("interface I1 { public void foo(); }"); addSnippetClassDecl("interface I2 { }"); String lambda = "Object o = (I2 & I1) () -> {};"; - assertEqualBlock("Object o=(EntryPoint$I2)(EntryPoint$I1)new EntryPoint$lambda$0$Type();", + assertEqualBlock("Object o=(EntryPoint$I1)(EntryPoint$I2)new EntryPoint$lambda$0$Type();", lambda); JProgram program = compileSnippet("void", lambda, false); @@ -1060,7 +1060,7 @@ addSnippetClassDecl("interface I3 { }"); String lambda = "I2 o = (I3 & I2 & I1) () -> {};"; assertEqualBlock( - "EntryPoint$I2 o=(EntryPoint$I3)(EntryPoint$I2)(EntryPoint$I1)new EntryPoint$lambda$0$Type();", + "EntryPoint$I2 o=(EntryPoint$I1)(EntryPoint$I2)(EntryPoint$I3)new EntryPoint$lambda$0$Type();", lambda); JProgram program = compileSnippet("void", lambda, false);
diff --git a/eclipse/dev/.classpath b/eclipse/dev/.classpath index 4e24779..ac771cb 100644 --- a/eclipse/dev/.classpath +++ b/eclipse/dev/.classpath
@@ -6,12 +6,12 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="GWT_TOOLS/lib/apache/ant-1.6.5.jar" sourcepath="/GWT_TOOLS/lib/apache/ant-1.6.5-src.zip"/> <classpathentry kind="var" path="GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2.jar" sourcepath="/GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2-src.zip"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/org.eclipse.jdt.core_3.13.102-CUSTOM-GWT-20180415.jar" sourcepath="/GWT_TOOLS/lib/eclipse/org.eclipse.jdt.core.source_3.13.102-CUSTOM-GWT-20180415.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/jdtCompilerAdapter_3.13.102-CUSTOM-GWT-20180415.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/org.eclipse.jdt.core_3.17.0.v20190306-2240.jar" sourcepath="/GWT_TOOLS/lib/eclipse/org.eclipse.jdt.core.source_3.17.0.v20190306-2240.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/jdtCompilerAdapter_3.17.0.v20190306-2240.jar"/> <classpathentry exported="true" kind="var" path="GWT_TOOLS/lib/jetty/jetty-9.2.14.v20151106/jetty-all-9.2.14.v20151106.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/jsr305/jsr305.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/junit/junit-4.8.2.jar" sourcepath="/GWT_TOOLS/lib/junit/junit-4.8.2-src.zip"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-6.1.1/asm-6.1.1.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-7.1/asm-7.1.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/ant-launcher-1.6.5.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/catalina-1.0.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/catalina-optional-1.0.jar"/> @@ -30,9 +30,7 @@ <classpathentry exported="true" kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-websocket-api-8.0.28.jar"/> <classpathentry exported="true" kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-annotations-api-8.0.28.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/colt/colt-1.2.jar" sourcepath="/GWT_TOOLS/lib/colt/colt-1.2-src.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-6.1.1/asm-analysis-6.1.1.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-6.1.1/asm-commons-6.1.1.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-6.1.1/asm-tree-6.1.1.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-6.1.1/asm-util-6.1.1.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-7.1/asm-commons-7.1.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-7.1/asm-util-7.1.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
diff --git a/eclipse/user/.classpath b/eclipse/user/.classpath index 4e98014..75f9362 100644 --- a/eclipse/user/.classpath +++ b/eclipse/user/.classpath
@@ -61,9 +61,9 @@ <classpathentry kind="var" path="GWT_TOOLS/lib/testng/testng-5.14.1-nojunit.jar" sourcepath="/GWT_TOOLS/lib/testng/testng-5.14.1-sources.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/protobuf/protobuf-2.5.0/protobuf-java-rebased-2.5.0.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/jscomp/20160315/sourcemap-rebased.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/org.eclipse.jdt.core_3.13.102-CUSTOM-GWT-20180415.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/jdtCompilerAdapter_3.13.102-CUSTOM-GWT-20180415.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-6.1.1/asm-6.1.1.jar"/> - <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-6.1.1/asm-commons-6.1.1.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/org.eclipse.jdt.core_3.17.0.v20190306-2240.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/jdtCompilerAdapter_3.17.0.v20190306-2240.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-7.1/asm-7.1.jar"/> + <classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-7.1/asm-commons-7.1.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
diff --git a/maven/poms/gwt/pom-template.xml b/maven/poms/gwt/pom-template.xml index 883e905..8b1d89c 100644 --- a/maven/poms/gwt/pom-template.xml +++ b/maven/poms/gwt/pom-template.xml
@@ -22,6 +22,7 @@ </licenses> <properties> <jetty.version>9.2.14.v20151106</jetty.version> + <asm.version>7.1</asm.version> </properties> <dependencyManagement> <dependencies> @@ -89,17 +90,17 @@ <dependency> <groupId>org.ow2.asm</groupId> <artifactId>asm</artifactId> - <version>6.1.1</version> + <version>${asm.version}</version> </dependency> <dependency> <groupId>org.ow2.asm</groupId> <artifactId>asm-commons</artifactId> - <version>6.1.1</version> + <version>${asm.version}</version> </dependency> <dependency> <groupId>org.ow2.asm</groupId> <artifactId>asm-util</artifactId> - <version>6.1.1</version> + <version>${asm.version}</version> </dependency> <dependency> <groupId>colt</groupId>
diff --git a/user/build.xml b/user/build.xml index 8dd3dd9..3d2a256 100755 --- a/user/build.xml +++ b/user/build.xml
@@ -65,8 +65,8 @@ <pathelement location="${gwt.tools.lib}/cglib/cglib-3.1.jar"/> <pathelement location="${gwt.tools.lib}/mockito/1.9.5/mockito-all-1.9.5.jar"/> <pathelement location="${gwt.tools.lib}/objenesis/objenesis-1.2.jar"/> - <pathelement location="${gwt.tools.lib}/objectweb/asm-6.1.1/asm-6.1.1.jar"/> - <pathelement location="${gwt.tools.lib}/objectweb/asm-6.1.1/asm-commons-6.1.1.jar"/> + <pathelement location="${gwt.tools.lib}/objectweb/asm-7.1/asm-7.1.jar"/> + <pathelement location="${gwt.tools.lib}/objectweb/asm-7.1/asm-commons-7.1.jar"/> <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar"/> <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA-sources.jar"/> <pathelement
diff --git a/user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java b/user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java index f5906e3..4e12d76 100644 --- a/user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java +++ b/user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java
@@ -352,7 +352,7 @@ public AnnotationProcessor(String sourceType, AnnotationVisitor av) { // TODO(rluble): should we chain av to super here? - super(Opcodes.ASM6); + super(Opcodes.ASM7); this.sourceType = sourceType; this.av = av; } @@ -386,7 +386,7 @@ private String sourceType; public ClassProcessor(String sourceType, ClassVisitor cv, State state) { - super(Opcodes.ASM6, cv); + super(Opcodes.ASM7, cv); this.sourceType = sourceType; this.state = state; } @@ -519,7 +519,7 @@ public FieldProcessor(String sourceType, FieldVisitor fv) { // TODO(rluble): Should we chain fv to super here? - super(Opcodes.ASM6); + super(Opcodes.ASM7); this.sourceType = sourceType; this.fv = fv; } @@ -541,7 +541,7 @@ private final String sourceType; public MethodProcessor(String sourceType, MethodVisitor mv) { - super(Opcodes.ASM6, mv); + super(Opcodes.ASM7, mv); this.sourceType = sourceType; } @@ -630,7 +630,7 @@ */ private class NativeMethodDefanger extends ClassVisitor { public NativeMethodDefanger(ClassVisitor cv) { - super(Opcodes.ASM6, cv); + super(Opcodes.ASM7, cv); } @Override
diff --git a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java11Test.java b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java11Test.java new file mode 100644 index 0000000..9e9c8f6 --- /dev/null +++ b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java11Test.java
@@ -0,0 +1,59 @@ +/* + * Copyright 2019 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.dev.jjs.test; + +import com.google.gwt.core.client.GwtScriptOnly; +import com.google.gwt.junit.client.GWTTestCase; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Tests Java 11 features. It is super sourced so that gwt can be compiles under Java 8. + * + * IMPORTANT: For each test here there must exist the corresponding method in the non super sourced + * version. + * + * Eventually this test will graduate and not be super sourced. + */ +@GwtScriptOnly +public class Java11Test extends GWTTestCase { + + @interface NotNull { + } + + interface Lambda<T> { + T run(T a, T b); + } + + @Override + public String getModuleName() { + return "com.google.gwt.dev.jjs.Java11Test"; + } + + public void testLambdaParametersVarType() { + Lambda<String> l = (@NotNull var x, var y) -> x + y; + assertEquals("12", l.run("1", "2")); + } + + public void testLambdaParametersVarType_function() { + List<String> l = Arrays.asList("a", "b"); + l = l.stream().map((var s) -> s.toUpperCase()).collect(Collectors.toList()); + assertEquals("A", l.get(0)); + assertEquals("B", l.get(1)); + } +}
diff --git a/user/test/com/google/gwt/dev/jjs/CompilerSuite.java b/user/test/com/google/gwt/dev/jjs/CompilerSuite.java index 3bd801e..7ee0fb2 100644 --- a/user/test/com/google/gwt/dev/jjs/CompilerSuite.java +++ b/user/test/com/google/gwt/dev/jjs/CompilerSuite.java
@@ -28,6 +28,7 @@ import com.google.gwt.dev.jjs.test.InnerClassTest; import com.google.gwt.dev.jjs.test.InnerOuterSuperTest; import com.google.gwt.dev.jjs.test.Java10Test; +import com.google.gwt.dev.jjs.test.Java11Test; import com.google.gwt.dev.jjs.test.Java7Test; import com.google.gwt.dev.jjs.test.Java8Test; import com.google.gwt.dev.jjs.test.JavaAccessFromJavaScriptTest; @@ -73,6 +74,7 @@ // to avoid executing if not in a Java 8+ environment. suite.addTestSuite(Java8Test.class); suite.addTestSuite(Java10Test.class); + suite.addTestSuite(Java11Test.class); suite.addTestSuite(JavaAccessFromJavaScriptTest.class); suite.addTestSuite(JsniConstructorTest.class); suite.addTestSuite(JsniDispatchTest.class);
diff --git a/user/test/com/google/gwt/dev/jjs/Java11Test.gwt.xml b/user/test/com/google/gwt/dev/jjs/Java11Test.gwt.xml new file mode 100644 index 0000000..a73ecb5 --- /dev/null +++ b/user/test/com/google/gwt/dev/jjs/Java11Test.gwt.xml
@@ -0,0 +1,19 @@ +<!-- --> +<!-- Copyright 2019 Google Inc. --> +<!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> +<!-- may not use this file except in compliance with the License. You may --> +<!-- may obtain a copy of the License at --> +<!-- --> +<!-- http://www.apache.org/licenses/LICENSE-2.0 --> +<!-- --> +<!-- Unless required by applicable law or agreed to in writing, software --> +<!-- distributed under the License is distributed on an "AS IS" BASIS, --> +<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or --> +<!-- implied. License for the specific language governing permissions and --> +<!-- limitations under the License. --> + +<!-- Contains tests for breaking out of the client source path --> +<module> + <inherits name="com.google.gwt.core.Core" /> + <super-source path='super' /> +</module> \ No newline at end of file
diff --git a/user/test/com/google/gwt/dev/jjs/test/Java11Test.java b/user/test/com/google/gwt/dev/jjs/test/Java11Test.java new file mode 100644 index 0000000..446c487 --- /dev/null +++ b/user/test/com/google/gwt/dev/jjs/test/Java11Test.java
@@ -0,0 +1,56 @@ +/* + * Copyright 2019 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.dev.jjs.test; + +import com.google.gwt.dev.util.arg.SourceLevel; +import com.google.gwt.junit.DoNotRunWith; +import com.google.gwt.junit.JUnitShell; +import com.google.gwt.junit.Platform; +import com.google.gwt.junit.client.GWTTestCase; + +/** + * Dummy test case. Java11Test is super sourced so that GWT can be compiled by Java 8. + * + * NOTE: Make sure this class has the same test methods of its supersourced variant. + */ +@DoNotRunWith(Platform.Devel) +public class Java11Test extends GWTTestCase { + + @Override + public String getModuleName() { + return "com.google.gwt.dev.jjs.Java11Test"; + } + + @Override + public void runTest() throws Throwable { + // Only run these tests if -sourceLevel 11 (or greater) is enabled. + if (isGwtSourceLevel11()) { + super.runTest(); + } + } + + public void testLambdaParametersVarType() { + assertFalse(isGwtSourceLevel11()); + } + + public void testLambdaParametersVarType_function() { + assertFalse(isGwtSourceLevel11()); + } + + private boolean isGwtSourceLevel11() { + return JUnitShell.getCompilerOptions().getSourceLevel().compareTo(SourceLevel.JAVA11) >= 0; + } +}