RFR: 7903673: Jextract throws NPE when generating enum constant javadoc

Jorn Vernee jvernee at openjdk.org
Mon Feb 19 14:29:08 UTC 2024


On Mon, 19 Feb 2024 13:58:42 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR fixes `TreeMaker` so that it doesn't try to generate javadoc for `null` enum constants.
> 
> Unfortunately I was not able to reproduce on Linux. The problem seems to appear on MacOS when extracting this enum:
> 
> 
> enum __CFByteOrder {
>     CFByteOrderUnknown,
>     CFByteOrderLittleEndian,
>     CFByteOrderBigEndian
> }; 
> 
> 
> But there doesn't seem to be anything peculiar with this (and this does work when extracted in isolation).
> It might indicate a deeper issue in libclang. For now, I made the code more robust, so that it handles possible null enum constants (these are left out from the IR).

Marked as reviewed by jvernee (Committer).

src/main/java/org/openjdk/jextract/impl/TreeMaker.java line 373:

> 371:             c.forEach(child -> {
> 372:                 Declaration enumConstantDecl = createTree(child);
> 373:                 if (enumConstantDecl != null) {

Could you add a comment on this `if` that points back at the bug? (just in case we ever wonder why there is a `null` check here in the future)

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

PR Review: https://git.openjdk.org/jextract/pull/219#pullrequestreview-1888539337
PR Review Comment: https://git.openjdk.org/jextract/pull/219#discussion_r1494626348


More information about the jextract-dev mailing list