RFR: 8163229: test test/tools/javac/CaptureInSubtype.java has a main method that is never executed Export [v3]

Vicente Romero vromero at openjdk.org
Thu Jan 5 18:17:53 UTC 2023

On Mon, 19 Dec 2022 15:44:08 GMT, Archie L. Cobbs <duke at openjdk.org> wrote:

>> This PR deals with some housekeeping relating to compiler unit tests.
>> JDK-8163229 points out that there are several tests that have a `public static void main(String[])` method, but because the test expects to fail during compilation, the test is never actually run, and so these `main` methods are just clutter that can be removed.
>> However, there are also some tests where the test is never run, but the `main()` method generates one or more of the expected compilation errors. Obviously we need to keep those, but they don't need to be declared as `public static void main(String[])` which is misleading. So instead we rename these methods to `meth()`, and also we remove the `String[]` parameter when it's not needed by the test.
> Archie L. Cobbs has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
>  - Merge branch 'master' into JDK-8163229
>  - Merge branch 'master' into JDK-8163229
>  - Rename or remove "main()" methods in tests that never actually run.

test/langtools/tools/javac/4980495/static/Test.java line 14:

> 12: public class Test {
> 13: 
> 14:     public static void meth() {

not sure about this case, but if a method doesn't need to be `static` we should remove the modifier, consider removing `public` too if not needed


PR: https://git.openjdk.org/jdk/pull/10992

More information about the compiler-dev mailing list