Skip to content

Commit 47ca72f

Browse files
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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
[
2+
{
3+
"name":"com.ibm.cldk.CodeAnalyzer",
4+
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
5+
},
26
{
37
"name":"java.lang.Boolean",
48
"methods":[{"name":"getBoolean","parameterTypes":["java.lang.String"] }]
9+
},
10+
{
11+
"name":"java.lang.String",
12+
"methods":[{"name":"lastIndexOf","parameterTypes":["int"] }, {"name":"substring","parameterTypes":["int"] }]
13+
},
14+
{
15+
"name":"java.lang.System",
16+
"methods":[{"name":"getProperty","parameterTypes":["java.lang.String"] }, {"name":"setProperty","parameterTypes":["java.lang.String","java.lang.String"] }]
517
}
618
]

0 commit comments

Comments
 (0)