diff --git a/test/langtools/lib/combo/TEST.properties b/test/langtools/lib/combo/TEST.properties index 01991acf216..84ff3d14656 100644 --- a/test/langtools/lib/combo/TEST.properties +++ b/test/langtools/lib/combo/TEST.properties @@ -1,6 +1,6 @@ -# This file identifies root(s) of the test-ng hierarchy. +# This file identifies root(s) of the JUnit hierarchy. -TestNG.dirs = . +JUnit.dirs = . modules = \ jdk.compiler/com.sun.tools.javac.util diff --git a/test/langtools/lib/combo/tools/javac/combo/ComboWatcher.java b/test/langtools/lib/combo/tools/javac/combo/ComboWatcher.java new file mode 100644 index 00000000000..e2164e6e187 --- /dev/null +++ b/test/langtools/lib/combo/tools/javac/combo/ComboWatcher.java @@ -0,0 +1,31 @@ +package tools.javac.combo; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestWatcher; + +public class ComboWatcher implements TestWatcher, AfterAllCallback { + private final Set errors = Collections.synchronizedSet(new HashSet<>()); + + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + if (context.getRequiredTestInstance() instanceof JavacTemplateTestBase instance) { + errors.addAll(instance.diags.errorKeys()); + if (instance instanceof CompilationTestCase) { + // Make sure offending template ends up in log file on failure + System.err.printf("Diagnostics: %s%nTemplate: %s%n", instance.diags.errorKeys(), + instance.sourceFiles.stream().map(SourceFile::template).toList()); + } + } + } + + @Override + public void afterAll(ExtensionContext extensionContext) { + if (errors.isEmpty()) return; + System.err.println("Errors found in tests: " + errors); + } +} diff --git a/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java b/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java index 27a2940a2c8..0760352e23b 100644 --- a/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java +++ b/test/langtools/lib/combo/tools/javac/combo/CompilationTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,30 +31,14 @@ import java.util.stream.IntStream; import javax.tools.Diagnostic; -import org.testng.ITestResult; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; - -import static java.util.stream.Collectors.toList; - /** * Base class for negative and positive compilation tests. */ -@Test public class CompilationTestCase extends JavacTemplateTestBase { - private String[] compileOptions = new String[] { }; + private String[] compileOptions = new String[]{}; private String defaultFileName = "Source.java"; private String programShell = "#"; - @AfterMethod - public void dumpTemplateIfError(ITestResult result) { - // Make sure offending template ends up in log file on failure - if (!result.isSuccess()) { - System.err.printf("Diagnostics: %s%nTemplate: %s%n", diags.errorKeys(), - sourceFiles.stream().map(p -> p.snd).collect(toList())); - } - } - protected void setProgramShell(String shell) { programShell = shell; } @@ -81,7 +65,7 @@ public class CompilationTestCase extends JavacTemplateTestBase { throw new AssertionError("unexpected negative value " + i); } if (i >= compileOptions.length) { - compileOptions = new String[] {}; + compileOptions = new String[]{}; } else { compileOptions = Arrays.copyOf(compileOptions, compileOptions.length - i); } @@ -105,8 +89,7 @@ public class CompilationTestCase extends JavacTemplateTestBase { File dir = null; try { dir = compile(generate); - } - catch (IOException e) { + } catch (IOException e) { throw new RuntimeException(e); } postTest.run(); diff --git a/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java b/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java index be94ec7a3fa..02c94b589c8 100644 --- a/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java +++ b/test/langtools/lib/combo/tools/javac/combo/JavacTemplateTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,10 +33,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import javax.tools.Diagnostic; @@ -48,17 +46,13 @@ import javax.tools.StandardLocation; import javax.tools.ToolProvider; import com.sun.source.util.JavacTask; -import com.sun.tools.javac.util.Pair; -import org.testng.ITestResult; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** - * Base class for template-driven TestNG javac tests that support on-the-fly + * Base class for template-driven JUnit javac tests that support on-the-fly * source file generation, compilation, classloading, execution, and separate * compilation. * @@ -70,16 +64,15 @@ import static org.testng.Assert.fail; * * @author Brian Goetz */ -@Test +@ExtendWith(ComboWatcher.class) public abstract class JavacTemplateTestBase { - private static final Set suiteErrors = Collections.synchronizedSet(new HashSet<>()); private static final AtomicInteger counter = new AtomicInteger(); private static final File root = new File("gen"); private static final File nullDir = new File("empty"); protected final Map templates = new HashMap<>(); protected final Diagnostics diags = new Diagnostics(); - protected final List> sourceFiles = new ArrayList<>(); + protected final List sourceFiles = new ArrayList<>(); protected final List compileOptions = new ArrayList<>(); protected final List classpaths = new ArrayList<>(); @@ -95,7 +88,7 @@ public abstract class JavacTemplateTestBase { /** Add a source file */ protected void addSourceFile(String name, String template) { - sourceFiles.add(new Pair<>(name, template)); + sourceFiles.add(new SourceFile(name, template)); } /** Add a File to the class path to be used when loading classes; File values @@ -130,7 +123,7 @@ public abstract class JavacTemplateTestBase { protected void resetClassPaths() { classpaths.clear(); } // Before each test method, reset everything - @BeforeMethod + @BeforeEach public void reset() { resetCompileOptions(); resetDiagnostics(); @@ -139,38 +132,6 @@ public abstract class JavacTemplateTestBase { resetClassPaths(); } - // After each test method, if the test failed, capture source files and diagnostics and put them in the log - @AfterMethod - public void copyErrors(ITestResult result) { - if (!result.isSuccess()) { - suiteErrors.addAll(diags.errorKeys()); - - List list = new ArrayList<>(); - Collections.addAll(list, result.getParameters()); - list.add("Test case: " + getTestCaseDescription()); - for (Pair e : sourceFiles) - list.add("Source file " + e.fst + ": " + e.snd); - if (diags.errorsFound()) - list.add("Compile diagnostics: " + diags.toString()); - result.setParameters(list.toArray(new Object[list.size()])); - } - } - - @AfterSuite - // After the suite is done, dump any errors to output - public void dumpErrors() { - if (!suiteErrors.isEmpty()) - System.err.println("Errors found in test suite: " + suiteErrors); - } - - /** - * Get a description of this test case; since test cases may be combinatorially - * generated, this should include all information needed to describe the test case - */ - protected String getTestCaseDescription() { - return this.toString(); - } - /** Assert that all previous calls to compile() succeeded */ protected void assertCompileSucceeded() { if (diags.errorsFound()) @@ -258,9 +219,7 @@ public abstract class JavacTemplateTestBase { /** Compile all registered source files, optionally generating class files * and returning a File describing the directory to which they were written */ protected File compile(boolean generate) throws IOException { - List files = new ArrayList<>(); - for (Pair e : sourceFiles) - files.add(new FileAdapter(e.fst, e.snd)); + var files = sourceFiles.stream().map(FileAdapter::new).toList(); return compile(classpaths, files, generate); } @@ -268,13 +227,11 @@ public abstract class JavacTemplateTestBase { * for finding required classfiles, optionally generating class files * and returning a File describing the directory to which they were written */ protected File compile(List classpaths, boolean generate) throws IOException { - List files = new ArrayList<>(); - for (Pair e : sourceFiles) - files.add(new FileAdapter(e.fst, e.snd)); + var files = sourceFiles.stream().map(FileAdapter::new).toList(); return compile(classpaths, files, generate); } - private File compile(List classpaths, List files, boolean generate) throws IOException { + private File compile(List classpaths, List files, boolean generate) throws IOException { JavaCompiler systemJavaCompiler = ToolProvider.getSystemJavaCompiler(); try (StandardJavaFileManager fm = systemJavaCompiler.getStandardFileManager(null, null, null)) { if (classpaths.size() > 0) @@ -327,9 +284,9 @@ public abstract class JavacTemplateTestBase { private class FileAdapter extends SimpleJavaFileObject { private final String templateString; - FileAdapter(String filename, String templateString) { - super(URI.create("myfo:/" + filename), Kind.SOURCE); - this.templateString = templateString; + FileAdapter(SourceFile file) { + super(URI.create("myfo:/" + file.name()), Kind.SOURCE); + this.templateString = file.template(); } public CharSequence getCharContent(boolean ignoreEncodingErrors) { diff --git a/test/langtools/lib/combo/tools/javac/combo/SourceFile.java b/test/langtools/lib/combo/tools/javac/combo/SourceFile.java new file mode 100644 index 00000000000..4ebbb80acbb --- /dev/null +++ b/test/langtools/lib/combo/tools/javac/combo/SourceFile.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package tools.javac.combo; + +public record SourceFile(String name, String template) {} diff --git a/test/langtools/lib/combo/tools/javac/combo/TemplateTest.java b/test/langtools/lib/combo/tools/javac/combo/TemplateTest.java index bdb7695e659..3aa324fa983 100644 --- a/test/langtools/lib/combo/tools/javac/combo/TemplateTest.java +++ b/test/langtools/lib/combo/tools/javac/combo/TemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,34 +23,34 @@ package tools.javac.combo; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; import java.util.HashMap; import java.util.Map; -import static org.testng.Assert.assertEquals; - /** * TemplateTest */ -@Test -public class TemplateTest { - Map vars = new HashMap<>(); +class TemplateTest { + final Map vars = new HashMap<>(); - @BeforeTest + @BeforeEach void before() { vars.clear(); } private void assertTemplate(String expected, String template) { String result = Template.expandTemplate(template, vars); - assertEquals(result, expected, "for " + template); + assertEquals(expected, result, "for " + template); } private String dotIf(String s) { return s == null || s.isEmpty() ? "" : "." + s; } - public void testTemplateExpansion() { + @Test + void testTemplateExpansion() { vars.put("A", s -> "a" + dotIf(s)); vars.put("B", s -> "b" + dotIf(s)); vars.put("C", s -> "#{A}#{B}"); @@ -72,7 +72,8 @@ public class TemplateTest { assertTemplate("#{A", "#{A"); } - public void testIndexedTemplate() { + @Test + void testIndexedTemplate() { vars.put("A[0]", s -> "a" ); vars.put("A[1]", s -> "b" ); vars.put("A[2]", s -> "c" ); @@ -82,13 +83,14 @@ public class TemplateTest { assertTemplate("c", "#{A[2]}"); } - public void testAngleBrackets() { + @Test + void testAngleBrackets() { vars.put("X", s -> "xyz"); assertTemplate("List ls = xyz;", "List ls = #{X};"); } - @Test(expectedExceptions = IllegalStateException.class ) - public void testUnknownKey() { - assertTemplate("#{Q}", "#{Q}"); + @Test + void testUnknownKey() { + assertThrows(IllegalStateException.class, () -> assertTemplate("#{Q}", "#{Q}")); } } diff --git a/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java b/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java index 1459357bb09..2464f4cd329 100644 --- a/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java +++ b/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,19 +21,12 @@ * questions. */ -import java.io.IOException; import java.util.List; -import org.testng.ITestResult; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import tools.javac.combo.CompilationTestCase; -import tools.javac.combo.JavacTemplateTestBase; -import static java.util.stream.Collectors.toList; - -@Test -public class ExpSwitchNestingTest extends CompilationTestCase { +class ExpSwitchNestingTest extends CompilationTestCase { private static final String RUNNABLE = "Runnable r = () -> { # };"; private static final String INT_FN = "java.util.function.IntSupplier r = () -> { # };"; private static final String LABEL = "label: #"; @@ -77,14 +70,16 @@ public class ExpSwitchNestingTest extends CompilationTestCase { setProgramShell(SHELL); } - public void testReallySimpleCases() { + @Test + void testReallySimpleCases() { for (String s : CONTAINERS) assertOK(s, NOTHING); for (String s : CONTAINER_STATEMENTS) assertOK(LABEL, s, NOTHING); } - public void testLambda() { + @Test + void testLambda() { assertOK(RUNNABLE, RETURN_N); assertOK(RUNNABLE, NOTHING); assertOK(INT_FN, RETURN_Z); @@ -106,7 +101,8 @@ public class ExpSwitchNestingTest extends CompilationTestCase { assertFail("compiler.err.undef.label", LABEL, BLOCK, INT_FN, CONTINUE_L); } - public void testEswitch() { + @Test + void testEswitch() { //Int-valued switch expressions assertOK(ESWITCH_Z, YIELD_Z); assertOK(LABEL, BLOCK, ESWITCH_Z, YIELD_Z); @@ -151,7 +147,8 @@ public class ExpSwitchNestingTest extends CompilationTestCase { } - public void testNestedInExpSwitch() { + @Test + void testNestedInExpSwitch() { assertOK(ESWITCH_Z, IF, YIELD_Z); assertOK(ESWITCH_Z, BLOCK, YIELD_Z); // @@ -184,7 +181,8 @@ public class ExpSwitchNestingTest extends CompilationTestCase { assertOK(ESWITCH_Z, YIELD_Z, BLOCK, DO, IF, YIELD_Z); } - public void testBreakExpressionLabelDisambiguation() { + @Test + void testBreakExpressionLabelDisambiguation() { assertOK(DEF_LABEL_VAR, ESWITCH_Z, YIELD_L); assertFail("compiler.err.undef.label", DEF_LABEL_VAR, ESWITCH_Z, BREAK_L); assertFail("compiler.err.break.outside.switch.expression", LABEL, FOR, BLOCK, DEF_LABEL_VAR, ESWITCH_Z, BREAK_L); @@ -194,11 +192,13 @@ public class ExpSwitchNestingTest extends CompilationTestCase { // } - public void testFunReturningSwitchExp() { + @Test + void testFunReturningSwitchExp() { assertOK(INT_FN_ESWITCH, YIELD_INT_FN); } - public void testContinueLoops() { + @Test + void testContinueLoops() { assertOK(LABEL, FOR, CONTINUE_L); assertOK(LABEL, FOR_EACH, CONTINUE_L); assertOK(LABEL, WHILE, CONTINUE_L); diff --git a/test/langtools/tools/javac/expswitch/TEST.properties b/test/langtools/tools/javac/expswitch/TEST.properties index 2c56a1dacff..8bb6d765625 100644 --- a/test/langtools/tools/javac/expswitch/TEST.properties +++ b/test/langtools/tools/javac/expswitch/TEST.properties @@ -1,4 +1,4 @@ -TestNG.dirs = . +JUnit.dirs = . lib.dirs = /lib/combo diff --git a/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java b/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java index f95f8ebcc6d..3c4b85e5e16 100644 --- a/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java +++ b/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,12 +31,12 @@ import java.util.List; import java.util.Map; import java.util.StringJoiner; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.javac.combo.*; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** * BridgeMethodTestCase -- used for asserting linkage to bridges under separate compilation. @@ -56,7 +56,6 @@ import static org.testng.Assert.fail; * @author Brian Goetz */ -@Test public abstract class BridgeMethodTestCase extends JavacTemplateTestBase { private static final String TYPE_LETTERS = "ABCDIJK"; @@ -229,7 +228,7 @@ public abstract class BridgeMethodTestCase extends JavacTemplateTestBase { return files; } - @BeforeMethod + @BeforeEach @Override public void reset() { compileDirs.clear(); diff --git a/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java b/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java index a4be15d320b..3786f62365d 100644 --- a/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java +++ b/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,16 +22,16 @@ */ import java.io.IOException; - -import org.testng.annotations.Test; +import tools.javac.combo.*; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * BridgeMethodsTemplateTest * * @author Brian Goetz */ -@Test -public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { +class BridgeMethodsTemplateTest extends BridgeMethodTestCase { /* * Cc1(A) -> Cc1(Ac0) @@ -39,7 +39,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited from A * 1: Declared in C */ - public void test1() throws IOException, ReflectiveOperationException { + @Test + void test1() throws IOException, ReflectiveOperationException { compileSpec("Cc1(A)"); assertLinkage("C", LINKAGE_ERROR, "C1"); recompileSpec("Cc1(Ac0)", "A"); @@ -52,7 +53,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited default from I * 1: Declared in C */ - public void test2() throws IOException, ReflectiveOperationException { + @Test + void test2() throws IOException, ReflectiveOperationException { compileSpec("Cc1(I)"); assertLinkage("C", LINKAGE_ERROR, "C1"); recompileSpec("Cc1(Id0)", "I"); @@ -65,7 +67,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited from A * 1: Inherited from B */ - public void test3() throws IOException, ReflectiveOperationException { + @Test + void test3() throws IOException, ReflectiveOperationException { compileSpec("C(Bc1(A))"); assertLinkage("C", LINKAGE_ERROR, "B1"); recompileSpec("C(Bc1(Ac0))", "A"); @@ -78,7 +81,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0: Inherited from B (through bridge) * 1: Inherited from B */ - public void test4() throws IOException, ReflectiveOperationException { + @Test + void test4() throws IOException, ReflectiveOperationException { compileSpec("C(B(Ac0))"); assertLinkage("C", "A0", LINKAGE_ERROR); recompileSpec("C(Bc1(Ac0))", "B"); @@ -91,7 +95,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0: Inherited from B (through bridge) * 1: Inherited from B */ - public void test5() throws IOException, ReflectiveOperationException { + @Test + void test5() throws IOException, ReflectiveOperationException { compileSpec("C(B(A))"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR); recompileSpec("C(Bc1(Ac0))", "A", "B"); @@ -104,7 +109,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited default from I * 1: Inherited from A */ - public void test6() throws IOException, ReflectiveOperationException { + @Test + void test6() throws IOException, ReflectiveOperationException { compileSpec("C(Ac1(I))"); assertLinkage("C", LINKAGE_ERROR, "A1"); recompileSpec("C(Ac1(Id0))", "I"); @@ -117,7 +123,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0: Inherited from A (through bridge) * 1: Inherited from A */ - public void test7() throws IOException, ReflectiveOperationException { + @Test + void test7() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0))"); assertLinkage("C", "I0", LINKAGE_ERROR); recompileSpec("C(Ac1(Id0))", "A"); @@ -130,7 +137,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited from A (through bridge) * 1*: Inherited from A */ - public void test8() throws IOException, ReflectiveOperationException { + @Test + void test8() throws IOException, ReflectiveOperationException { compileSpec("C(A(I))"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR); recompileSpec("C(Ac1(Id0))", "A", "I"); @@ -143,7 +151,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited default from J * 1: Inherited default from I */ - public void test9() throws IOException, ReflectiveOperationException { + @Test + void test9() throws IOException, ReflectiveOperationException { compileSpec("C(Id1(J))"); assertLinkage("C", LINKAGE_ERROR, "I1"); recompileSpec("C(Id1(Jd0))", "J"); @@ -156,7 +165,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0: Inherited default from I (through bridge) * 1: Inherited default from I */ - public void test10() throws IOException, ReflectiveOperationException { + @Test + void test10() throws IOException, ReflectiveOperationException { compileSpec("C(I(Jd0))"); assertLinkage("C", "J0", LINKAGE_ERROR); recompileSpec("C(Id1(Jd0))", "I"); @@ -169,7 +179,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0: Inherited default from I (through bridge) * 1: Inherited default from I */ - public void test11() throws IOException, ReflectiveOperationException { + @Test + void test11() throws IOException, ReflectiveOperationException { compileSpec("C(I(J))"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR); recompileSpec("C(Id1(Jd0))", "I", "J"); @@ -183,7 +194,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from B * 2: Declared in C */ - public void test12() throws IOException, ReflectiveOperationException { + @Test + void test12() throws IOException, ReflectiveOperationException { compileSpec("Cc2(B(Ac0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Bc1(Ac0))", "B"); @@ -197,7 +209,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from B * 2: Declared in C */ - public void test13() throws IOException, ReflectiveOperationException { + @Test + void test13() throws IOException, ReflectiveOperationException { compileSpec("Cc2(B(Aa0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Bc1(Aa0))", "B"); @@ -211,7 +224,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Declared in C (through bridge) * 2: Declared in C */ - public void test14() throws IOException, ReflectiveOperationException { + @Test + void test14() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Bc1(A))"); assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); recompileSpec("Cc2(Bc1(Ac0))", "A"); @@ -225,7 +239,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Declared in C (through bridge) * 2: Declared in C */ - public void test15() throws IOException, ReflectiveOperationException { + @Test + void test15() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Ba1(A))"); assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); recompileSpec("Cc2(Ba1(Ac0))", "A"); @@ -239,7 +254,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from B * 2: Declared in C */ - public void test16() throws IOException, ReflectiveOperationException { + @Test + void test16() throws IOException, ReflectiveOperationException { compileSpec("Cc2(B(A))"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Bc1(Ac0))", "B", "A"); @@ -253,7 +269,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from A * 2: Declared in C */ - public void test17() throws IOException, ReflectiveOperationException { + @Test + void test17() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A(Id0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ac1(Id0))", "A"); @@ -267,7 +284,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from A * 2: Declared in C */ - public void test18() throws IOException, ReflectiveOperationException { + @Test + void test18() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A(Ia0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ac1(Ia0))", "A"); @@ -281,7 +299,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Declared in C (through bridge) * 2: Declared in C */ - public void test19() throws IOException, ReflectiveOperationException { + @Test + void test19() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Ac1(I))"); assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); recompileSpec("Cc2(Ac1(Id0))", "I"); @@ -295,7 +314,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Declared in C (through bridge) * 2: Declared in C */ - public void test20() throws IOException, ReflectiveOperationException { + @Test + void test20() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Aa1(I))"); assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); recompileSpec("Cc2(Aa1(Id0))", "I"); @@ -309,7 +329,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from A * 2: Declared in C */ - public void test21() throws IOException, ReflectiveOperationException { + @Test + void test21() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A(I))"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ac1(Id0))", "A", "I"); @@ -323,7 +344,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test22() throws IOException, ReflectiveOperationException { + @Test + void test22() throws IOException, ReflectiveOperationException { compileSpec("Cc2(J(Id0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Jd1(Id0))", "J"); @@ -337,7 +359,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test23() throws IOException, ReflectiveOperationException { + @Test + void test23() throws IOException, ReflectiveOperationException { compileSpec("Cc2(J(Ia0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Jd1(Ia0))", "J"); @@ -351,7 +374,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Declared in C (through bridge) * 2: Declared in C */ - public void test24() throws IOException, ReflectiveOperationException { + @Test + void test24() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Jd1(I))"); assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); recompileSpec("Cc2(Jd1(Id0))", "I"); @@ -365,7 +389,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Declared in C (through bridge) * 2: Declared in C */ - public void test25() throws IOException, ReflectiveOperationException { + @Test + void test25() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Ja1(I))"); assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); recompileSpec("Cc2(Ja1(Id0))", "I"); @@ -379,7 +404,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test26() throws IOException, ReflectiveOperationException { + @Test + void test26() throws IOException, ReflectiveOperationException { compileSpec("Cc2(J(I))"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Jd1(Id0))", "J", "I"); @@ -392,7 +418,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited default from I * 1: Inherited from A */ - public void test27() throws IOException, ReflectiveOperationException { + @Test + void test27() throws IOException, ReflectiveOperationException { compileSpec("C(Ac1,I)"); assertLinkage("C", LINKAGE_ERROR, "A1"); recompileSpec("C(Ac1,Id0)", "I"); @@ -405,7 +432,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited default from I * 1: Inherited from A */ - public void test28() throws IOException, ReflectiveOperationException { + @Test + void test28() throws IOException, ReflectiveOperationException { compileSpec("C(A,Id0)"); assertLinkage("C", "I0", LINKAGE_ERROR); recompileSpec("C(Ac1,Id0)", "A"); @@ -418,7 +446,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited default from I * 1: Inherited from A */ - public void test29() throws IOException, ReflectiveOperationException { + @Test + void test29() throws IOException, ReflectiveOperationException { compileSpec("C(A,I)"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR); recompileSpec("C(Ac1,Id0)", "A", "I"); @@ -432,7 +461,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Declared in C (through bridge) * 2: Declared in C */ - public void test30() throws IOException, ReflectiveOperationException { + @Test + void test30() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Ac1,I)"); assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); recompileSpec("Cc2(Ac1,Id0)", "I"); @@ -446,7 +476,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Declared in C (through bridge) * 2: Declared in C */ - public void test31() throws IOException, ReflectiveOperationException { + @Test + void test31() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Aa1,I)"); assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); recompileSpec("Cc2(Aa1,Id0)", "I"); @@ -460,7 +491,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from A * 2: Declared in C */ - public void test32() throws IOException, ReflectiveOperationException { + @Test + void test32() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A,Id0)"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ac1,Id0)", "A"); @@ -474,7 +506,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from A * 2: Declared in C */ - public void test33() throws IOException, ReflectiveOperationException { + @Test + void test33() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A,Ia0)"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ac1,Ia0)", "A"); @@ -488,7 +521,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from I * 2: Declared in C */ - public void test34() throws IOException, ReflectiveOperationException { + @Test + void test34() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A,I)"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ac1,Id0)", "A", "I"); @@ -502,7 +536,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test35() throws IOException, ReflectiveOperationException { + @Test + void test35() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Id0,J)"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Id0,Jd1)", "J"); @@ -516,7 +551,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test36() throws IOException, ReflectiveOperationException { + @Test + void test36() throws IOException, ReflectiveOperationException { compileSpec("Cc2(Ia0,J)"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ia0,Jd1)", "J"); @@ -530,7 +566,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test37() throws IOException, ReflectiveOperationException { + @Test + void test37() throws IOException, ReflectiveOperationException { compileSpec("Cc2(I,J)"); assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Id0,Jd1)", "I", "J"); @@ -544,7 +581,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited from A (through bridge) * 1*: Inherited from A */ - public void test38() throws IOException, ReflectiveOperationException { + @Test + void test38() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0),J(Id0))"); assertLinkage("C", "I0", LINKAGE_ERROR); recompileSpec("C(Ac1(Id0),J(Id0))", "A"); @@ -558,7 +596,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0: Inherited default from J (through bridge) * 1*: Inherited default from J */ - public void test39() throws IOException, ReflectiveOperationException { + @Test + void test39() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0),J(Id0))"); assertLinkage("C", "I0", LINKAGE_ERROR); recompileSpec("C(A(Id0),Jd1(Id0))", "J"); @@ -573,7 +612,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Inherited from A */ - public void test40() throws IOException, ReflectiveOperationException { + @Test + void test40() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0),J(Id0))"); assertLinkage("C", "I0", LINKAGE_ERROR); recompileSpec("C(Ac2(Id0),Jd1(Id0))", "A", "J"); @@ -587,7 +627,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 0*: Inherited default from J (through bridge) * 1: Inherited default from J */ - public void test41() throws IOException, ReflectiveOperationException { + @Test + void test41() throws IOException, ReflectiveOperationException { compileSpec("C(J(Id0),K(Id0))"); assertLinkage("C", "I0", LINKAGE_ERROR); recompileSpec("C(Jd1(Id0),K(Id0))", "J"); @@ -601,7 +642,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Inherited from A */ - public void test42() throws IOException, ReflectiveOperationException { + @Test + void test42() throws IOException, ReflectiveOperationException { compileSpec("C(Ac2(Id0),J(Id0))"); assertLinkage("C", "A2", LINKAGE_ERROR, "A2"); recompileSpec("C(Ac2(Id0),Jd1(Id0))", "J"); @@ -615,7 +657,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Inherited from A */ - public void test43() throws IOException, ReflectiveOperationException { + @Test + void test43() throws IOException, ReflectiveOperationException { compileSpec("C(Ac2(Ia0),J(Ia0))"); assertLinkage("C", "A2", LINKAGE_ERROR, "A2"); recompileSpec("C(Ac2(Ia0),Jd1(Ia0))", "J"); @@ -630,7 +673,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Inherited default from J * 2*: Inherited from A */ - public void test44() throws IOException, ReflectiveOperationException { + @Test + void test44() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0),Jd1(Id0))"); assertLinkage("C", "J1", "J1", LINKAGE_ERROR); recompileSpec("C(Ac2(Id0),Jd1(Id0))", "A"); @@ -645,7 +689,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1: Inherited default from J * 2*: Inherited from A */ - public void test45() throws IOException, ReflectiveOperationException { + @Test + void test45() throws IOException, ReflectiveOperationException { compileSpec("C(A(Ia0),Jd1(Ia0))"); assertLinkage("C", "J1", "J1", LINKAGE_ERROR); recompileSpec("C(Ac2(Ia0),Jd1(Ia0))", "A"); @@ -659,7 +704,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from A * 2: Declared in C */ - public void test46() throws IOException, ReflectiveOperationException { + @Test + void test46() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A(Id0),J(Id0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ac1(Id0),J(Id0))", "A"); @@ -673,7 +719,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited from A * 2: Declared in C */ - public void test47() throws IOException, ReflectiveOperationException { + @Test + void test47() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A(Ia0),J(Ia0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Ac1(Ia0),J(Ia0))", "A"); @@ -687,7 +734,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test48() throws IOException, ReflectiveOperationException { + @Test + void test48() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A(Id0),J(Id0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(A(Id0),Jd1(Id0))", "J"); @@ -701,7 +749,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test49() throws IOException, ReflectiveOperationException { + @Test + void test49() throws IOException, ReflectiveOperationException { compileSpec("Cc2(A(Ia0),J(Ia0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(A(Ia0),Jd1(Ia0))", "J"); @@ -717,7 +766,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from J * 3: Declared in C */ - public void test50() throws IOException, ReflectiveOperationException { + @Test + void test50() throws IOException, ReflectiveOperationException { compileSpec("Cc3(A(Id0),J(Id0))"); assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "A", "J"); @@ -732,7 +782,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from J * 3: Declared in C */ - public void test51() throws IOException, ReflectiveOperationException { + @Test + void test51() throws IOException, ReflectiveOperationException { compileSpec("Cc3(A(Ia0),J(Ia0))"); assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "A", "J"); @@ -746,7 +797,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test52() throws IOException, ReflectiveOperationException { + @Test + void test52() throws IOException, ReflectiveOperationException { compileSpec("Cc2(J(Id0),K(Id0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Jd1(Id0),K(Id0))", "J"); @@ -760,7 +812,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 1*: Inherited default from J * 2: Declared in C */ - public void test53() throws IOException, ReflectiveOperationException { + @Test + void test53() throws IOException, ReflectiveOperationException { compileSpec("Cc2(J(Ia0),K(Ia0))"); assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); recompileSpec("Cc2(Jd1(Ia0),K(Ia0))", "J"); @@ -775,7 +828,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from K * 3: Declared in C */ - public void test54() throws IOException, ReflectiveOperationException { + @Test + void test54() throws IOException, ReflectiveOperationException { compileSpec("Cc3(J(Id0),K(Id0))"); assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "J", "K"); @@ -790,7 +844,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from K * 3: Declared in C */ - public void test55() throws IOException, ReflectiveOperationException { + @Test + void test55() throws IOException, ReflectiveOperationException { compileSpec("Cc3(J(Ia0),K(Ia0))"); assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "J", "K"); @@ -805,7 +860,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from J * 3: Declared in C */ - public void test56() throws IOException, ReflectiveOperationException { + @Test + void test56() throws IOException, ReflectiveOperationException { compileSpec("Cc3(Ac1(Id0),J(Id0))"); assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "J"); @@ -820,7 +876,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from J * 3: Declared in C */ - public void test57() throws IOException, ReflectiveOperationException { + @Test + void test57() throws IOException, ReflectiveOperationException { compileSpec("Cc3(Ac1(Ia0),J(Ia0))"); assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "J"); @@ -835,7 +892,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from J * 3: Declared in C */ - public void test58() throws IOException, ReflectiveOperationException { + @Test + void test58() throws IOException, ReflectiveOperationException { compileSpec("Cc3(Aa1(Id0),J(Id0))"); assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Aa1(Id0),Jd2(Id0))", "J"); @@ -850,7 +908,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from J * 3: Declared in C */ - public void test59() throws IOException, ReflectiveOperationException { + @Test + void test59() throws IOException, ReflectiveOperationException { compileSpec("Cc3(Aa1(Ia0),J(Ia0))"); assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Aa1(Ia0),Jd2(Ia0))", "J"); @@ -865,7 +924,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2: Declared in C (through bridge) * 3: Declared in C */ - public void test60() throws IOException, ReflectiveOperationException { + @Test + void test60() throws IOException, ReflectiveOperationException { compileSpec("Cc3(A(Id0),Jd2(Id0))"); assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3"); recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "A"); @@ -880,7 +940,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2: Declared in C (through bridge) * 3: Declared in C */ - public void test61() throws IOException, ReflectiveOperationException { + @Test + void test61() throws IOException, ReflectiveOperationException { compileSpec("Cc3(A(Ia0),Jd2(Ia0))"); assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3"); recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "A"); @@ -895,7 +956,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2: Declared in C (through bridge) * 3: Declared in C */ - public void test62() throws IOException, ReflectiveOperationException { + @Test + void test62() throws IOException, ReflectiveOperationException { compileSpec("Cc3(A(Id0),Ja2(Id0))"); assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3"); recompileSpec("Cc3(Ac1(Id0),Ja2(Id0))", "A"); @@ -910,7 +972,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2: Declared in C (through bridge) * 3: Declared in C */ - public void test63() throws IOException, ReflectiveOperationException { + @Test + void test63() throws IOException, ReflectiveOperationException { compileSpec("Cc3(A(Ia0),Ja2(Ia0))"); assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3"); recompileSpec("Cc3(Ac1(Ia0),Ja2(Ia0))", "A"); @@ -925,7 +988,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from K * 3: Declared in C */ - public void test64() throws IOException, ReflectiveOperationException { + @Test + void test64() throws IOException, ReflectiveOperationException { compileSpec("Cc3(Jd1(Id0),K(Id0))"); assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "K"); @@ -940,7 +1004,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from K * 3: Declared in C */ - public void test65() throws IOException, ReflectiveOperationException { + @Test + void test65() throws IOException, ReflectiveOperationException { compileSpec("Cc3(Jd1(Ia0),K(Ia0))"); assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "K"); @@ -955,7 +1020,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from K * 3: Declared in C */ - public void test66() throws IOException, ReflectiveOperationException { + @Test + void test66() throws IOException, ReflectiveOperationException { compileSpec("Cc3(Jd1(Id0),K(Id0))"); assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "K"); @@ -970,7 +1036,8 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { * 2*: Inherited default from K * 3: Declared in C */ - public void test67() throws IOException, ReflectiveOperationException { + @Test + void test67() throws IOException, ReflectiveOperationException { compileSpec("Cc3(Jd1(Ia0),K(Ia0))"); assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "K"); @@ -978,57 +1045,68 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { } // Dan's set A - public void testA1() throws IOException, ReflectiveOperationException { + @Test + void testA1() throws IOException, ReflectiveOperationException { compileSpec("C(Id0)"); assertLinkage("C", "I0"); } - public void testA2() throws IOException, ReflectiveOperationException { + @Test + void testA2() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0))"); assertLinkage("C", "I0"); } - public void testA3() throws IOException, ReflectiveOperationException { + @Test + void testA3() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0),J)"); assertLinkage("C", "I0"); } - public void testA4() throws IOException, ReflectiveOperationException { + @Test + void testA4() throws IOException, ReflectiveOperationException { compileSpec("D(C(Id0),Jd0(Id0))"); assertLinkage("D", "J0"); assertLinkage("C", "I0"); } - public void testA5() throws IOException, ReflectiveOperationException { + @Test + void testA5() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0),Jd0)", "compiler.err.types.incompatible"); } - public void testA6() throws IOException, ReflectiveOperationException { + @Test + void testA6() throws IOException, ReflectiveOperationException { compileSpec("C(A(Ia0,Jd0))", "compiler.err.does.not.override.abstract", "compiler.err.types.incompatible"); } - public void testA7() throws IOException, ReflectiveOperationException { + @Test + void testA7() throws IOException, ReflectiveOperationException { compileSpec("C(A(Id0,Jd0))", "compiler.err.types.incompatible"); } - public void testA8() throws IOException, ReflectiveOperationException { + @Test + void testA8() throws IOException, ReflectiveOperationException { compileSpec("C(A(Ia0),J)", "compiler.err.does.not.override.abstract"); } - public void testA9() throws IOException, ReflectiveOperationException { + @Test + void testA9() throws IOException, ReflectiveOperationException { compileSpec("C(Ac0(Id0))"); assertLinkage("C", "A0"); } - public void testA10() throws IOException, ReflectiveOperationException { + @Test + void testA10() throws IOException, ReflectiveOperationException { compileSpec("C(Aa0,I)", "compiler.err.does.not.override.abstract"); } - public void testA11() throws IOException, ReflectiveOperationException { + @Test + void testA11() throws IOException, ReflectiveOperationException { compileSpec("C(Ac0,Id0)"); assertLinkage("C", "A0"); } @@ -1036,14 +1114,16 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { // Dan's set B /* B1 can't be done, needs a second concrete class D - public void testB1() throws IOException, ReflectiveOperationException { + @Test + void testB1() throws IOException, ReflectiveOperationException { compileSpec("Cc1(Dc0)"); assertLinkage("C", "C1", "C1"); assertLinkage("D", "A0", LINKAGE_ERROR); } */ - public void testB2() throws IOException, ReflectiveOperationException { + @Test + void testB2() throws IOException, ReflectiveOperationException { compileSpec("Cc1(Ac0)"); assertLinkage("C", "C1", "C1"); } @@ -1056,22 +1136,26 @@ public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { // B4 needs too many classes - public void testB5() throws IOException, ReflectiveOperationException { + @Test + void testB5() throws IOException, ReflectiveOperationException { compileSpec("Cc1(Aa1(Id0))"); assertLinkage("C", "C1", "C1"); } - public void testB6() throws IOException, ReflectiveOperationException { + @Test + void testB6() throws IOException, ReflectiveOperationException { compileSpec("C(Ac1(Id0))"); assertLinkage("C", "A1", "A1"); } - public void testB7() throws IOException, ReflectiveOperationException { + @Test + void testB7() throws IOException, ReflectiveOperationException { compileSpec("Cc1(Id0)"); assertLinkage("C", "C1", "C1"); } - public void testB8() throws IOException, ReflectiveOperationException { + @Test + void testB8() throws IOException, ReflectiveOperationException { compileSpec("C(Jd1(Id0))"); assertLinkage("C", "J1", "J1"); } diff --git a/test/langtools/tools/javac/lambda/bridge/template_tests/TEST.properties b/test/langtools/tools/javac/lambda/bridge/template_tests/TEST.properties index 70090afb5d5..90f2fe459c2 100644 --- a/test/langtools/tools/javac/lambda/bridge/template_tests/TEST.properties +++ b/test/langtools/tools/javac/lambda/bridge/template_tests/TEST.properties @@ -1,6 +1,6 @@ -# This file identifies root(s) of the test-ng hierarchy. +# This file identifies root(s) of the JUnit hierarchy. -TestNG.dirs = . +JUnit.dirs = . lib.dirs = /lib/combo diff --git a/test/langtools/tools/javac/lambda/methodReference/BoundUnboundSearchTest.java b/test/langtools/tools/javac/lambda/methodReference/BoundUnboundSearchTest.java index effce1a30af..6c0dba5e7f2 100644 --- a/test/langtools/tools/javac/lambda/methodReference/BoundUnboundSearchTest.java +++ b/test/langtools/tools/javac/lambda/methodReference/BoundUnboundSearchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * @modules * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.util - * @run testng BoundUnboundSearchTest + * @run junit BoundUnboundSearchTest */ import java.util.function.*; @@ -40,13 +40,10 @@ import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper; import com.sun.tools.javac.util.Assert; import com.sun.tools.javac.util.JCDiagnostic; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import tools.javac.combo.CompilationTestCase; -import static org.testng.Assert.assertEquals; - -@Test -public class BoundUnboundSearchTest extends CompilationTestCase { +class BoundUnboundSearchTest extends CompilationTestCase { static final String TEMPLATE = """ import java.util.function.*; @@ -58,7 +55,7 @@ public class BoundUnboundSearchTest extends CompilationTestCase { } """; - public BoundUnboundSearchTest() { + BoundUnboundSearchTest() { setDefaultFilename("Test.java"); setCompileOptions(new String[]{"--debug=dumpMethodReferenceSearchResults"}); } @@ -75,7 +72,8 @@ public class BoundUnboundSearchTest extends CompilationTestCase { }; } - public void test() { + @Test + void test() { assertOK( getDiagConsumer(0, -1), TEMPLATE.replaceFirst("#CANDIDATES", diff --git a/test/langtools/tools/javac/patterns/scope/ScopeTest.java b/test/langtools/tools/javac/patterns/scope/ScopeTest.java index 1f10fb7dea5..86457df532b 100644 --- a/test/langtools/tools/javac/patterns/scope/ScopeTest.java +++ b/test/langtools/tools/javac/patterns/scope/ScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,18 +23,11 @@ import java.io.IOException; import java.util.Arrays; -import java.util.List; import java.util.stream.Collectors; - -import org.testng.ITestResult; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import tools.javac.combo.JavacTemplateTestBase; -import static java.util.stream.Collectors.toList; - -@Test -public class ScopeTest extends JavacTemplateTestBase { +class ScopeTest extends JavacTemplateTestBase { private static String st_block(String... statements) { return Arrays.stream(statements).collect(Collectors.joining("", "{", "}")); @@ -84,14 +77,6 @@ public class ScopeTest extends JavacTemplateTestBase { return "!(" + expr + ")"; } - @AfterMethod - public void dumpTemplateIfError(ITestResult result) { - // Make sure offending template ends up in log file on failure - if (!result.isSuccess()) { - System.err.printf("Diagnostics: %s%nTemplate: %s%n", diags.errorKeys(), sourceFiles.stream().map(p -> p.snd).collect(toList())); - } - } - private void program(String block) { String s = "class C { void m(Object o) " + block + "}"; addSourceFile("C.java", s); @@ -121,24 +106,28 @@ public class ScopeTest extends JavacTemplateTestBase { assertCompileFailed(expectedDiag); } - public void testIf() { + @Test + void testIf() { assertOK(st_block(st_if(expr_o_match_str(), st_s_use(), st_return()), st_s_use())); assertOK(st_block(st_if(expr_not(expr_o_match_str()), st_return(), st_s_use()), st_s_use())); assertFail("compiler.err.cant.resolve.location", st_block(st_if(expr_o_match_str(), st_s_use(), st_noop()), st_s_use())); assertFail("compiler.err.cant.resolve.location", st_block(st_if(expr_not(expr_o_match_str()), st_noop(), st_s_use()), st_s_use())); } - public void testWhile() { + @Test + void testWhile() { assertOK(st_block(st_while(expr_not(expr_o_match_str()), st_noop()), st_s_use())); assertFail("compiler.err.cant.resolve.location", st_block(st_while(expr_not(expr_o_match_str()), st_break()), st_s_use())); } - public void testDoWhile() { + @Test + void testDoWhile() { assertOK(st_block(st_do_while(st_noop(), expr_not(expr_o_match_str())), st_s_use())); assertFail("compiler.err.cant.resolve.location", st_block(st_do_while(st_break(), expr_not(expr_o_match_str())), st_s_use())); } - public void testFor() { + @Test + void testFor() { assertOK(st_block(st_for(expr_empty(), expr_not(expr_o_match_str()), expr_empty(), st_noop()), st_s_use())); assertFail("compiler.err.cant.resolve.location", st_block(st_for(expr_empty(), expr_not(expr_o_match_str()), expr_empty(), st_break()), st_s_use())); } diff --git a/test/langtools/tools/javac/patterns/scope/TEST.properties b/test/langtools/tools/javac/patterns/scope/TEST.properties index 2c56a1dacff..8bb6d765625 100644 --- a/test/langtools/tools/javac/patterns/scope/TEST.properties +++ b/test/langtools/tools/javac/patterns/scope/TEST.properties @@ -1,4 +1,4 @@ -TestNG.dirs = . +JUnit.dirs = . lib.dirs = /lib/combo diff --git a/test/langtools/tools/javac/records/LocalStaticDeclarations2.java b/test/langtools/tools/javac/records/LocalStaticDeclarations2.java index f13ae15c6d2..268186ef0be 100644 --- a/test/langtools/tools/javac/records/LocalStaticDeclarations2.java +++ b/test/langtools/tools/javac/records/LocalStaticDeclarations2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,17 +29,15 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.file * jdk.compiler/com.sun.tools.javac.util - * @run testng/othervm LocalStaticDeclarations2 + * @run junit/othervm LocalStaticDeclarations2 */ -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import tools.javac.combo.CompilationTestCase; -import static org.testng.Assert.assertEquals; - -@Test -public class LocalStaticDeclarations2 extends CompilationTestCase { - public void testLocalStatic() { +class LocalStaticDeclarations2 extends CompilationTestCase { + @Test + void testLocalStatic() { assertOK( """ class Test { diff --git a/test/langtools/tools/javac/records/RecordCompilationTests.java b/test/langtools/tools/javac/records/RecordCompilationTests.java index f1533625d9d..5f204598324 100644 --- a/test/langtools/tools/javac/records/RecordCompilationTests.java +++ b/test/langtools/tools/javac/records/RecordCompilationTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,8 @@ * java.base/jdk.internal.classfile.components * java.base/jdk.internal.classfile.impl * @build JavacTestingAbstractProcessor - * @run testng/othervm -DuseAP=false RecordCompilationTests - * @run testng/othervm -DuseAP=true RecordCompilationTests + * @run junit/othervm -DuseAP=false RecordCompilationTests + * @run junit/othervm -DuseAP=true RecordCompilationTests */ import java.io.File; @@ -81,11 +81,10 @@ import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.util.JCDiagnostic; -import org.testng.annotations.Test; import tools.javac.combo.CompilationTestCase; +import org.junit.jupiter.api.Test; import static java.lang.annotation.ElementType.*; -import static org.testng.Assert.assertEquals; /** Records are the first feature which sports automatic injection of (declarative and type) annotations : from a * given record component to one or more record members, if applicable. @@ -99,8 +98,7 @@ import static org.testng.Assert.assertEquals; * method: testAnnos() */ -@Test -public class RecordCompilationTests extends CompilationTestCase { +class RecordCompilationTests extends CompilationTestCase { private static String[] OPTIONS_WITH_AP = {"-processor", SimplestAP.class.getName()}; private static final List BAD_COMPONENT_NAMES = List.of( @@ -128,7 +126,8 @@ public class RecordCompilationTests extends CompilationTestCase { System.out.println(useAP ? "running all tests using an annotation processor" : "running all tests without annotation processor"); } - public void testMalformedDeclarations() { + @Test + void testMalformedDeclarations() { assertFail("compiler.err.premature.eof", "record R()"); assertFail("compiler.err.expected", "record R();"); assertFail("compiler.err.illegal.start.of.type", "record R(,) { }"); @@ -150,7 +149,8 @@ public class RecordCompilationTests extends CompilationTestCase { assertFail("compiler.err.instance.initializer.not.allowed.in.records", "record R(int i) { {} }"); } - public void testGoodDeclarations() { + @Test + void testGoodDeclarations() { assertOK("public record R() { }"); assertOK("record R() { }"); assertOK("record R() implements java.io.Serializable, Runnable { public void run() { } }"); @@ -180,7 +180,8 @@ public class RecordCompilationTests extends CompilationTestCase { """); } - public void testGoodMemberDeclarations() { + @Test + void testGoodMemberDeclarations() { String template = "public record R(int x) {\n" + " public R(int x) { this.x = x; }\n" + " public int x() { return x; }\n" @@ -191,12 +192,14 @@ public class RecordCompilationTests extends CompilationTestCase { assertOK(template); } - public void testBadComponentNames() { + @Test + void testBadComponentNames() { for (String s : BAD_COMPONENT_NAMES) assertFail("compiler.err.illegal.record.component.name", "record R(int #) { } ", s); } - public void testRestrictedIdentifiers() { + @Test + void testRestrictedIdentifiers() { for (String s : List.of("interface record { void m(); }", "@interface record { }", "class record { }", @@ -215,7 +218,8 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testValidMembers() { + @Test + void testValidMembers() { for (String s : List.of("record X(int j) { }", "interface I { }", "static { }", @@ -226,12 +230,14 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testCyclic() { + @Test + void testCyclic() { // Cyclic records are OK, but cyclic inline records would not be assertOK("record R(R r) { }"); } - public void testBadExtends() { + @Test + void testBadExtends() { assertFail("compiler.err.expected", "record R(int x) extends Object { }"); assertFail("compiler.err.expected", "record R(int x) {}\n" + "record R2(int x) extends R { }"); @@ -239,7 +245,8 @@ public class RecordCompilationTests extends CompilationTestCase { + "class C extends R { }"); } - public void testNoExtendRecord() { + @Test + void testNoExtendRecord() { assertFail("compiler.err.invalid.supertype.record", """ class R extends Record { @@ -251,7 +258,8 @@ public class RecordCompilationTests extends CompilationTestCase { ); } - public void testFieldDeclarations() { + @Test + void testFieldDeclarations() { // static fields are OK assertOK("public record R(int x) {\n" + " static int I = 1;\n" + @@ -279,7 +287,8 @@ public class RecordCompilationTests extends CompilationTestCase { "}"); } - public void testAccessorRedeclaration() { + @Test + void testAccessorRedeclaration() { assertOK("public record R(int x) {\n" + " public int x() { return x; };" + "}"); @@ -335,7 +344,8 @@ public class RecordCompilationTests extends CompilationTestCase { "}"); } - public void testConstructorRedeclaration() { + @Test + void testConstructorRedeclaration() { for (String goodCtor : List.of( "public R(int x) { this(x, 0); }", "public R(int x, int y) { this.x = x; this.y = y; }", @@ -426,7 +436,8 @@ public class RecordCompilationTests extends CompilationTestCase { "public R(int a) { super(); this.a = a; }"); } - public void testAnnotationCriteria() { + @Test + void testAnnotationCriteria() { String imports = "import java.lang.annotation.*;\n"; String template = "@Target({ # }) @interface A {}\n"; EnumMap annotations = new EnumMap<>(ElementType.class); @@ -435,7 +446,7 @@ public class RecordCompilationTests extends CompilationTestCase { EnumSet goodSet = EnumSet.of(RECORD_COMPONENT, FIELD, METHOD, PARAMETER, TYPE_USE); EnumSet badSet = EnumSet.of(CONSTRUCTOR, PACKAGE, TYPE, LOCAL_VARIABLE, ANNOTATION_TYPE, TYPE_PARAMETER, MODULE); - assertEquals(goodSet.size() + badSet.size(), values().length); + Assert.check(goodSet.size() + badSet.size() == values().length); String A_GOOD = template.replace("#", goodSet.stream().map(ElementType::name).map(s -> "ElementType." + s).collect(Collectors.joining(","))); String A_BAD = template.replace("#", @@ -459,7 +470,8 @@ public class RecordCompilationTests extends CompilationTestCase { // TODO: OK to redeclare with or without same annos } - public void testNestedRecords() { + @Test + void testNestedRecords() { String template = "class R { \n" + " # record RR(int a) { }\n" + "}"; @@ -477,7 +489,8 @@ public class RecordCompilationTests extends CompilationTestCase { assertOK("record R(int x) { # }", s); } - public void testDuplicatedMember() { + @Test + void testDuplicatedMember() { String template = " record R(int i) {\n" + " public int i() { return i; }\n" + @@ -486,7 +499,8 @@ public class RecordCompilationTests extends CompilationTestCase { assertFail("compiler.err.already.defined", template); } - public void testStaticLocals() { + @Test + void testStaticLocals() { // static locals can't capture local variables, instance fields or type variables for (String s : List.of( "record RR(int x) { public int x() { return y; }};", @@ -576,7 +590,8 @@ public class RecordCompilationTests extends CompilationTestCase { assertOK("class R { void m() { final record RR(int x) { }; } }"); } - public void testStaticDefinitionsInInnerClasses() { + @Test + void testStaticDefinitionsInInnerClasses() { // static defs in inner classes can't capture instance fields or type variables for (String s : List.of( """ @@ -1042,7 +1057,8 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testReturnInCanonical_Compact() { + @Test + void testReturnInCanonical_Compact() { assertFail("compiler.err.invalid.canonical.constructor.in.record", "record R(int x) { # }", "public R { return; }"); assertFail("compiler.err.invalid.canonical.constructor.in.record", "record R(int x) { # }", @@ -1051,7 +1067,8 @@ public class RecordCompilationTests extends CompilationTestCase { assertOK("record R(int x) { public R { Runnable r = () -> { return; };} }"); } - public void testArgumentsAreNotFinalInCompact() { + @Test + void testArgumentsAreNotFinalInCompact() { assertOK( """ record R(int x) { @@ -1062,14 +1079,16 @@ public class RecordCompilationTests extends CompilationTestCase { """); } - public void testNoNativeMethods() { + @Test + void testNoNativeMethods() { assertFail("compiler.err.mod.not.allowed.here", "record R(int x) { # }", "public native R {}"); assertFail("compiler.err.mod.not.allowed.here", "record R(int x) { # }", "public native void m();"); } - public void testRecordsInsideInner() { + @Test + void testRecordsInsideInner() { assertOK( """ class Outer { @@ -1110,7 +1129,8 @@ public class RecordCompilationTests extends CompilationTestCase { """); } - public void testAnnoInsideLocalOrAnonymous() { + @Test + void testAnnoInsideLocalOrAnonymous() { assertFail("compiler.err.annotation.decl.not.allowed.here", """ class Outer { @@ -1214,7 +1234,8 @@ public class RecordCompilationTests extends CompilationTestCase { """); } - public void testReceiverParameter() { + @Test + void testReceiverParameter() { assertFail("compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class", """ record R(int i) { @@ -1242,7 +1263,8 @@ public class RecordCompilationTests extends CompilationTestCase { """); } - public void testOnlyOneFieldRef() throws Exception { + @Test + void testOnlyOneFieldRef() throws Exception { for (String source : List.of( "record R(int recordComponent) {}", """ @@ -1292,7 +1314,8 @@ public class RecordCompilationTests extends CompilationTestCase { // check that fields are initialized in a canonical constructor in the same declaration order as the corresponding // record component - public void testCheckInitializationOrderInCompactConstructor() throws Exception { + @Test + void testCheckInitializationOrderInCompactConstructor() throws Exception { FieldInstruction putField1 = null; FieldInstruction putField2 = null; File dir = assertOK(true, "record R(int i, String s) { R {} }"); @@ -1331,7 +1354,8 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testAcceptRecordId() { + @Test + void testAcceptRecordId() { String[] previousOptions = getCompileOptions(); try { String[] testOptions = {}; @@ -1348,7 +1372,8 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testMultipleAnnosInRecord() throws Exception { + @Test + void testMultipleAnnosInRecord() throws Exception { String[] previousOptions = getCompileOptions(); try { @@ -1389,7 +1414,8 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testAnnos() throws Exception { + @Test + void testAnnos() throws Exception { String[] previousOptions = getCompileOptions(); try { String srcTemplate = @@ -1532,7 +1558,8 @@ public class RecordCompilationTests extends CompilationTestCase { // JDK-8292159: TYPE_USE annotations on generic type arguments // of record components discarded - public void testOnlyTypeAnnotationsOnComponentField() throws Exception { + @Test + void testOnlyTypeAnnotationsOnComponentField() throws Exception { String code = """ import java.lang.annotation.*; @@ -1755,7 +1782,8 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testMethodsInheritedFromRecordArePublicAndFinal() throws Exception { + @Test + void testMethodsInheritedFromRecordArePublicAndFinal() throws Exception { int numberOfFieldRefs = 0; File dir = assertOK(true, "record R() {}"); for (final File fileEntry : Objects.requireNonNull(dir.listFiles())) { @@ -1774,7 +1802,8 @@ public class RecordCompilationTests extends CompilationTestCase { private static final List ACCESSIBILITY = List.of( "public", "protected", "", "private"); - public void testCanonicalAccessibility() throws Exception { + @Test + void testCanonicalAccessibility() throws Exception { // accessibility of canonical can't be stronger than that of the record type for (String a1 : ACCESSIBILITY) { for (String a2 : ACCESSIBILITY) { @@ -1823,7 +1852,8 @@ public class RecordCompilationTests extends CompilationTestCase { }; } - public void testSameArity() { + @Test + void testSameArity() { for (String source : List.of( """ record R(int... args) { @@ -1897,7 +1927,8 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testSafeVararsAnno() { + @Test + void testSafeVararsAnno() { assertFail("compiler.err.annotation.type.not.applicable", """ @SafeVarargs @@ -1959,7 +1990,8 @@ public class RecordCompilationTests extends CompilationTestCase { ); } - public void testOverrideAtAccessor() { + @Test + void testOverrideAtAccessor() { assertOK( """ record R(int i) { @@ -1997,7 +2029,8 @@ public class RecordCompilationTests extends CompilationTestCase { ); } - public void testNoAssigmentInsideCompactRecord() { + @Test + void testNoAssigmentInsideCompactRecord() { assertFail("compiler.err.cant.assign.val.to.var", """ record R(int i) { @@ -2018,7 +2051,8 @@ public class RecordCompilationTests extends CompilationTestCase { ); } - public void testNoNPEStaticAnnotatedFields() { + @Test + void testNoNPEStaticAnnotatedFields() { assertOK( """ import java.lang.annotation.Native; @@ -2051,7 +2085,8 @@ public class RecordCompilationTests extends CompilationTestCase { ); } - public void testDoNotAllowCStyleArraySyntaxForRecComponents() { + @Test + void testDoNotAllowCStyleArraySyntaxForRecComponents() { assertFail("compiler.err.record.component.and.old.array.syntax", """ record R(int i[]) {} @@ -2069,7 +2104,8 @@ public class RecordCompilationTests extends CompilationTestCase { ); } - public void testNoWarningForSerializableRecords() { + @Test + void testNoWarningForSerializableRecords() { if (!useAP) { // don't execute this test when the default annotation processor is on as it will fail due to // spurious warnings @@ -2084,7 +2120,8 @@ public class RecordCompilationTests extends CompilationTestCase { } } - public void testAnnotationsOnVarargsRecComp() { + @Test + void testAnnotationsOnVarargsRecComp() { assertOK( """ import java.lang.annotation.*; @@ -2119,7 +2156,8 @@ public class RecordCompilationTests extends CompilationTestCase { ); } - public void testSaveVarargsAnno() { + @Test + void testSaveVarargsAnno() { // the compiler would generate an erronous accessor assertFail("compiler.err.varargs.invalid.trustme.anno", """ diff --git a/test/langtools/tools/javac/sealed/SealedCompilationTests.java b/test/langtools/tools/javac/sealed/SealedCompilationTests.java index 7a80afbe130..5ad70d102d6 100644 --- a/test/langtools/tools/javac/sealed/SealedCompilationTests.java +++ b/test/langtools/tools/javac/sealed/SealedCompilationTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,20 +33,14 @@ * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * @build toolbox.ToolBox toolbox.JavacTask - * @run testng/othervm -DuseAP=false SealedCompilationTests - * @run testng/othervm -DuseAP=true SealedCompilationTests + * @run junit/othervm -DuseAP=false SealedCompilationTests + * @run junit/othervm -DuseAP=true SealedCompilationTests */ -import java.lang.constant.ClassDesc; - -import java.io.File; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; - -import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -54,16 +48,12 @@ import java.util.stream.Collectors; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; - import javax.lang.model.element.TypeElement; import javax.lang.model.SourceVersion; import com.sun.tools.javac.util.Assert; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import tools.javac.combo.CompilationTestCase; import toolbox.ToolBox; @@ -71,8 +61,9 @@ import toolbox.JavacTask; import toolbox.Task; import toolbox.Task.OutputKind; -@Test -public class SealedCompilationTests extends CompilationTestCase { +import static org.junit.jupiter.api.Assertions.fail; + +class SealedCompilationTests extends CompilationTestCase { ToolBox tb = new ToolBox(); @@ -94,7 +85,7 @@ public class SealedCompilationTests extends CompilationTestCase { } - public SealedCompilationTests() { + SealedCompilationTests() { boolean useAP = System.getProperty("useAP") == null ? false : System.getProperty("useAP").equals("true"); setDefaultFilename("SealedTest.java"); setCompileOptions(useAP ? OPTIONS_WITH_AP : new String[]{}); @@ -116,7 +107,8 @@ public class SealedCompilationTests extends CompilationTestCase { """; private static final List SHELLS = List.of(NO_SHELL, NEST_SHELL, AUX_SHELL); - public void testSimpleExtension() { + @Test + void testSimpleExtension() { String CC1 = """ sealed class Sup # { } @@ -194,7 +186,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertFail("compiler.err.non.sealed.sealed.or.final.expected", shell, expandMarkers(b, p, m)); } - public void testSealedAndRecords() { + @Test + void testSealedAndRecords() { String P = """ sealed interface Sup # { } @@ -210,7 +203,8 @@ public class SealedCompilationTests extends CompilationTestCase { } // Test that a type that explicitly permits one type, can't be extended by another - public void testBadExtension() { + @Test + void testBadExtension() { String CC2 = """ sealed class Sup permits Sub1 { } @@ -241,7 +235,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertFail("compiler.err.cant.inherit.from.sealed", shell, b); } - public void testRestrictedKeyword() { + @Test + void testRestrictedKeyword() { for (String s : List.of( "class SealedTest { String sealed; }", "class SealedTest { int sealed = 0; int non = 0; int ns = non-sealed; }", @@ -289,7 +284,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testRejectPermitsInNonSealedClass() { + @Test + void testRejectPermitsInNonSealedClass() { assertFail("compiler.err.invalid.permits.clause", "class SealedTest {\n" + " class NotSealed permits Sub {}\n" + @@ -302,7 +298,8 @@ public class SealedCompilationTests extends CompilationTestCase { "}"); } - public void testTypeInPermitsIsSameClassOrSuper() { + @Test + void testTypeInPermitsIsSameClassOrSuper() { assertFail("compiler.err.invalid.permits.clause", """ sealed class Sealed permits Sealed {} @@ -326,7 +323,8 @@ public class SealedCompilationTests extends CompilationTestCase { /* It is a compile-time error if a class declaration has more than one of the class modifiers * sealed, non-sealed and final */ - public void testBadModifiers() { + @Test + void testBadModifiers() { assertFail("compiler.err.non.sealed.with.no.sealed.supertype", "class SealedTest { non-sealed class NoSealedSuper {} }"); assertFail("compiler.err.mod.not.allowed.here", @@ -344,7 +342,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertFail("compiler.err.illegal.combination.of.modifiers", s); } - public void testAnonymous_FunctionalExpr_and_Sealed() { + @Test + void testAnonymous_FunctionalExpr_and_Sealed() { for (String s : List.of( """ sealed interface I extends Runnable { @@ -403,7 +402,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertFail("compiler.err.local.classes.cant.extend.sealed", s); } - public void testNoLocalSealedClasses() { + @Test + void testNoLocalSealedClasses() { for (String s : List.of( """ sealed class C { @@ -422,7 +422,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertFail("compiler.err.sealed.or.non.sealed.local.classes.not.allowed", s); } - public void testLocalCantExtendSealed() { + @Test + void testLocalCantExtendSealed() { for (String s : List.of( """ sealed class C { @@ -454,7 +455,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertFail("compiler.err.local.classes.cant.extend.sealed", s); } - public void testSealedInterfaceAndAbstracClasses() { + @Test + void testSealedInterfaceAndAbstracClasses() { for (String s : List.of( """ sealed interface I {} @@ -496,7 +498,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertOK(s); } - public void testEnumsCantBeSealedOrNonSealed() { + @Test + void testEnumsCantBeSealedOrNonSealed() { for (String s : List.of( """ sealed interface I {} @@ -511,7 +514,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertFail("compiler.err.mod.not.allowed.here", s); } - public void testEnumsCanImplementSealedInterfaces() { + @Test + void testEnumsCanImplementSealedInterfaces() { for (String s : List.of( """ sealed interface I {} @@ -521,7 +525,8 @@ public class SealedCompilationTests extends CompilationTestCase { assertOK(s); } - public void testClassesCanExtendNonSealed() { + @Test + void testClassesCanExtendNonSealed() { for (String s : List.of( """ sealed class C {} @@ -534,7 +539,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testEmptyPermits() { + @Test + void testEmptyPermits() { for (String s : List.of( """ sealed class C permits {} @@ -544,7 +550,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testTypeVarInPermits() { + @Test + void testTypeVarInPermits() { for (String s : List.of( """ class Outer { @@ -555,7 +562,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testRepeatedTypeInPermits() { + @Test + void testRepeatedTypeInPermits() { for (String s : List.of( """ sealed class C permits Sub, Sub {} @@ -566,7 +574,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testSubtypeDoesntExtendSealed() { + @Test + void testSubtypeDoesntExtendSealed() { for (String s : List.of( """ sealed class C permits Sub {} @@ -590,7 +599,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testAPIForPrimitiveAndArrayClasses() { + @Test + void testAPIForPrimitiveAndArrayClasses() { for (Class c : new Class[]{byte.class, byte[].class, short.class, short[].class, int.class, int[].class, long.class, long[].class, float.class, float[].class, double.class, double[].class, char.class, char[].class, boolean.class, boolean[].class, void.class, String[].class}) { @@ -599,7 +609,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testPrinting() throws Exception { + @Test + void testPrinting() throws Exception { Path base = Paths.get("testPrinting"); Path src = base.resolve("src"); Path test = src.resolve("Test"); @@ -715,7 +726,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testNonSealedErroneousSuper() { + @Test + void testNonSealedErroneousSuper() { assertFail("compiler.err.cant.resolve", d -> { if (diags.keys().size() != 1) { @@ -727,7 +739,8 @@ public class SealedCompilationTests extends CompilationTestCase { """); } - public void testNonSealedErroneousSuperInterface() { + @Test + void testNonSealedErroneousSuperInterface() { assertFail("compiler.err.cant.resolve", d -> { if (diags.keys().size() != 1) { @@ -739,7 +752,8 @@ public class SealedCompilationTests extends CompilationTestCase { """); } - public void testIllFormedNonSealed() { + @Test + void testIllFormedNonSealed() { for (String s : List.of( """ sealed class C permits Sub {} @@ -767,7 +781,8 @@ public class SealedCompilationTests extends CompilationTestCase { "byte[]", "short[]", "int[]", "long[]", "float[]", "double[]", "char[]", "boolean[]" }; - public void testPermitsClause() { + @Test + void testPermitsClause() { for (String s : List.of( // can't include a parameterized type """ @@ -829,7 +844,8 @@ public class SealedCompilationTests extends CompilationTestCase { return tb.findJavaFiles(paths); } - public void testSealedNonSealedWithOtherModifiers() { + @Test + void testSealedNonSealedWithOtherModifiers() { String template1 = """ @interface A {} @@ -872,7 +888,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testSubClassBeforeSealedClassInSameCU() { + @Test + void testSubClassBeforeSealedClassInSameCU() { for (String s : List.of( """ final class Sub extends Sealed {} @@ -951,7 +968,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testDoNotAllowSealedAnnotation() { + @Test + void testDoNotAllowSealedAnnotation() { for (String s : List.of( """ sealed @interface A {} @@ -962,7 +980,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testNarrowConversion() { + @Test + void testNarrowConversion() { for (String s : List.of( """ interface I {} @@ -1264,7 +1283,8 @@ public class SealedCompilationTests extends CompilationTestCase { } } - public void testIntersectionWithSealedClasses() { + @Test + void testIntersectionWithSealedClasses() { assertOK( """ class A { }