Integrated: 7016187: `javac -h` could generate conflict .h for inner class and class name with '_'

Archie L. Cobbs duke at openjdk.org
Sat Mar 18 17:35:28 UTC 2023


On Thu, 16 Feb 2023 17:49:00 GMT, Archie L. Cobbs <duke at openjdk.org> wrote:

> Consider these two classes:
> 
> public class Foo_Bar {
>     public static native void method();
> }
> 
> 
> public class Foo {
>     public static class Bar {
>         public static native void method();
>     }
> }
> 
> If you run `javac -h` to generate native header files, classes `Foo_Bar` and `Foo$Bar` will want to generate the same native header file `Foo_Bar.h`.
> 
> Currently, javac does not detect this situation, so in effect you get a "last writer wins" situation.
> 
> This patch causes compilation to fail instead in this case with an error like this:
> 
> Foo.java:2: error: error while writing Bar: native header file collision between Foo_Bar and Foo$Bar (both generate Foo_Bar.h)
>     public static class Bar {
>                   ^
> 1 error

This pull request has now been integrated.

Changeset: e339e183
Author:    Archie L. Cobbs <archie.cobbs at gmail.com>
Committer: Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e339e183c1d60e494d266bac0c2ec05c1ec30cc6
Stats:     42 lines in 2 files changed: 38 ins; 0 del; 4 mod

7016187: `javac -h` could generate conflict .h for inner class and class name with '_'

Reviewed-by: vromero

-------------

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


More information about the compiler-dev mailing list