Search in sources :

Example 1 with Interfaces

use of net.runelite.asm.Interfaces in project runelite by runelite.

the class Renamer method renameClass.

private void renameClass(ClassFile on, ClassFile old, String name) {
    if (on.getParentClass().getName().equals(old.getName())) {
        on.setParentClass(new net.runelite.asm.pool.Class(name));
    }
    Interfaces interfaces = on.getInterfaces();
    List<net.runelite.asm.pool.Class> interfaceList = interfaces.getInterfaces();
    for (net.runelite.asm.pool.Class inter : interfaceList) {
        if (inter.getName().equals(old.getName())) {
            int idx = interfaceList.indexOf(inter);
            interfaceList.remove(idx);
            interfaceList.add(idx, new net.runelite.asm.pool.Class(name));
            break;
        }
    }
}
Also used : Interfaces(net.runelite.asm.Interfaces)

Example 2 with Interfaces

use of net.runelite.asm.Interfaces in project runelite by runelite.

the class Inject method injectInterface.

private java.lang.Class injectInterface(ClassFile cf, ClassFile other) {
    Annotations an = cf.getAnnotations();
    if (an == null) {
        return null;
    }
    Annotation a = an.find(DeobAnnotations.IMPLEMENTS);
    if (a == null) {
        return null;
    }
    String ifaceName = API_PACKAGE_BASE + a.getElement().getString();
    java.lang.Class<?> apiClass;
    try {
        apiClass = java.lang.Class.forName(ifaceName);
    } catch (ClassNotFoundException ex) {
        logger.trace("Class {} implements nonexistent interface {}, skipping interface injection", cf.getName(), ifaceName);
        return null;
    }
    // to internal name
    String ifaceNameInternal = ifaceName.replace('.', '/');
    Class clazz = new Class(ifaceNameInternal);
    Interfaces interfaces = other.getInterfaces();
    interfaces.addInterface(clazz);
    return apiClass;
}
Also used : Interfaces(net.runelite.asm.Interfaces) Annotations(net.runelite.asm.attributes.Annotations) DeobAnnotations(net.runelite.deob.DeobAnnotations) Class(net.runelite.asm.pool.Class) Annotation(net.runelite.asm.attributes.annotation.Annotation)

Aggregations

Interfaces (net.runelite.asm.Interfaces)2 Annotations (net.runelite.asm.attributes.Annotations)1 Annotation (net.runelite.asm.attributes.annotation.Annotation)1 Class (net.runelite.asm.pool.Class)1 DeobAnnotations (net.runelite.deob.DeobAnnotations)1