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;
}
}
}
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;
}
Aggregations