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

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Feb 19 14:10: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).

A possible explanation as to why we're seeing this now is that we now generate enum constant comments much earlier. Perhaps this was never an issue before as this enum was (likely) skipped.

Also, our `makeTreeInternal` checks that a position is set:


if (pos == Position.NO_POSITION) return null; // intrinsic, skip


This code is also new, and could lead to this issue.

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

PR Comment: https://git.openjdk.org/jextract/pull/219#issuecomment-1952524391
PR Comment: https://git.openjdk.org/jextract/pull/219#issuecomment-1952527007


More information about the jextract-dev mailing list