RFR: 7903666: Jextract should report issues with missing dependencies [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Feb 16 17:00:21 UTC 2024


> When custom include filters are specified on the command line, it is possible for jextract to generate non-sensical code (now even more so than in the past). Possible issues:
> 
> * a function descriptor refers to a non-existent struct/union
> * a struct/union typedef refers to a non-existent struct/union
> * a struct/union field refers to a non-existent struct/union
> * a global variable refers to a non-existent struct/union
> 
> In such cases, jextract should terminate (and report the problem to the user), rather than generating buggy code.
> 
> The fix is relatively simple, and amounts at checking whether a declaration depends on a skipped struct in `IncludeHelper`. That said, when we detect an issue, we should stop jextract. So we need some way to notify jextract that some error occurred, and stop.
> 
> I initially had a hacky approach with some mutable field in `IncludeFilter`, but I've decided to implement a minimal Logger class, and make _all_ error/warnings go through the Logger. This way we can easily check how many errors occurred, and stop jextract if needed. Of course, this led to several changes, as I realized that we were being inconsistent on our usage of the property file. I now made sure that all messages use some key in the property file (e.g. no lone strings). This might be important if jextract message will ever be translated to languages other than English.

Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:

  Address review comments
  Update README to talk about missing dependencies

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

Changes:
  - all: https://git.openjdk.org/jextract/pull/214/files
  - new: https://git.openjdk.org/jextract/pull/214/files/d6dcfae3..b6a1c9e6

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jextract&pr=214&range=01
 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=214&range=00-01

  Stats: 45 lines in 4 files changed: 29 ins; 3 del; 13 mod
  Patch: https://git.openjdk.org/jextract/pull/214.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/214/head:pull/214

PR: https://git.openjdk.org/jextract/pull/214


More information about the jextract-dev mailing list