diff -r f9f144c148ac test/langtools/tools/javac/6917288/GraphicalInstallerTest.java --- a/test/langtools/tools/javac/6917288/GraphicalInstallerTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/6917288/GraphicalInstallerTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -47,7 +47,6 @@ } check(classes, - "GraphicalInstaller$1.class", "GraphicalInstaller$1X$1.class", "GraphicalInstaller$1X.class", "GraphicalInstaller$BackgroundInstaller.class", diff -r f9f144c148ac test/langtools/tools/javac/6917288/T6917288.java --- a/test/langtools/tools/javac/6917288/T6917288.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/6917288/T6917288.java Wed Feb 07 15:57:40 2018 +0000 @@ -69,7 +69,14 @@ return; } - check(classesDir, "Test.class", "Test$Inner.class", "Test$1.class"); + switch (k) { + case ALWAYS: + case TRUE: + check(classesDir, "Test.class", "Test$Inner.class", "Test$1.class"); + break; + default: + check(classesDir, "Test.class", "Test$Inner.class"); + } } /** diff -r f9f144c148ac test/langtools/tools/javac/7199823/InnerClassCannotBeVerified.java --- a/test/langtools/tools/javac/7199823/InnerClassCannotBeVerified.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/7199823/InnerClassCannotBeVerified.java Wed Feb 07 15:57:40 2018 +0000 @@ -29,6 +29,7 @@ * @run main InnerClassCannotBeVerified */ +import java.nio.file.NoSuchFileException; import java.util.Arrays; import javax.tools.JavaFileObject; import java.net.URI; @@ -43,6 +44,17 @@ public class InnerClassCannotBeVerified { + enum CompilationKind { + PRE_NESTMATES("-source", "10", "-target", "10"), + POST_NESTMATES(); + + String[] opts; + + CompilationKind(String... opts) { + this.opts = opts; + } + } + private static final String errorMessage = "Compile error while compiling the following source:\n"; @@ -51,34 +63,49 @@ } void run() throws Exception { - JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); - JavaSource source = new JavaSource(); - JavacTask ct = (JavacTask)comp.getTask(null, null, null, - null, null, Arrays.asList(source)); - try { - if (!ct.call()) { + for (CompilationKind ck : CompilationKind.values()) { + File file = new File("Test$1.class"); + if (file.exists()) { + file.delete(); + } + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + JavaSource source = new JavaSource(); + JavacTask ct = (JavacTask)comp.getTask(null, null, null, + Arrays.asList(ck.opts), null, Arrays.asList(source)); + try { + if (!ct.call()) { + throw new AssertionError(errorMessage + + source.getCharContent(true)); + } + } catch (Throwable ex) { throw new AssertionError(errorMessage + source.getCharContent(true)); } - } catch (Throwable ex) { - throw new AssertionError(errorMessage + - source.getCharContent(true)); + check(ck); } - check(); } - private void check() throws IOException, ConstantPoolException { - File file = new File("Test$1.class"); - ClassFile classFile = ClassFile.read(file); - boolean inheritsFromObject = - classFile.getSuperclassName().equals("java/lang/Object"); - boolean implementsNoInterface = classFile.interfaces.length == 0; - boolean noMethods = classFile.methods.length == 0; - if (!(inheritsFromObject && - implementsNoInterface && - noMethods)) { - throw new AssertionError("The inner classes reused as " + - "access constructor tag for this code must be empty"); + private void check(CompilationKind ck) throws IOException, ConstantPoolException { + try { + File file = new File("Test$1.class"); + ClassFile classFile = ClassFile.read(file); + if (ck == CompilationKind.POST_NESTMATES) { + throw new AssertionError("Unexpected constructor tag class!"); + } + boolean inheritsFromObject = + classFile.getSuperclassName().equals("java/lang/Object"); + boolean implementsNoInterface = classFile.interfaces.length == 0; + boolean noMethods = classFile.methods.length == 0; + if (!(inheritsFromObject && + implementsNoInterface && + noMethods)) { + throw new AssertionError("The inner classes reused as " + + "access constructor tag for this code must be empty"); + } + } catch (NoSuchFileException ex) { + if (ck == CompilationKind.PRE_NESTMATES) { + throw new AssertionError("Constructor tag class missing!"); + } } } diff -r f9f144c148ac test/langtools/tools/javac/classfiles/attributes/SourceFile/SyntheticClassTest.java --- a/test/langtools/tools/javac/classfiles/attributes/SourceFile/SyntheticClassTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/classfiles/attributes/SourceFile/SyntheticClassTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -30,14 +30,30 @@ * jdk.compiler/com.sun.tools.javac.main * jdk.jdeps/com.sun.tools.classfile * @build toolbox.ToolBox InMemoryFileManager TestBase SourceFileTestBase - * @run main SyntheticClassTest + * @compile -source 10 -target 10 SyntheticClassTest.java + * @run main SyntheticClassTest true + * @clean SyntheticClassTest$1 + * @compile SyntheticClassTest.java + * @run main SyntheticClassTest false */ +import java.nio.file.NoSuchFileException; + public class SyntheticClassTest extends SourceFileTestBase { public static void main(String[] args) throws Exception { + boolean expectSynthetic = Boolean.parseBoolean(args[0]); new Inner(); - new SyntheticClassTest().test("SyntheticClassTest$1", "SyntheticClassTest.java"); + try { + new SyntheticClassTest().test("SyntheticClassTest$1", "SyntheticClassTest.java"); + if (!expectSynthetic) { + throw new AssertionError("Synthetic class should not have been emitted!"); + } + } catch (NoSuchFileException ex) { + if (expectSynthetic) { + throw new AssertionError("Synthetic class should have been emitted!"); + } + } } static class Inner { diff -r f9f144c148ac test/langtools/tools/javac/classfiles/attributes/Synthetic/AccessToPrivateInnerClassMembersTest.java --- a/test/langtools/tools/javac/classfiles/attributes/Synthetic/AccessToPrivateInnerClassMembersTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/classfiles/attributes/Synthetic/AccessToPrivateInnerClassMembersTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -32,7 +32,7 @@ * @library /tools/lib /tools/javac/lib ../lib * @build toolbox.ToolBox InMemoryFileManager TestResult * @build AccessToPrivateInnerClassMembersTest SyntheticTestDriver ExpectedClass ExpectedClasses - * @run main SyntheticTestDriver AccessToPrivateInnerClassMembersTest 1 + * @run main SyntheticTestDriver AccessToPrivateInnerClassMembersTest */ /** @@ -51,12 +51,10 @@ @ExpectedClass(className = "AccessToPrivateInnerClassMembersTest$Inner1", expectedMethods = {"(AccessToPrivateInnerClassMembersTest)", "function()"}, expectedFields = "var", - expectedNumberOfSyntheticMethods = 4, expectedNumberOfSyntheticFields = 1) @ExpectedClass(className = "AccessToPrivateInnerClassMembersTest$Inner2", expectedMethods = {"function()", "staticFunction()", "()"}, - expectedFields = {"staticVar", "var"}, - expectedNumberOfSyntheticMethods = 7) + expectedFields = {"staticVar", "var"}) public class AccessToPrivateInnerClassMembersTest { private class Inner1 { diff -r f9f144c148ac test/langtools/tools/javac/classfiles/attributes/Synthetic/AccessToPrivateSiblingsTest.java --- a/test/langtools/tools/javac/classfiles/attributes/Synthetic/AccessToPrivateSiblingsTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/classfiles/attributes/Synthetic/AccessToPrivateSiblingsTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -32,7 +32,7 @@ * @library /tools/lib /tools/javac/lib ../lib * @build toolbox.ToolBox InMemoryFileManager TestResult TestBase * @build AccessToPrivateSiblingsTest SyntheticTestDriver ExpectedClass ExpectedClasses - * @run main SyntheticTestDriver AccessToPrivateSiblingsTest 1 + * @run main SyntheticTestDriver AccessToPrivateSiblingsTest */ /** @@ -50,19 +50,16 @@ @ExpectedClass(className = "AccessToPrivateSiblingsTest$Inner1", expectedMethods = {"function()", "(AccessToPrivateSiblingsTest)"}, expectedFields = "var", - expectedNumberOfSyntheticMethods = 4, expectedNumberOfSyntheticFields = 1) @ExpectedClass(className = "AccessToPrivateSiblingsTest$Inner2", expectedMethods = "(AccessToPrivateSiblingsTest)", expectedNumberOfSyntheticFields = 1) @ExpectedClass(className = "AccessToPrivateSiblingsTest$Inner3", expectedMethods = {"()", "function()", "staticFunction()", "()"}, - expectedFields = {"var", "staticVar"}, - expectedNumberOfSyntheticMethods = 4) + expectedFields = {"var", "staticVar"}) @ExpectedClass(className = "AccessToPrivateSiblingsTest$Inner4", expectedMethods = {"()", "function()", "staticFunction()"}, - expectedFields = {"var", "staticVar"}, - expectedNumberOfSyntheticMethods = 4) + expectedFields = {"var", "staticVar"}) public class AccessToPrivateSiblingsTest { private class Inner1 { diff -r f9f144c148ac test/langtools/tools/javac/classfiles/attributes/Synthetic/BridgeMethodsForLambdaTest.java --- a/test/langtools/tools/javac/classfiles/attributes/Synthetic/BridgeMethodsForLambdaTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/classfiles/attributes/Synthetic/BridgeMethodsForLambdaTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -32,7 +32,7 @@ * @library /tools/lib /tools/javac/lib ../lib * @build toolbox.ToolBox InMemoryFileManager TestResult TestBase * @build BridgeMethodsForLambdaTest SyntheticTestDriver ExpectedClass ExpectedClasses - * @run main SyntheticTestDriver BridgeMethodsForLambdaTest 1 + * @run main SyntheticTestDriver BridgeMethodsForLambdaTest */ import java.util.Comparator; @@ -58,15 +58,14 @@ @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner1", expectedMethods = {"(BridgeMethodsForLambdaTest)", "function()", "run()"}, expectedFields = "lambda1", - expectedNumberOfSyntheticMethods = 4, + expectedNumberOfSyntheticMethods = 1, expectedNumberOfSyntheticFields = 1) @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner2", expectedMethods = {"()", "staticFunction()"}, expectedFields = "lambda1", - expectedNumberOfSyntheticMethods = 3) + expectedNumberOfSyntheticMethods = 1) @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner3", expectedMethods = {"(BridgeMethodsForLambdaTest)", "function()"}, - expectedNumberOfSyntheticMethods = 1, expectedNumberOfSyntheticFields = 1) @ExpectedClass(className = "BridgeMethodsForLambdaTest$Inner4", expectedMethods = {"(BridgeMethodsForLambdaTest)", "function()"}, diff -r f9f144c148ac test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesInInnerClassTest.java --- a/test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesInInnerClassTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesInInnerClassTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -31,21 +31,30 @@ * jdk.jdeps/com.sun.tools.classfile * @build toolbox.ToolBox InMemoryFileManager TestResult TestBase * @build InnerClassesInInnerClassTestBase InnerClassesTestBase - * @run main InnerClassesInInnerClassTest + * @run main InnerClassesInInnerClassTest true + * @run main InnerClassesInInnerClassTest false */ +import java.util.Arrays; import java.util.List; public class InnerClassesInInnerClassTest extends InnerClassesInInnerClassTestBase { + final boolean expectSyntheticClass; + + public InnerClassesInInnerClassTest(boolean expectSyntheticClass) { + this.expectSyntheticClass = expectSyntheticClass; + } + public static void main(String[] args) throws TestFailedException { - InnerClassesTestBase test = new InnerClassesInInnerClassTest(); + boolean expectSyntheticClass = Boolean.parseBoolean(args[0]); + InnerClassesTestBase test = new InnerClassesInInnerClassTest(expectSyntheticClass); test.test("InnerClassesSrc$Inner", "Inner", "1"); } @Override public void setProperties() { - setHasSyntheticClass(true); + setHasSyntheticClass(expectSyntheticClass); setOuterClassType(ClassType.CLASS); setInnerClassType(ClassType.CLASS); } @@ -62,4 +71,11 @@ return sources; } + + @Override + protected List getCompileOptions() { + return !expectSyntheticClass ? + super.getCompileOptions() : + Arrays.asList("-source", "10", "-target", "10"); + } } diff -r f9f144c148ac test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesInInnerEnumTest.java --- a/test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesInInnerEnumTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesInInnerEnumTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -31,13 +31,24 @@ * jdk.jdeps/com.sun.tools.classfile * @build toolbox.ToolBox InMemoryFileManager TestResult TestBase * @build InnerClassesInInnerClassTestBase InnerClassesTestBase - * @run main InnerClassesInInnerEnumTest + * @run main InnerClassesInInnerEnumTest true + * @run main InnerClassesInInnerEnumTest false */ +import java.util.Arrays; +import java.util.List; + public class InnerClassesInInnerEnumTest extends InnerClassesInInnerClassTestBase { + final boolean expectSyntheticClass; + + public InnerClassesInInnerEnumTest(boolean expectSyntheticClass) { + this.expectSyntheticClass = expectSyntheticClass; + } + public static void main(String[] args) throws TestFailedException { - InnerClassesTestBase test = new InnerClassesInInnerEnumTest(); + boolean expectSyntheticClass = Boolean.parseBoolean(args[0]); + InnerClassesTestBase test = new InnerClassesInInnerEnumTest(expectSyntheticClass); test.test("InnerClassesSrc$Inner", "Inner", "1"); } @@ -46,8 +57,15 @@ setOuterOtherModifiers(Modifier.EMPTY, Modifier.STATIC); setOuterClassType(ClassType.ENUM); setInnerClassType(ClassType.CLASS); - setHasSyntheticClass(true); + setHasSyntheticClass(expectSyntheticClass); setPrefix("Inner {;"); setSuffix("}"); } + + @Override + protected List getCompileOptions() { + return !expectSyntheticClass ? + super.getCompileOptions() : + Arrays.asList("-source", "10", "-target", "10"); + } } diff -r f9f144c148ac test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesTest.java --- a/test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -31,20 +31,29 @@ * jdk.jdeps/com.sun.tools.classfile * @build toolbox.ToolBox InMemoryFileManager TestResult TestBase * @build InnerClassesTestBase - * @run main InnerClassesTest + * @run main InnerClassesTest true + * @run main InnerClassesTest false */ +import java.util.Arrays; import java.util.List; public class InnerClassesTest extends InnerClassesTestBase { + final boolean expectSyntheticClass; + + public InnerClassesTest(boolean expectSyntheticClass) { + this.expectSyntheticClass = expectSyntheticClass; + } + public static void main(String[] args) throws TestFailedException { - new InnerClassesTest().test("InnerClassesSrc"); + boolean expectSyntheticClass = Boolean.parseBoolean(args[0]); + new InnerClassesTest(expectSyntheticClass).test("InnerClassesSrc"); } private List generateClasses() { setInnerClassType(ClassType.CLASS); - setHasSyntheticClass(true); + setHasSyntheticClass(expectSyntheticClass); return super.generateTestCases(); } @@ -82,4 +91,11 @@ sources.addAll(generateAnnotations()); return sources; } + + @Override + protected List getCompileOptions() { + return !expectSyntheticClass ? + super.getCompileOptions() : + Arrays.asList("-source", "10", "-target", "10"); + } } diff -r f9f144c148ac test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesTestBase.java --- a/test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesTestBase.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesTestBase.java Wed Feb 07 15:57:40 2018 +0000 @@ -199,7 +199,7 @@ printf("Testing :\n%s\n", test.getSource()); try { Map> class2Flags = test.getFlags(); - ClassFile cf = readClassFile(compile(test.getSource()) + ClassFile cf = readClassFile(compile(getCompileOptions(), test.getSource()) .getClasses().get(classToTest)); InnerClasses_attribute innerClasses = (InnerClasses_attribute) cf.getAttribute(Attribute.InnerClasses); @@ -324,6 +324,10 @@ return flags; } + protected List getCompileOptions() { + return Collections.emptyList(); + } + private List> getAllCombinations(Modifier[] accessModifiers, Modifier[] otherModifiers) { List> list = new ArrayList<>(); for (Modifier access : accessModifiers) { diff -r f9f144c148ac test/langtools/tools/javac/nativeHeaders/NativeHeaderTest.java --- a/test/langtools/tools/javac/nativeHeaders/NativeHeaderTest.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/nativeHeaders/NativeHeaderTest.java Wed Feb 07 15:57:40 2018 +0000 @@ -122,7 +122,7 @@ // double check the synthetic class was generated checkEqual("generatedClasses", - createSet("C.class", "C$1.class", "C$Inner.class"), + createSet("C.class", "C$Inner.class"), createSet(classesDir.list())); } diff -r f9f144c148ac test/langtools/tools/javac/processing/model/completionfailure/NoAbortForBadClassFile.java --- a/test/langtools/tools/javac/processing/model/completionfailure/NoAbortForBadClassFile.java Tue Feb 06 06:45:09 2018 -0500 +++ b/test/langtools/tools/javac/processing/model/completionfailure/NoAbortForBadClassFile.java Wed Feb 07 15:57:40 2018 +0000 @@ -120,6 +120,7 @@ new toolbox.JavacTask(tb) .outdir(out) + .options("-source", "10", "-target", "10") .files(tb.findJavaFiles(src)) .run(Expect.SUCCESS) .writeAll()