RFR: 7016187: `javac -h` could generate conflict .h for inner class and class name with '_'
Vicente Romero
vromero at openjdk.org
Fri Feb 17 23:17:25 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
lgtm
-------------
Marked as reviewed by vromero (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12602
More information about the compiler-dev
mailing list