I am using JNI to call some static Java method from Rust side, but its throwing an
java.lang.IllegalAccessError
java.lang.IllegalAccessError
exception
the code for calling the method is nothing special:
// 5. Start JVM let jvm = JavaVM::new(jvm_args)?; let mut env = jvm.attach_current_thread()?; println!("Calling: Bootstrap.initialize()"); env.call_static_method("net/minecraft/Bootstrap", "initialize", "()V", &[])?;
// 5. Start JVM let jvm = JavaVM::new(jvm_args)?; let mut env = jvm.attach_current_thread()?; println!("Calling: Bootstrap.initialize()"); env.call_static_method("net/minecraft/Bootstrap", "initialize", "()V", &[])?;
It feels to me that the error have something to do with JVM/JNI and Java itself rather than the Rust library, I am super new to Java, so any help would be much appreciated, this is the full error (truncated):
Calling: Bootstrap.initialize()Exception in thread "Thread-0" java.lang.IllegalAccessError: class net.minecraft.registry.SimpleRegistry tried to access method 'void net.minecraft.registry.entry.RegistryEntry$Reference.setRegistryKey(net.minecraft.registry.RegistryKey)' (net.minecraft.registry.SimpleRegistry and net.minecraft.registry.entry.RegistryEntry$Reference are in unnamed module of loader 'app') at net.minecraft.registry.SimpleRegistry.add(SimpleRegistry.java:120) at net.minecraft.registry.SimpleDefaultedRegistry.add(SimpleDefaultedRegistry.java:23) at net.minecraft.registry.Registry.register(Registry.java:126) at net.minecraft.registry.Registry.register(Registry.java:122) at net.minecraft.registry.Registry.register(Registry.java:118) at net.minecraft.fluid.Fluids.register(Fluids.java:14) at net.minecraft.fluid.Fluids.<clinit>(Fluids.java:7) at net.minecraft.block.AbstractBlock$AbstractBlockState.<init>(AbstractBlock.java:851) at net.minecraft.block.BlockState.<init>(BlockState.java:17) at net.minecraft.state.StateManager.method_28484(StateManager.java:64) at java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ...
Calling: Bootstrap.initialize()Exception in thread "Thread-0" java.lang.IllegalAccessError: class net.minecraft.registry.SimpleRegistry tried to access method 'void net.minecraft.registry.entry.RegistryEntry$Reference.setRegistryKey(net.minecraft.registry.RegistryKey)' (net.minecraft.registry.SimpleRegistry and net.minecraft.registry.entry.RegistryEntry$Reference are in unnamed module of loader 'app') at net.minecraft.registry.SimpleRegistry.add(SimpleRegistry.java:120) at net.minecraft.registry.SimpleDefaultedRegistry.add(SimpleDefaultedRegistry.java:23) at net.minecraft.registry.Registry.register(Registry.java:126) at net.minecraft.registry.Registry.register(Registry.java:122) at net.minecraft.registry.Registry.register(Registry.java:118) at net.minecraft.fluid.Fluids.register(Fluids.java:14) at net.minecraft.fluid.Fluids.<clinit>(Fluids.java:7) at net.minecraft.block.AbstractBlock$AbstractBlockState.<init>(AbstractBlock.java:851) at net.minecraft.block.BlockState.<init>(BlockState.java:17) at net.minecraft.state.StateManager.method_28484(StateManager.java:64) at java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ...