Commit 47ca72f
committed
fix(native): register JavaParser AST reflection metadata so the native image can analyze (#153)
The GraalVM native image crashed on every project with
`java.lang.NoSuchFieldError: variables` -- JavaParser's metamodel
(PropertyMetaModel.getValue) reflects over AST node fields, which aren't
registered under native-image's closed world, so any parse died before reaching
any emit target. Only `--emit schema` (no analysis) worked.
Fix: register all 266 `com.github.javaparser.ast.**` classes with
allDeclaredFields/Methods/Constructors (per-fixture tracing-agent capture did not
generalize -- unseen apps hit fresh NoSuchFieldErrors like `pairs`/`elements`),
plus the tracing-agent-captured reflect/jni/resource entries for the parse path.
Verified: native `--emit json -a 1` and `--emit neo4j` now succeed on every test
fixture, including the large real apps (daytrader8, plantsbywebsphere) that
previously crashed.
Note: a residual, native-inherent limitation remains -- symbol resolution via
JavaParser's ReflectionTypeSolver is ~20% degraded on JDK/dependency types not
registered for reflection (+ version reports "unknown"). The cldk SDK sidesteps
this by running the jar on a bundled HotSpot JVM (full fidelity), so the native
gap affects only direct use of the standalone native binary.1 parent 1121fb2 commit 47ca72f
3 files changed
Lines changed: 3298 additions & 238 deletions
File tree
- src/main/resources/META-INF/native-image-config
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
5 | 17 | | |
6 | 18 | | |
0 commit comments