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

[1.19] IllegalAccessError when LANGPROVIDER tries to access a module from its JarJar dependencies while loading mod #8878

Open
thedarkcolour opened this issue Jul 16, 2022 · 24 comments · May be fixed by #9939
Assignees
Labels
1.19 Bug This request reports or fixes a new or existing bug. Confirmed This request has been verified to be factually correct by at least one member of the team.

Comments

@thedarkcolour
Copy link
Contributor

Minecraft Version: 1.19

Forge Version: 41.0.98

Logs: https://gist.github.com/thedarkcolour/3c08730917d49a8d1bf79334770b5c0a

Steps to Reproduce:

  1. Run Forge with just these two mods
  • KotlinForForge can be compiled from here. The correct jar is kotlinforforge-3.7.0-obf.jar, created in kfflang\build\libs
  • Examplemod can be compiled from here on the 1.19.x branch.
  1. Crash

Description of issue:
This issue happens when running with the vanilla Minecraft launcher. Attempting to load a mod with KotlinForForge (Kotlin language loader) causes an IllegalAccessError, since the kotlinforforge module cannot access kotlin.stdlib module, which is included via JarJar. The language provider classes are written in Kotlin, and they do not get loaded unless a mod whose modLoader is set to "kotlinforforge" in the mods.toml.
When KotlinForForge used the shadow plugin to shade the Kotlin libraries, this issue did not happen. It seems like JarJar is not opening up the module-info of the JarJar libraries?
image

@thedarkcolour thedarkcolour added the Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. label Jul 16, 2022
@sciwhiz12 sciwhiz12 added Bug This request reports or fixes a new or existing bug. 1.19 labels Jul 16, 2022
@cpw
Copy link
Contributor

cpw commented Jul 16, 2022

This is not the way to package kotlin. I suspect it would work fine if the kotlin for forge langprovider was shadowed with kotlin. Otherwise you'd need to get a version of kotlin that is properly jpms aware. Given they're still shipping jdk7! compatible libs that's likely a few years away yet.

@thedarkcolour
Copy link
Contributor Author

thedarkcolour commented Jul 16, 2022

The example mod can access the Kotlin libraries when they are shadowed by the langprovider, but when the langprovider is shadowed alongside Kotlin, Forge doesn't detect the langprovider when it's needed by the example mod.
The log
The langprovider, in a blank JarJar with all the Kotlin libraries:
image

@marchermans
Copy link
Contributor

I am checking this now
I think this might be related to us just injecting all deps as game libraries if they are not FML aware.

@tmvkrpxl0
Copy link
Contributor

tmvkrpxl0 commented Jul 18, 2022

After further testing I have succeed in making minecraft to be aware of kotlin language provider
image
kff_testing_kit.zip

But it's still unable to access kotlin libs
https://www.toptal.com/developers/hastebin/yusixinuwi.yaml

kotlinforforge-3.7.0-obf.jar inside jarjar directory is language provider. It may be confusing that both archive file name and language provider's names are same, but language provider has module name kfflang, and log also shows it as kfflang it's only just file name that is same

@marchermans
Copy link
Contributor

I tracked the issue down to the kotlin libs and wing unaware of fmls systems and as such being injected into the game layer and not the plugin/service layers

@marchermans marchermans added Confirmed This request has been verified to be factually correct by at least one member of the team. and removed Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. labels Jul 25, 2022
@marchermans
Copy link
Contributor

marchermans commented Jul 25, 2022

Note due to changes needed in signatures of objects this will likely target 1.20.

In short:

needs to become a parameterized version either pulled up into createMod() or some other factor.

@thedarkcolour
Copy link
Contributor Author

Do you know of a workaround to use in the meantime?

@marchermans
Copy link
Contributor

No this was hardcoded into the mod provider at the time.

@cpw
Copy link
Contributor

cpw commented Jul 26, 2022

Question: WHY can't you just fatjar kotlin with the kotlin4forge? That was my original question, and it still hasn't been answered.

@tmvkrpxl0
Copy link
Contributor

tmvkrpxl0 commented Jul 26, 2022

After further testing I have succeed in making minecraft to be aware of kotlin language provider image kff_testing_kit.zip

But it's still unable to access kotlin libs https://www.toptal.com/developers/hastebin/yusixinuwi.yaml

kotlinforforge-3.7.0-obf.jar inside jarjar directory is language provider. It may be confusing that both archive file name and language provider's names are same, but language provider has module name kfflang, and log also shows it as kfflang it's only just file name that is same

Wasn't this one what you meant? Putting kotlin std libs along side with language provider

@marchermans
Copy link
Contributor

After further testing I have succeed in making minecraft to be aware of kotlin language provider image kff_testing_kit.zip
But it's still unable to access kotlin libs https://www.toptal.com/developers/hastebin/yusixinuwi.yaml
kotlinforforge-3.7.0-obf.jar inside jarjar directory is language provider. It may be confusing that both archive file name and language provider's names are same, but language provider has module name kfflang, and log also shows it as kfflang it's only just file name that is same

Wasn't this one what you meant? Putting kotlin std libs along side with language provider

Basically he is saying that LanguageProviders should be a fatjar, with the libraries shaded into it without relocation.

@tmvkrpxl0
Copy link
Contributor

tmvkrpxl0 commented Jul 26, 2022

Yes, shadowing does work.
Isn't kotlin jpms aware from 1.7.0? It contains module-info.java by default
And jdk7 stdlib is for "stdlib for features added in jdk 7", not jdk7 compatibility module, and it also has module-info.java
So I thought these were jpms aware

@Rubydesic
Copy link

Question: WHY can't you just fatjar kotlin with the kotlin4forge? That was my original question, and it still hasn't been answered.

This is what Kotlin For Forge does, and it breaks every single other mod that wants to include kotlin without a hard dependency on Kotlin For Forge. Given that language providers can't be JIJed (even if we don't need the lang provider, just kotlin stdlib!), this means that mods MUST require their users to manually download Kotlin For Forge, including every single kotlin library, even those the mod doesn't need (by necessity, because they don't support JPMS and forge loads every JAR on the module path), which is a sorry state of affairs.

@marchermans
Copy link
Contributor

You can jij a language provider. But a lang provider can not jij itself for reasons we have discussed before: it is unclear where what version of the library goes. So for yes and language provider that has its own does needs to be downloaded.

@Rubydesic
Copy link

You can jij a language provider.

This is not true. Including Kotlin For Forge via JIJ will crash the game on startup with a ResolutionException if the player already has Kotlin For Forge in their mods folder.

@thedarkcolour
Copy link
Contributor Author

thedarkcolour commented Dec 9, 2022

The goal I have here is to have the lang provider jij a gamelibrary and the Kotlin libs. Previously I had it working where the game library is all inline functions, but that dumps a bunch of duplicated bytecode into other mods and it limits changing the library in the future.
It seems like no matter what order I jij things, there's a classloading or module error.

@thedarkcolour
Copy link
Contributor Author

Shadowing Kotlin while JiJ everything else works, although it would be ideal to have Kotlin as a JarJar library instead of a shadowed one.

@marchermans
Copy link
Contributor

This is know and as of now a not supported scenario.

A none fml aware library will always be put into beh game layer and there is no effective way to change that.

Any launch plugin like a language provider should shadow its dependencies.

@marchermans marchermans closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2023
@Rubydesic
Copy link

This is know and as of now a not supported scenario.

A none fml aware library will always be put into beh game layer and there is no effective way to change that.

Any launch plugin like a language provider should shadow its dependencies.

This is very bad for the aforementioned reason that it forces mods that need kotlin to not only have a hard dependency on kotlin for forge (or create an incompatibility), but also to force users to manually download it because it cannot be JIJ'd. Is there a recommended solution for this issue?

@marchermans
Copy link
Contributor

The language loader can be jar in jarred.
It however can not jar in jar libraries which are not fml aware.

This is currently a concequence of the way it is setup.

And is the status quo when it comes to language loaders even from before jar in jar.

@Rubydesic
Copy link

The language loader can be jar in jarred. It however can not jar in jar libraries which are not fml aware.

This is currently a concequence of the way it is setup.

And is the status quo when it comes to language loaders even from before jar in jar.

Should I make a separate issue then? Kotlin for Forge cannot be jar in jarred. If the player has Kotlin for Forge in the mods folder, and a mod that jar-in-jars Kotlin for Forge, they crash the game with a ResolutionException.

@marchermans marchermans reopened this Jan 12, 2023
@marchermans
Copy link
Contributor

We have decided to make it work somehow, it might take some time until we have a solution.

@OE-KT
Copy link

OE-KT commented Oct 8, 2023

Any updates about this?

@thedarkcolour
Copy link
Contributor Author

I made a pull request that will fix this issue: #9939

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.19 Bug This request reports or fixes a new or existing bug. Confirmed This request has been verified to be factually correct by at least one member of the team.
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

8 participants
@cpw @marchermans @sciwhiz12 @Rubydesic @thedarkcolour @tmvkrpxl0 @OE-KT and others