[foreign-jextract] RFR: 8262117: jextract crashes with javac compilation error "class u is already defined"

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Feb 23 10:40:07 UTC 2021

On Tue, 23 Feb 2021 04:42:31 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

> enclosing names are checked for clash now

Looks good, added a minor comment

src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/JavaSourceBuilder.java line 215:

> 213:     // is the name enclosed enclosed by a class of the same name?
> 214:     boolean isEnclosedBySameName(String name) {
> 215:         return false;

Should we add className().equals(name) in here - just to be on the safe side>

I guess it's never possible for a nested class to have the same name of a "toplevel" class (e.g. generated by HeaderFileBuilder), because we explicitly mangle the names (e.g. `toplevel$nested`). But I think adding the name check at the toplevel is the correct thing to do code-wise.

Then in the subclass you can do `super.isEnclosedBySameName(name) || enclosing.isEnclosedBySameName(name))`


Marked as reviewed by mcimadamore (Committer).

PR: https://git.openjdk.java.net/panama-foreign/pull/458

More information about the panama-dev mailing list