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

Some ASM methods are not usable without access to some Java types #26

Closed
GirafiStudios opened this issue Dec 16, 2019 · 2 comments
Closed

Comments

@GirafiStudios
Copy link
Contributor

GirafiStudios commented Dec 16, 2019

Methods like AbstractInsnNode.clone(Map<LabelNode, LabelNode> clonedLabels) cannot be called from Nashorn without using Java.type("java.util.HashMap") or some other Map type, but CoreModEngine does not allow access to java.util.HashMap (Java.type("java.util.HashMap") fails with java.lang.ClassNotFoundException: java.util.HashMap).

As far as I can tell, Javascript objects in Nashorn are Maps, but only support String keys. Doing something like

var LabelNode = Java.type("org.objectweb.asm.tree.LabelNode");
var instruction = new LabelNode();
var map = {};
instruction.clone(map);

will give an error like:

key should be a String. It is org.objectweb.asm.tree.LabelNode instead. java.lang.ClassCastException: key should be a String. It is org.objectweb.asm.tree.LabelNode instead. at jdk.nashorn.api.scripting.ScriptObjectMirror.checkKey(ScriptObjectMirror.java:884) at jdk.nashorn.api.scripting.ScriptObjectMirror.get(ScriptObjectMirror.java:381) at org.objectweb.asm.tree.LabelNode.clone(LabelNode.java:73) at jdk.nashorn.internal.scripts.Script$Recompilation$5$18587A$\^eval\_.ASMHelper#cloneInsnList(<eval>:453) at jdk.nashorn.internal.scripts.Script$Recompilation$1$909$\^eval\_.initializeCoreMod(<eval>:58) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)

@James103
Copy link

As far as I can tell, this is a major problem, preventing several major mods, including AppleCore and Iguana Tweaks Reborn from being fully ported over to 1.15.

@Insane96
Copy link

Insane96 commented Aug 5, 2020

Iguana Tweaks Reborn from being fully ported over to 1.15.

Actually the features required from AppleCore are for porting Hunger Ovehaul.

squeek502 added a commit to squeek502/ASMHelper that referenced this issue Feb 7, 2021
squeek502 added a commit to squeek502/AppleCore that referenced this issue Feb 7, 2021
This is what I had before I stopped working on it when blocked by MinecraftForge/CoreMods#26.
GirafiStudios pushed a commit to squeek502/ASMHelper that referenced this issue Feb 7, 2021
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

3 participants