RFR: 7016187: `javac -h` could generate conflict .h for inner class and class name with '_'
Archie L. Cobbs
duke at openjdk.org
Thu Feb 16 17:56:16 UTC 2023
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
-------------
Commit messages:
- Fail "-h" compilation if two classes generate the same native header file.
Changes: https://git.openjdk.org/jdk/pull/12602/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12602&range=00
Issue: https://bugs.openjdk.org/browse/JDK-7016187
Stats: 42 lines in 2 files changed: 38 ins; 0 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/12602.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12602/head:pull/12602
PR: https://git.openjdk.org/jdk/pull/12602
More information about the compiler-dev
mailing list