JNI IllegalAccessError

I am using JNI to call some static Java method from Rust side, but its throwing an 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)
...
3 Replies
JavaBot
JavaBot22h ago
This post has been reserved for your question.
Hey @Potentiometer Annihilator! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Noah | Nowipi
Noah | Nowipi19h ago
def wrong rust lib usage did you write any Java code? FFM is the new way of connecting Java with native code btw
JavaBot
JavaBot14h ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?