diff --git a/jode/jode/bytecode/BinaryInfo.java.in b/jode/jode/bytecode/BinaryInfo.java.in index d727d58..d992619 100644 --- a/jode/jode/bytecode/BinaryInfo.java.in +++ b/jode/jode/bytecode/BinaryInfo.java.in @@ -150,6 +150,11 @@ public class BinaryInfo { } } + public void dropInfo(int howMuch) { + if ((howMuch & UNKNOWNATTRIBS) != 0) + unknownAttributes = null; + } + protected void prepareAttributes(GrowableConstantPool gcp) { if (unknownAttributes == null) return; diff --git a/jode/jode/bytecode/BytecodeInfo.java.in b/jode/jode/bytecode/BytecodeInfo.java.in index 4c1fcbd..d7a0169 100644 --- a/jode/jode/bytecode/BytecodeInfo.java.in +++ b/jode/jode/bytecode/BytecodeInfo.java.in @@ -1420,6 +1420,14 @@ public class BytecodeInfo extends BinaryInfo implements Opcodes { writeAttributes(gcp, output); } + public void dropInfo(int howMuch) { + if ((howMuch & KNOWNATTRIBS) != 0) { + lvt = null; + lnt = null; + } + super.dropInfo(howMuch); + } + public int getSize() { /* maxStack: 2 * maxLocals: 2 diff --git a/jode/jode/bytecode/ClassInfo.java.in b/jode/jode/bytecode/ClassInfo.java.in index b32d3fe..fef3e0d 100644 --- a/jode/jode/bytecode/ClassInfo.java.in +++ b/jode/jode/bytecode/ClassInfo.java.in @@ -643,6 +643,51 @@ public class ClassInfo extends BinaryInfo { } } + /** + * This is the counter part to loadInfo. It will drop all info specified + * in howMuch and clean up the memory. + * @param howMuch tells how much info we should drop + */ + public void dropInfo(int howMuch) { + if ((status & howMuch) == 0) + return; + if (modified) { + System.err.println("Dropping info 0x" + + Integer.toHexString(howMuch) + + " (status 0x" + Integer.toHexString(status) + + ") in class " + this); + Thread.dumpStack(); + return; + } + howMuch &= status; + + if ((howMuch & FIELDS) != 0) { + fields = null; + } else if ((status & FIELDS) != 0 + && (howMuch & (KNOWNATTRIBS | UNKNOWNATTRIBS)) != 0) { + for (int i=0; i < fields.length; i++) + fields[i].dropInfo(howMuch); + } + + if ((howMuch & METHODS) != 0) { + methods = null; + } else if ((status & METHODS) != 0 + && (howMuch & (KNOWNATTRIBS | UNKNOWNATTRIBS)) != 0) { + for (int i=0; i < methods.length; i++) + methods[i].dropInfo(howMuch); + } + if ((howMuch & KNOWNATTRIBS) != 0) + sourceFile = null; + if ((howMuch & OUTERCLASSES) != 0) + outerClasses = null; + if ((howMuch & INNERCLASSES) != 0) { + innerClasses = null; + extraClasses = null; + } + super.dropInfo(howMuch); + status &= ~howMuch; + } + public String getName() { return name; } diff --git a/jode/jode/bytecode/FieldInfo.java b/jode/jode/bytecode/FieldInfo.java index 4caf334..a98d2fd 100644 --- a/jode/jode/bytecode/FieldInfo.java +++ b/jode/jode/bytecode/FieldInfo.java @@ -140,6 +140,12 @@ public class FieldInfo extends BinaryInfo { writeAttributes(constantPool, output); } + public void dropInfo(int howMuch) { + if ((howMuch & KNOWNATTRIBS) != 0) + constant = null; + super.dropInfo(howMuch); + } + public String getName() { return name; } diff --git a/jode/jode/bytecode/MethodInfo.java b/jode/jode/bytecode/MethodInfo.java index efedd60..8c52c5f 100644 --- a/jode/jode/bytecode/MethodInfo.java +++ b/jode/jode/bytecode/MethodInfo.java @@ -156,6 +156,16 @@ public class MethodInfo extends BinaryInfo { writeAttributes(constantPool, output); } + public void dropInfo(int howMuch) { + if ((howMuch & KNOWNATTRIBS) != 0) { + bytecode = null; + exceptions = null; + } + if (bytecode != null) + bytecode.dropInfo(howMuch); + super.dropInfo(howMuch); + } + public ClassInfo getClazzInfo() { return clazzInfo; }