Skip to content

Conversation

@EvaristeGalois11
Copy link
Contributor

Hi, after updating to the new version 1.34.0 I'm receiving this error running the native binary:

error: no such method: com.sun.tools.javac.tree.JCTree.getEndPosition(EndPosTable)int/invokeVirtual
java.lang.LinkageError: no such method: com.sun.tools.javac.tree.JCTree.getEndPosition(EndPosTable)int/invokeVirtual
        at com.google.googlejavaformat.java.Trees.getEndPosMethodHandle(Trees.java:278)
        at com.google.googlejavaformat.java.Trees.<clinit>(Trees.java:251)
        at com.google.googlejavaformat.java.Formatter.format(Formatter.java:104)
        at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:214)
        at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:188)
        at com.google.googlejavaformat.java.FormatFileCallable.call(FormatFileCallable.java:75)
        at com.google.googlejavaformat.java.FormatFileCallable.call(FormatFileCallable.java:29)
        at java.base@25.0.2/java.util.concurrent.FutureTask.run(FutureTask.java:328)
        at java.base@25.0.2/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:545)
        at java.base@25.0.2/java.util.concurrent.FutureTask.run(FutureTask.java:328)
        at java.base@25.0.2/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
        at java.base@25.0.2/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
        at java.base@25.0.2/java.lang.Thread.runWith(Thread.java:1487)
        at java.base@25.0.2/java.lang.Thread.run(Thread.java:1474)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:832)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:808)
Caused by: java.lang.NoSuchMethodException: no such method: com.sun.tools.javac.tree.JCTree.getEndPosition(EndPosTable)int/invokeVirtual
        at java.base@25.0.2/java.lang.invoke.MemberName.makeAccessException(MemberName.java:910)
        at java.base@25.0.2/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:989)
        at java.base@25.0.2/java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:3591)
        at java.base@25.0.2/java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:2610)
        at com.google.googlejavaformat.java.Trees.getEndPosMethodHandle(Trees.java:269)
        ... 15 more
Caused by: java.lang.NoSuchMethodError: com.sun.tools.javac.tree.JCTree.getEndPosition(com.sun.tools.javac.tree.EndPosTable)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.methodhandles.Util_java_lang_invoke_MethodHandleNatives.resolve(Target_java_lang_invoke_MethodHandleNatives.java:352)
        at java.base@25.0.2/java.lang.invoke.MethodHandleNatives.resolve(MethodHandleNatives.java:208)
        at java.base@25.0.2/java.lang.invoke.MemberName$Factory.resolve(MemberName.java:120)
        at java.base@25.0.2/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:986)
        ... 18 more

It's caused by 4a15b1b that introduced new reflection invocations that the native build process isn't able to pick up.
Following this guide I generated an updated config file to fix the problem. The config file name changed in Graal 23, but it's only used during build time so it shouldn't matter that much.

With this fix everything works fine (at least for my case 😁).

@google-cla
Copy link

google-cla bot commented Feb 3, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@natros
Copy link

natros commented Feb 4, 2026

In my case, with java 25.0.1 (macOS x86_64) in addition to that change, I had to add --initialize-at-build-time=com.google.googlejavaformat.java.Trees

@cushon
Copy link
Collaborator

cushon commented Feb 4, 2026

In my case, with java 25.0.1 (macOS x86_64) in addition to that change, I had to add --initialize-at-build-time=com.google.googlejavaformat.java.Trees

Hmm, it works for me with 25.0.2+10 on mac arm64 with just this change. There were also some recent changes in f0a9748 to the use of reflection here that may affect graal.

@natros could you trying 25.0.2 and also the google-java-format changes from f0a9748, and see if --initialize-at-build-time=com.google.googlejavaformat.java.Trees is still necessary for you?

@natros
Copy link

natros commented Feb 4, 2026

I tried again, and this time it worked. Don't know what I did wrong the first time, but now everything is working fine. Maybe it's my custom build using --pgo-instrument to compile an optimized version.

The changes from f0a9748 also work without the --initialize-at-build-time=com.google.googlejavaformat.java.Trees

I cannot test with 25.0.2 because graalvm only supports macOS M1/AArch64 or newer, and I'm on intel :(

It seems that --initialize-at-build-time=com.google.googlejavaformat.java.Trees is not needed after all.

@cushon
Copy link
Collaborator

cushon commented Feb 4, 2026

Thanks for checking! I'll make another release with the fixes in this PR. If you see other issues or --initialize-at-build-time=com.google.googlejavaformat.java.Trees does end up being necessary let me know and we can tweak the configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants