Tyranobast
Tyranobast
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 11/10/2024 in #java-help
Creating a gradle plugin for a custom JVM language
.
7 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 6/8/2023 in #java-help
Java 1.8 ASM modified code throws NoSuchFieldError
The decompiled Launch constructor (using FernFlower):
private Launch() {
URLClassLoader ucl =
(URLClassLoader)this.getClass().getClassLoader();
new LaunchClassLoader(ucl.getURLs());
classLoader = new CustomLaunchClassLoader(ucl.getURLs());
blackboard = new HashMap();
Thread.currentThread().setContextClassLoader(classLoader);
}
private Launch() {
URLClassLoader ucl =
(URLClassLoader)this.getClass().getClassLoader();
new LaunchClassLoader(ucl.getURLs());
classLoader = new CustomLaunchClassLoader(ucl.getURLs());
blackboard = new HashMap();
Thread.currentThread().setContextClassLoader(classLoader);
}
7 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 6/8/2023 in #java-help
Java 1.8 ASM modified code throws NoSuchFieldError
any help would be cool !!!!
7 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 6/8/2023 in #java-help
Java 1.8 ASM modified code throws NoSuchFieldError
The ASM code I use:
ClassReader cr = new ClassReader(Files.newInputStream(launchClass));
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("<init>")) {
return new MethodVisitor(Opcodes.ASM5, super.visitMethod(access, name, desc, signature, exceptions)) {
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (opcode == Opcodes.PUTSTATIC && "net/minecraft/launchwrapper/Launch".equals(owner) && "classLoader".equals(name)) {
mv.visitTypeInsn(Opcodes.NEW, "eu/damnatio/damnatioac/network/verification/CustomLaunchClassLoader");
mv.visitInsn(Opcodes.DUP);
mv.visitVarInsn(Opcodes.ALOAD, 1);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/net/URLClassLoader", "getURLs", "()[Ljava/net/URL;", false);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "eu/damnatio/damnatioac/network/verification/CustomLaunchClassLoader", "<init>", "([Ljava/net/URL;)V", false);
mv.visitFieldInsn(Opcodes.PUTSTATIC, "net/minecraft/launchwrapper/Launch", "classLoader", "Leu/damnatio/damnatioac/network/verification/CustomLaunchClassLoader;");
} else {
mv.visitFieldInsn(opcode, owner, name, desc);
}
}
};
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
};

cr.accept(cv, 0);
ClassReader cr = new ClassReader(Files.newInputStream(launchClass));
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("<init>")) {
return new MethodVisitor(Opcodes.ASM5, super.visitMethod(access, name, desc, signature, exceptions)) {
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (opcode == Opcodes.PUTSTATIC && "net/minecraft/launchwrapper/Launch".equals(owner) && "classLoader".equals(name)) {
mv.visitTypeInsn(Opcodes.NEW, "eu/damnatio/damnatioac/network/verification/CustomLaunchClassLoader");
mv.visitInsn(Opcodes.DUP);
mv.visitVarInsn(Opcodes.ALOAD, 1);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/net/URLClassLoader", "getURLs", "()[Ljava/net/URL;", false);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "eu/damnatio/damnatioac/network/verification/CustomLaunchClassLoader", "<init>", "([Ljava/net/URL;)V", false);
mv.visitFieldInsn(Opcodes.PUTSTATIC, "net/minecraft/launchwrapper/Launch", "classLoader", "Leu/damnatio/damnatioac/network/verification/CustomLaunchClassLoader;");
} else {
mv.visitFieldInsn(opcode, owner, name, desc);
}
}
};
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
};

cr.accept(cv, 0);
7 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 5/28/2023 in #java-help
ASM : Return a value
Ok thank you very much!
13 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 5/28/2023 in #java-help
ASM : Return a value
mv.visitIntInsn(); ?
13 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 5/28/2023 in #java-help
ASM : Return a value
with what visit call ?
13 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 5/28/2023 in #java-help
ASM : Return a value
For example : make a method that returns 3.
13 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 10/31/2022 in #java-help
Looking for file format
thanks ! worked
8 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 10/31/2022 in #java-help
Looking for file format
I do not need it to : - be human readable - be lightweight - have an external tool to read or write
8 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 10/19/2022 in #java-help
what does byte[] do while unzipping file ?
Okay thanks !
11 replies
JCHJava Community | Help. Code. Learn.
Created by Tyranobast on 10/19/2022 in #java-help
what does byte[] do while unzipping file ?
*zip not zim
11 replies