Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 8 Support #364

Open
extremall-dev opened this issue Dec 28, 2024 · 3 comments
Open

Java 8 Support #364

extremall-dev opened this issue Dec 28, 2024 · 3 comments
Labels

Comments

@extremall-dev
Copy link

[proguard] java.lang.RuntimeException: -target can only be used with class file versions <= 55 (Java 11).
[proguard] The input classes contain version 60 class files which cannot be backported to target version (52).

@0dinD
Copy link
Collaborator

0dinD commented Dec 30, 2024

What version of ProGuard are you using? If you are using an up-to-date version of ProGuard then it should support the latest versions of Java, which is the solution I'd recommend.

Even though most of AnvilGUI is compiled with and supports Java 8, some class files in AnvilGUI are compiled with (up to) Java 21, because modern Minecraft versions require it (there is nothing that can be done about that, it's Mojang's decision). If you absolutely need a version of AnvilGUI that only contains Java 8 classes, you will need to downgrade to AnvilGUI version 1.4.1-SNAPSHOT, which only supports Minecraft 1.7.10 - 1.16.5. However, that version may contain unfixed bugs and features which were added in later versions of AnvilGUI, so I would instead recommend you to upgrade ProGuard and AnvilGUI to the latest version. Note that this does not prevent you from compiling your plugin with and supporting Java 8 (as long as you don't use Minecraft 1.17+).

@0dinD 0dinD added the question label Dec 30, 2024
@extremall-dev
Copy link
Author

Hi, I am using latest version of ProGuard. Here is the issue. May you can set here Java 8 and set Java 21 on project JDA and may will work I am doing this without issues.

@0dinD
Copy link
Collaborator

0dinD commented Jan 1, 2025

Oh, I just assumed you were using an outdated ProGuard version because the latest version says that it should support Java 21. But the problem here is that you are using ProGuard's -target option, which is deprecated and will not support JDK > 11:

Deprecated: this option is only applicable for Java class file versions <= 11.

In your case there should be absolutely no reason to use the -target option in ProGuard for AnvilGUI, because all the AnvilGUI classes that can run on Java 8 are compiled to Java 8's classfile version. Only the AnvilGUI classes for modern Minecraft versions (which require Java 21) are compiled with Java 21. If you don't use modern Minecraft versions, then you don't use those classes, which means that you don't need to downgrade those classfiles.


And yes, it's technically possible to tell javac to compile all classes in AnvilGUI to Java 8 using the source/target/release options (note: the -target option in javac is completely different from the -target option in ProGuard), but that only works in some cases. The bigger problem is also that in Java 20, support for compiling to Java 7 was removed, and compiling to Java 8 was deprecated for removal (see JEP 182 and JDK-8173605) so it will stop working whenever Oracle decides to remove it and Mojang upgrades to that Java version.

This means that going forward, the only way to support modern Minecraft versions will be to compile AnvilGUI using a mix of Java 8 and modern Java versions, as we are currently doing. Again, this does not prevent AnvilGUI from running on Java 8, it just means that if you are processing the AnvilGUI class files using a tool such as ProGuard, it will need to support modern Java versions. ProGuard should support modern Java versions, apart from some deprecated options like -target, which you should try to stop using.


If you for some reason need something like ProGuard's -target option that works on modern Java versions, it's not something we can really help with here, but I'd recommend you to have a look at JvmDowngrader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants