antlr / antlr4-tools

Tools to run antlr4 w/o needing to install java or antlr4!
MIT License
82 stars 19 forks source link

Windows. ANTLR tools compiled to JRE 11 (class file 55), but installed JRE only recognizes up to JRE 8 (class file 52). #14

Open rturrado opened 1 year ago

rturrado commented 1 year ago

Hi,

I'm doing this both in Linux and Windows, and it's working fine in Linux but not in Windows:

The error is:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/antlr/v4/Tool has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Shouldn't ANTLR tools be installing an adequate version of JRE?

Is there any easy way to fix this?

Many thanks!

rturrado commented 1 year ago

BTW, it works OK for gcc-clang/Linux/x64, clang/MacOS/x64, and msvc/Windows/x64 if I go back to using antlr4-4.9.3. See here.

rturrado commented 1 year ago

Hi Eric,

Thanks for your comment. Would you mind writing it on GitHub? This could help others.

Could you please elaborate more on your answer? E.g. how do you check your JDK version, what version of JDK do you need, and so on? I see we're talking here about JRE 11, and the last JDK is 20.

My point though was: could the installation of antlr-tools do this (update to the last version of JDK/JRE) automatically?

Best regards, Roberto.

On Tue, Aug 15, 2023 at 8:52 AM ericvergnaud @.***> wrote:

An easy way is to upgrade your jdk.

— Reply to this email directly, view it on GitHub https://github.com/antlr/antlr4-tools/issues/14#issuecomment-1678499534, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQHR5YIP2HBETEMNI3YEJQDXVMMELANCNFSM6AAAAAA3PNGDVY . You are receiving this because you authored the thread.Message ID: @.***>

ericvergnaud commented 1 year ago

I removed it from GH because I thought this was about antlr tool. I’ll let people in charge of antlr4-tools answer your questionEnvoyé de mon iPhoneLe 15 août 2023 à 12:18, Roberto Turrado Camblor @.***> a écrit : Hi Eric,

Thanks for your comment. Would you mind writing it on GitHub? This could

help others.

Could you please elaborate more on your answer? E.g. how do you check your

JDK version, what version of JDK do you need, and so on? I see we're

talking here about JRE 11, and the last JDK is 20.

My point though was: could the installation of antlr-tools do this (update

to the last version of JDK/JRE) automatically?

Best regards,

Roberto.

On Tue, Aug 15, 2023 at 8:52 AM ericvergnaud @.***>

wrote:

An easy way is to upgrade your jdk.

Reply to this email directly, view it on GitHub

https://github.com/antlr/antlr4-tools/issues/14#issuecomment-1678499534,

or unsubscribe

https://github.com/notifications/unsubscribe-auth/AQHR5YIP2HBETEMNI3YEJQDXVMMELANCNFSM6AAAAAA3PNGDVY

.

You are receiving this because you authored the thread.Message ID:

@.***>

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

mawildoer commented 10 months ago

I've got a very similar issue for OSx (M3/aarch6):

(.venv) atopile % pip install antlr4-tools  
Collecting antlr4-tools
  Downloading antlr4_tools-0.2.1-py3-none-any.whl (4.3 kB)
Collecting install-jdk
  Downloading install_jdk-1.1.0-py3-none-any.whl (15 kB)
Installing collected packages: install-jdk, antlr4-tools
Successfully installed antlr4-tools-0.2.1 install-jdk-1.1.0

[notice] A new release of pip is available: 23.0.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
(.venv) atopile % antlr4
Downloading antlr4-4.13.1-complete.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/antlr/v4/Tool has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:359)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:635)

It's also not the first time I've experienced this. I'm not sure I'm familiar enough in Java to work this out. I've tried installing other versions of and upgrading Java as well. Following along here!

This was the issue that originally spurred me on to create this dockerised version of the tool: https://github.com/antlr/antlr4/pull/4244

I see now it was actually approved - I missed that all this time ago! I'll have to polish it off as well

parrt commented 10 months ago

It's weird. It's like it's installing an old version of java.

mawildoer commented 9 months ago

I have a hunch this has something to do with Rosetta on OSx. I tried disabling it, installing native (aarch64) Java (via native brew) with success.

I'm not sure it's worth getting to the bottom of, but hopefully the breadcrumbs at least help the next person to hit this!