RFR: 7016187: `javac -h` could generate conflict .h for inner class and class name with '_'
Archie L. Cobbs
duke at openjdk.org
Thu Feb 23 22:22:04 UTC 2023
On Fri, 17 Feb 2023 23:31:55 GMT, Jonathan Gibbons <jjg 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
>
> The JBS issue lists _two_ problem cases, of which this PR addresses one.
>
> You should either fix both, or file a subsidiary issue for the part that is not covered here (if that is still an issue):
>
>> It also does not handle the fields properly for O_I.class and O$I.class if both have same named fields. The generated field constant names are the same in the jni header file.
@jonathan-gibbons - Are you OK with this patch as it currently stands?
Thanks.
-------------
PR: https://git.openjdk.org/jdk/pull/12602
More information about the compiler-dev
mailing list