ClassNodeLoader Cleanup
This commit is contained in:
parent
a6311d86ba
commit
a96f2ed445
1 changed files with 6 additions and 3 deletions
|
@ -33,8 +33,8 @@ import org.objectweb.asm.tree.ClassNode;
|
||||||
* @author Demmonic
|
* @author Demmonic
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class ClassNodeLoader extends ClassLoader {
|
public final class ClassNodeLoader extends ClassLoader
|
||||||
|
{
|
||||||
private final HashMap<String, ClassNode> classes = new HashMap<>();
|
private final HashMap<String, ClassNode> classes = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,15 +112,18 @@ public final class ClassNodeLoader extends ClassLoader {
|
||||||
* @param node The node to convert
|
* @param node The node to convert
|
||||||
* @return The converted class
|
* @return The converted class
|
||||||
*/
|
*/
|
||||||
public Class<?> nodeToClass(ClassNode node) {
|
public Class<?> nodeToClass(ClassNode node)
|
||||||
|
{
|
||||||
if (super.findLoadedClass(node.name.replace("/", ".")) != null)
|
if (super.findLoadedClass(node.name.replace("/", ".")) != null)
|
||||||
return findLoadedClass(node.name.replace("/", "."));
|
return findLoadedClass(node.name.replace("/", "."));
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||||
try {
|
try {
|
||||||
node.accept(cw);
|
node.accept(cw);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] b = cw.toByteArray();
|
byte[] b = cw.toByteArray();
|
||||||
return defineClass(node.name.replaceAll("/", "."), b, 0, b.length,
|
return defineClass(node.name.replaceAll("/", "."), b, 0, b.length,
|
||||||
getDomain());
|
getDomain());
|
||||||
|
|
Loading…
Reference in a new issue