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 Compatibility #18

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

calmilamsy
Copy link
Contributor

So, massive disclaimer: I did this in like 30 minutes flat, and I took a bunch of shortcuts (static initializer spam go brrrr), so be aware that the code probably isn't as clean as it should be.

A few major(ish) notes to take into account:

  • I had to remove the module-info class, due to java8 not supporting it.
  • I have had to do a god awful workaround for java8's terrible filesystem support. More details in code comments. (MmcPackCreator.class)
  • Cleaned up an incorrect java version specifier which broke j8 compat.
    • (It's tasks.compileJava.source/targetCompatiblity for all versions of java, also sets the IDE java compat for you as well, which is nice.)

I have tested the mmc pack and server and can confirm they're fully working.
I'm able to install the vanilla launcher one, but the crappy minecraft launcher doesn't work for me, so I can't test it.

If explanations are needed for anything I did, feel free to ask.

@calmilamsy
Copy link
Contributor Author

Oh, that might be a problem. Hmmm.

@calmilamsy
Copy link
Contributor Author

Okay, it works now, I think

@@ -220,16 +225,29 @@ public static void compileMmcZip(Path outPutDir, String gameVersion, LoaderType
Path zipFile = outPutDir.resolve("Ornithe-" + gameVersion + ".zip");
Files.deleteIfExists(zipFile);

try (FileSystem fs = FileSystems.newFileSystem(zipFile, Map.of("create", "true"))) {
// This is a god awful workaround, because paths can't be cleanly converted to URIs in j8, and for some reason, you can't pass parameters into newFileSystem with a path argument.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they can be converted, it's just

URI.create("jar:" + path.toUri())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work on windows, cause:

  • Windows uses \, which is an illegal char.
  • Windows also has the drive name, which itself is illegal to have in a URI.
  • I can't replace \ with / and then urlencode it, because it then encodes /, which then breaks the path.
  • I can't just manually escape space and colon (the two main offenders of breaking path), cause the path component is still somehow undefined.

I love J8 path API on windows :)

Copy link

@wagyourtail wagyourtail Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, path.toUri on windows looks like file:///C:/path/to/file on windows. and is a valid uri
and adding jar: on the front makes FileSystems recognize it as a zip properly on java 8 as the scheme becomes jar:file:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still ends up at the exact same "path component is undefined" error.

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.

2 participants