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

Fix compiling and running with Java 9 #188

Closed
wants to merge 1 commit into from

Conversation

games647
Copy link

@games647 games647 commented Feb 2, 2018

Although this project might not be ready to decompile Java 9 jar files, it should be able to run and compile with Java 9 JVM. This fixes a few issues I encountered like the following:

  1. The xml.Base64 class was replaced with java.util.Base64 (only available from java 8+ -> use apache codecs implementation)
  2. Resources.class.getClass() is redundant and even returned a NPE everytime
  3. Basic generics for TreeNode were added and therefore cannot make an unchecked cast

@Konloch
Copy link
Owner

Konloch commented Mar 22, 2018

Cheers, I've started implementing the changes. I'll try to get Java 9.x support working by this weekend.

@sh1ftchg
Copy link

sh1ftchg commented Apr 8, 2018

Should we bother with java 9? Java 10 is out! Plus there's not really any changes needed, everything can still be compiled for Java 8; really just need to add "module-info.java" into packages and the appropriate "exports/requires". Beyond that, not much to change to run on java 9/10.

@games647
Copy link
Author

games647 commented Apr 8, 2018

@sh1ftchg

Should we bother with java 9? Java 10 is out!

It's about Java 9+ not Java 9 alone. There were some breaking changes in Java 9.

everything can still be compiled for Java 8

Not with JDK9+ (installed) and you cannot run it with Java 9+ runtime, because of missing classes.

really just need to add "module-info.java" into packages and the appropriate "exports/requires"

This PR still compiles against Java 7 (EDIT: meant Java 7 not 8).

@sh1ftchg
Copy link

sh1ftchg commented Apr 8, 2018

Not sure what classes are missing, the sun package was refactored into java/jdk packages... Nothing I can find is actually missing? Just like I told the Minecraft modders, they're mostly not gone (the only ones removed were the ones marked for removal, but you would get a warning when compiling with java 8) but moved into a standardized package.

AFAIK the things that moved shouldn't have been used in the first place, internal java/jdk classes can be used but it's not standard. Correct me if I'm wrong but you're supposed to reference them through their service provider interfaces (SPI's), not by the classes themselves. If you do that the code should work fine on java 8 or newer.

@games647
Copy link
Author

games647 commented Apr 8, 2018

Not sure what classes are missing, the sun package was refactored into java/jdk packages... Nothing I can find is actually missing?

If you do that the code should work fine on java 8 or newer.

Sadly, not only **sun.* packages were removed.

javax.xml.bind.DatatypeConverter#parseBase64Binary(String)

This class is now only available using an additional startup parameter:
--add-modules java.xml.bind or something similar.

Try to run the project with a Java 9 runtime and you'll get NoClassDefError. See this for example. We can now use the Base64 class in Java 8 or the class in commons-codec like mentioned in the first post.

AFAIK this class or package wasn't deprecated, but it was still removed from the standard accessible library.

@Konloch Konloch closed this Apr 8, 2018
@Konloch
Copy link
Owner

Konloch commented Apr 8, 2018

Thanks for the suggestions guys but we need to explicitly support JRE/JDK 9 as @games647 pointed out

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.

None yet

3 participants