Search in sources :

Example 1 with ClassFileVisitor

use of net.runelite.asm.visitors.ClassFileVisitor in project runelite by runelite.

the class JarUtil method loadJar.

public static ClassGroup loadJar(File jarfile) throws IOException {
    ClassGroup group = new ClassGroup();
    try (JarFile jar = new JarFile(jarfile)) {
        for (Enumeration<JarEntry> it = jar.entries(); it.hasMoreElements(); ) {
            JarEntry entry = it.nextElement();
            if (!entry.getName().endsWith(".class")) {
                continue;
            }
            InputStream is = jar.getInputStream(entry);
            ClassReader reader = new ClassReader(is);
            ClassFileVisitor cv = new ClassFileVisitor();
            reader.accept(cv, ClassReader.SKIP_FRAMES);
            group.addClass(cv.getClassFile());
        }
    }
    group.initialize();
    return group;
}
Also used : ClassFileVisitor(net.runelite.asm.visitors.ClassFileVisitor) ClassGroup(net.runelite.asm.ClassGroup) InputStream(java.io.InputStream) ClassReader(org.objectweb.asm.ClassReader) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry)

Example 2 with ClassFileVisitor

use of net.runelite.asm.visitors.ClassFileVisitor in project runelite by runelite.

the class BufferMethodInjector method loadClass.

static ClassFile loadClass(InputStream in) throws IOException {
    ClassReader reader = new ClassReader(in);
    ClassFileVisitor cv = new ClassFileVisitor();
    reader.accept(cv, ClassReader.SKIP_FRAMES);
    return cv.getClassFile();
}
Also used : ClassFileVisitor(net.runelite.asm.visitors.ClassFileVisitor) ClassReader(org.objectweb.asm.ClassReader)

Example 3 with ClassFileVisitor

use of net.runelite.asm.visitors.ClassFileVisitor in project runelite by runelite.

the class ClassUtil method loadClass.

public static ClassFile loadClass(InputStream in) throws IOException {
    ClassReader reader = new ClassReader(in);
    ClassFileVisitor cv = new ClassFileVisitor();
    reader.accept(cv, ClassReader.SKIP_FRAMES);
    return cv.getClassFile();
}
Also used : ClassFileVisitor(net.runelite.asm.visitors.ClassFileVisitor) ClassReader(org.objectweb.asm.ClassReader)

Example 4 with ClassFileVisitor

use of net.runelite.asm.visitors.ClassFileVisitor in project runelite by runelite.

the class MixinInjector method loadClass.

private ClassFile loadClass(Class<?> clazz) throws IOException {
    try (InputStream is = clazz.getClassLoader().getResourceAsStream(clazz.getName().replace('.', '/') + ".class")) {
        ClassReader reader = new ClassReader(is);
        ClassFileVisitor cv = new ClassFileVisitor();
        reader.accept(cv, 0);
        return cv.getClassFile();
    }
}
Also used : ClassFileVisitor(net.runelite.asm.visitors.ClassFileVisitor) InputStream(java.io.InputStream) ClassReader(org.objectweb.asm.ClassReader)

Aggregations

ClassFileVisitor (net.runelite.asm.visitors.ClassFileVisitor)4 ClassReader (org.objectweb.asm.ClassReader)4 InputStream (java.io.InputStream)2 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 ClassGroup (net.runelite.asm.ClassGroup)1