-
Notifications
You must be signed in to change notification settings - Fork 22
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
Unable to load Lua54 natives when running/debugging in IntelliJ with minecraftforge+gradle #161
Comments
Thanks for the detailed reproducing steps! It seems you are using ForgeGradle. As is mentioned in their documentation that "Non-Minecraft dependencies are not loaded by Forge by default in the development environment", have you tried replacing https://github.com/GHXX/luajavatest/blob/ceb7c887bcd32c0ff6a5a79f19eb91c18b730986/build.gradle#L160 |
Yes, i have tried this, and i have just now double-checked, but the result appears to be exactly the same ( |
Here is an even more simple example by @00asdf only using gradle and java17: https://github.com/00asdf/LuaJavaTest Setup steps (although this should be fairly standard):
Exception:
|
It turns out I will try to come up with a solution (probably by submitting a PR in the By the way, the second reproducing repo has the dependency line wrong: https://github.com/00asdf/LuaJavaTest/blob/8bedcbdd546665b6137a73a944f2d011e45a5f58/build.gradle#L20 (It misses the classifier suffix |
Ah yes, you are totally right, adding the :natives-desktop does make it work properly (in the non-minecraft forge case).
I'll go ahead and try adding the jnigen jar onto the classpath as you suggested. I am not sure if I'll be able to get this to work, but if I do then I will let you know. |
Update on this: I did manage to get it to work (in another repository), but it involves unpacking all 3 luajava related jars (lua54 x2 and luajava) (and also the gdx-jnigen-loader jar) into the build/classes folder which essentially contains the compilation result of the mod. So quite a lot of hackery going on there (as I feared) but it no longer appears to fail which is a relief, and thus I expect the library to work fine, but I have not yet tested this. In the future it would be nice to have a more proper solution for this, thus I'd suggest we keep this issue ticket open in the meantime as it essentially still is an ongoing problem. |
I highly suggest to pack native library to other method for Minecraft Mod development. They uses completely different way to load sub-jars and its resource so you can encounter unexpected issues like this. Instead, I recommend |
you can consider to use Mixin when library is not allowed to change the directory of native library but it seems super overkill... I have no idea about better solution, but to support loading native library from specified path can be solution |
@gudzpoz Looks like the gdx-jnigen pr was just merged, so to take away some of the stress i want to point out that we have recently been prototyping a custom lua vm as we needed some extra features, such as pausing, saving and restoring entire VM states |
Thanks! Not supporting JPMS is definitely a bug in this library (as well as jnigen) and there is nothing to be sorry about reporting it. So thank you again for submitting this issue! (But unfortunately we might need to wait until gdx-jnigen releases a newer version containing this change.) |
Describe the bug
This might simply be user-error on my part, however, it appears that, upon creating an instance of
Lua54
, the luajava library attempts to use the com.badlogic.gdx.utils.SharedLibraryLoader to load lua5464.dll, however locating this dll fails, as I suspect it would need to be located in a different package/jar.To Reproduce
Steps to reproduce the behavior (assuming you are on Windows, otherwise step 2 differs slightly):
Current behavior
While the class Lua54 is loaded properly, the natives are not found by the SharedLibraryLoader, possibly because they are located in a jar that is separate from the jar containing the SharedLibraryLoader (see image 2; the highlighted line causes
input
to benull
). This is represented by the stacktrace below.Due to this I am unable to instantiate the Lua54 class.
Expected behavior
Luajava should successfully load the natives, resulting in no exception being thrown upon executing the following line of code:
Platform:
Arch: x86_64
OS: Windows 10 64 bit
Lua Version: Lua54
IntelliJ IDEA 2021.2.4
Gradle 8.1.1
JDK 17
LuaJava 3.5.0
Additional context
I am new-ish to gradle, so perhaps the actual issue lies in the build.gradle script (https://github.com/GHXX/luajavatest/blob/master/build.gradle), although the non-native parts of Luajava are being loaded properly it seems. Despite getting that to work, I cannot think of any other things to try at this point, even after a few days of digging through the internet.
Additionally, when packing all luajava dependencies (including the natives) via shading into the mod-jar and loading this outside of the development environment, so in a normal minecraft-client 1.20.1 installation, with forge, it loads successfully. This is not included in the minimal example. But the top-level directory structure of the working mod jar is shown in image 3.
Lua54 was the only LUA version I have tried. I also have not tried LuaJit.
The build-outputs are located in the
/build
folder. Interesting subfolders areclasses/
,classpath/
andlibs/
(which contains the output jar), and possibly others.Run configuration screenshot:
Root of the exception chain:
Working jar when using it outside of the dev environment:
The text was updated successfully, but these errors were encountered: