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

In ide, minecraft classes should be loaded with knot than java's default class loader #353

Closed
liach opened this issue Feb 16, 2021 · 15 comments

Comments

@liach
Copy link
Contributor

liach commented Feb 16, 2021

See FabricMC/yarn#2057

(net.minecraft.world.gen.chunk.NoiseChunkGenerator and net.minecraft.world.gen.StructureWeightSampler are in unnamed module of loader 'app')

Afaik running in other circumstances, such as in gradle run task or in production all goes through fabric loader. This one doesn't and apparently causes some trouble as it bypasses loaders' access hacks.

@Chocohead
Copy link
Contributor

Were this the case no Mixins would be able to apply to them either... which would be a far bigger problem. Given Knot is the context class loader before mods are even discovered it's a little difficult to completely avoid loading classes through it, could do with actual reproduction cases/code to work out what is happening for sure.

@liach
Copy link
Contributor Author

liach commented Feb 17, 2021

Maybe knot cannot find the class on classpath and just delegates to parent for the class, and the parent doesn't have pre-loading transformation hooks? That is a possibility.

@Chocohead
Copy link
Contributor

That would only happen if the Minecraft jar was split up into multiple jars, because Loader would only count the one with a net.minecraft.client.main.Main type class as being the complete game, which Fabric doesn't do. Knot must have at least some of the game jar as it has to put the entrypoints in to load mod initialisers in the first place, presuming it's getting that far of course. It would be heavily unlikely Mixin wouldn't notice classes it wanted were missing too were it only getting fragments.

@liach
Copy link
Contributor Author

liach commented Feb 17, 2021

Hmm, how did those classes escape into app classloader then? app should be the system class loader per https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/ClassLoader.html#getSystemClassLoader()

@Chocohead
Copy link
Contributor

That's why I suggested getting a reproduction case, you can artificially do it readily enough but the Yarn report appeared like it was accidental.

@liach
Copy link
Contributor Author

liach commented Feb 17, 2021

Hmm, in my intellij idea IDE I can never run my mods (always only loader loaded, mods folder works normally), and I always use runClient gradle task. I've only encountered such access issues before when I tried to run data generator in gradle tasks without fabric loader/knot. Need someone who can test this to test.

@Chocohead
Copy link
Contributor

If you're running without Loader you'll definitely get these issues as any access problems are fixed by it at runtime (seemingly to avoid mods compiling to depend on them from Modmuss's responses to #352). In such contexts though it's not really Loom's problem given it is only catering for the expected use case that you're using Loader.

@liach
Copy link
Contributor Author

liach commented Feb 17, 2021

@OroArmor do you have the full stacktrace of that illegal access error?

@modmuss50
Copy link
Member

If you want to run the data generator it has to go through loader/knot for a few reasons (AW's and mixins are 2), for now id recommend just calling the data generator from a client or a server mod.

Getting loader setup to run data gen should be easy enough, but it would need to have a fabric api module to go with it. And even then id still suggest just calling it after a server has booted up and close gracefully once compelete to ensure mods are correctaly loaded.

@liach
Copy link
Contributor Author

liach commented Feb 17, 2021

the problem now is not data gen. it's this access problem (in wrong classloader) happening under loader in dev env as seen in original yarn issue

@modmuss50
Copy link
Member

Then I need a way to reproduce it, or at the very least a full stacktrace to know how it was launched.

@OroArmor
Copy link

@OroArmor do you have the full stacktrace of that illegal access error?

No, it was someone else that encountered it. I just reported it

@liach
Copy link
Contributor Author

liach commented Feb 17, 2021

We need that full stacktrace in order to find out how minecraft classes are loaded by the app classloader without knot sanitization. Can you help contacting?

@OroArmor
Copy link

Sure give me a bit

@modmuss50
Copy link
Member

Not seen this for a while, please open a new issue if it still happens.

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

No branches or pull requests

4 participants