Skip to content

Commit 60f39af

Browse files
committed
Register the javac end-position API for the native image
Since palantir#1786, Trees reaches JCTree.getEndPosition(EndPosTable) and JCCompilationUnit.endPositions through method handles, so that the same code runs on JDK 27, where neither exists. The image is built with --exact-reachability-metadata, so without these entries every file failed, even `class A{int x;}`: "Cannot reflectively access method 'com.sun.tools.javac.tree.JCTree#getEndPosition(com.sun.tools.javac.tree.EndPosTable)'".
1 parent b2e270b commit 60f39af

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎open-java-format-native/src/main/resources/META-INF/native-image/reachability-metadata.json‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,28 @@
160160
}
161161
]
162162
},
163+
{
164+
"type": "com.sun.tools.javac.tree.EndPosTable"
165+
},
166+
{
167+
"type": "com.sun.tools.javac.tree.JCTree",
168+
"methods": [
169+
{
170+
"name": "getEndPosition",
171+
"parameterTypes": [
172+
"com.sun.tools.javac.tree.EndPosTable"
173+
]
174+
}
175+
]
176+
},
177+
{
178+
"type": "com.sun.tools.javac.tree.JCTree$JCCompilationUnit",
179+
"fields": [
180+
{
181+
"name": "endPositions"
182+
}
183+
]
184+
},
163185
{
164186
"type": "java.io.Serializable"
165187
},

0 commit comments

Comments
 (0)