RFR: 8366678: Use JUnit in test/langtools/tools/javac [v2]
Chen Liang
liach at openjdk.org
Wed Sep 3 14:32:45 UTC 2025
On Wed, 3 Sep 2025 13:52:33 GMT, Christian Stein <cstein at openjdk.org> wrote:
>> Please review this change to use JUnit in tests of `test/langtools/tools/javac`.
>>
>> ### Assess Status Quo
>> A local `make test TEST=test/langtools/tools/javac` run before the conversion yields:
>>
>> Test results: passed: 3,938; excluded: 4; did not match keywords: 2; did not meet platform requirements: 2
>> Framework-based tests: 3043 = 2762 TestNG + 281 JUnit
>>
>>
>> ### Perform Automatic Conversion
>> - [junit-convert](
>> https://github.com/lahodaj/netbeans/tree/openjdk-testng-junit-fixes-and-hacks/java/java.openjdk.project/junit-convert)
>>
>> ### Perform Manual Adjustments
>>
>> Some of the following adjustments will be integrated into the `junit-convert` tool.
>>
>> #### Make argument source factory method `static`
>>
>> Method 'public java.lang.Object[][] org.openjdk.tests.javac.FDTest.caseGenerator()'
>> must be static: local factory methods must be static
>> unless the PER_CLASS @testinstance lifecycle mode is used;
>> external factory methods must always be static.
>>
>>
>> #### Make `@AfterAll`-annotated method `static`
>>
>> [ERROR] @afterall method 'public void org.openjdk.tests.vm.FDSeparateCompilationTest.cleanupCompilerCache()'
>> must be static unless the test class
>> is annotated with `@TestInstance(Lifecycle.PER_CLASS)`.
>>
>>
>> #### Remove `static` modifier from `@Test`-annotated methods
>> This configuration error should have been detected by JUnit Jupiter and reported via the Discovery
>> Issues API: https://docs.junit.org/current/user-guide/#running-tests-discovery-issues
>>
>> #### Rename test property to `JUnit.dirs`
>>
>> package org.junit.jupiter.api does not exist
>>
>>
>> #### Add custom test instance factory
>>
>> Class [FDTests] must declare a single constructor
>> Class [MethodReferenceTestKinds] must declare a single constructor
>>
>>
>> ### Results
>> Re-run tests via `make test TEST=test/langtools/tools/javac` after the conversion; yielding:
>>
>> Test results: passed: 3,939; excluded: 4; did not match keywords: 2; did not meet platform requirements: 2
>> Framework-based tests: 3043 = 0 TestNG + 3043 JUnit
>
> Christian Stein has updated the pull request incrementally with one additional commit since the last revision:
>
> Update copyright year
test/langtools/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java line 215:
> 213: }
> 214:
> 215: public Object[][] createModes() {
This one technically can be removed in favor of `@EnumSource` but since you are using a script and we can be more lenient.
test/langtools/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java line 185:
> 183: }
> 184:
> 185: class LocalTestInstanceFactory implements TestInstanceFactory {
Can't junit call the no-arg constructor naturally :thinking:
test/langtools/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java line 210:
> 208: }
> 209:
> 210: class LocalTestInstanceFactory implements TestInstanceFactory {
Since we have this again, can we just make a no-arg-constructor calling test instance factory and leave it in like /test/lib?
test/langtools/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java line 25:
> 23:
> 24: // this test has been disabled because of timeout issues.
> 25: // see JDK-8006746
Should we convert this to a full jtreg header and use problem lists or `@ignore` directive instead?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27046#discussion_r2319026920
PR Review Comment: https://git.openjdk.org/jdk/pull/27046#discussion_r2319141375
PR Review Comment: https://git.openjdk.org/jdk/pull/27046#discussion_r2319162108
PR Review Comment: https://git.openjdk.org/jdk/pull/27046#discussion_r2319166549
More information about the compiler-dev
mailing list