jode/bytecode/ClassInfo.java.in, jode/bytecode/MethodInfo.java,

jode/bytecode/FieldInfo.java, jode/bytecode/BytecodeInfo.java.in:
	(readAttribute): Never read in known attributes as unknown 
	attributes.  This could happen before when class was first read with
	known info and then again with all info.

jode/obfuscator/ClassIdentifier.java: (doTransformation): Remove
	all unknown attributes.  They may contain references to
	nonexisting constant pool entries.

jode/obfuscator/PackageIdentifier.java: (loadClass): Fix a
	compile time bug in the last patch.


git-svn-id: https://svn.code.sf.net/p/jode/code/branches/branch_1_1@1407 379699f6-c40d-0410-875b-85095c16579e
branch_1_1
hoenicke 18 years ago
parent fca129b90a
commit 240de78e81
  1. 18
      jode/ChangeLog
  2. 12
      jode/jode/bytecode/BytecodeInfo.java.in
  3. 11
      jode/jode/bytecode/ClassInfo.java.in
  4. 5
      jode/jode/bytecode/FieldInfo.java
  5. 5
      jode/jode/bytecode/MethodInfo.java
  6. 4
      jode/jode/obfuscator/ClassIdentifier.java.in
  7. 6
      jode/jode/obfuscator/PackageIdentifier.java.in

@ -1,3 +1,21 @@
2007-07-31 Jochen Hoenicke <hoenicke@gmail.com>
* jode/bytecode/ClassInfo.java.in:
(readAttribute): Never read in known attributes as unknown
attributes. This could happen before when class was first read with
known info and then again with all info.
* jode/bytecode/MethodInfo.java: (readAttribute): Likewise.
* jode/bytecode/FieldInfo.java: (readAttribute): Likewise.
* jode/bytecode/BytecodeInfo.java.in: (readAttribute): Likewise.
* jode/obfuscator/ClassIdentifier.java: (doTransformation): Remove
all unknown attributes. They may contain references to
nonexisting constant pool entries.
* jode/obfuscator/PackageIdentifier.java: (loadClass): Fix a
compile time bug in the last patch.
2005-09-13 Jochen Hoenicke <jochen@gnu.org>
Check for NullPointer in SyntheticAnalyzer. Based on

@ -211,8 +211,8 @@ public class BytecodeInfo extends BinaryInfo implements Opcodes {
protected void readAttribute(String name, int length, ConstantPool cp,
DataInputStream input,
int howMuch) throws IOException {
if ((howMuch & KNOWNATTRIBS) != 0
&& name.equals("LocalVariableTable")) {
if (name.equals("LocalVariableTable")) {
if ((howMuch & KNOWNATTRIBS) != 0){
if ((GlobalOptions.debuggingFlags & GlobalOptions.DEBUG_LVT) != 0)
GlobalOptions.err.println("LocalVariableTable of "+methodInfo);
int count = input.readUnsignedShort();
@ -273,8 +273,10 @@ public class BytecodeInfo extends BinaryInfo implements Opcodes {
+" range "+start+" - "+end
+" slot "+slot);
}
} else if ((howMuch & KNOWNATTRIBS) != 0
&& name.equals("LineNumberTable")) {
} else
input.readFully(new byte[length]);
} else if (name.equals("LineNumberTable")) {
if ((howMuch & KNOWNATTRIBS) != 0) {
int count = input.readUnsignedShort();
if (length != 2 + count * 4) {
GlobalOptions.err.println
@ -295,6 +297,8 @@ public class BytecodeInfo extends BinaryInfo implements Opcodes {
lnt[i].start = startInstr;
lnt[i].linenr = input.readUnsignedShort();
}
} else
input.readFully(new byte[length]);
} else
super.readAttribute(name, length, cp, input, howMuch);
}

@ -168,13 +168,16 @@ public class ClassInfo extends BinaryInfo {
ConstantPool cp,
DataInputStream input,
int howMuch) throws IOException {
if ((howMuch & KNOWNATTRIBS) != 0 && name.equals("SourceFile")) {
if (name.equals("SourceFile")) {
if ((howMuch & KNOWNATTRIBS) != 0) {
if (length != 2)
throw new ClassFormatException("SourceFile attribute"
+ " has wrong length");
sourceFile = cp.getUTF8(input.readUnsignedShort());
} else if ((howMuch & (OUTERCLASSES | INNERCLASSES)) != 0
&& name.equals("InnerClasses")) {
} else
input.readFully(new byte[length]);
} else if (name.equals("InnerClasses")) {
if ((howMuch & (OUTERCLASSES | INNERCLASSES)) != 0) {
int count = input.readUnsignedShort();
if (length != 2 + 8 * count)
throw new ClassFormatException
@ -273,6 +276,8 @@ public class ClassInfo extends BinaryInfo {
extraClasses[--extraCount] = ici;
}
}
} else
input.readFully(new byte[length]);
} else if (name.equals("Deprecated")) {
deprecatedFlag = true;
if (length != 0)

@ -49,12 +49,15 @@ public class FieldInfo extends BinaryInfo {
ConstantPool cp,
DataInputStream input,
int howMuch) throws IOException {
if ((howMuch & KNOWNATTRIBS) != 0 && name.equals("ConstantValue")) {
if (name.equals("ConstantValue")) {
if ((howMuch & KNOWNATTRIBS) != 0) {
if (length != 2)
throw new ClassFormatException("ConstantValue attribute"
+ " has wrong length");
int index = input.readUnsignedShort();
constant = cp.getConstant(index);
} else
input.readFully(new byte[length]);
} else if (name.equals("Synthetic")) {
syntheticFlag = true;
if (length != 0)

@ -51,9 +51,12 @@ public class MethodInfo extends BinaryInfo {
protected void readAttribute(String name, int length, ConstantPool cp,
DataInputStream input,
int howMuch) throws IOException {
if ((howMuch & KNOWNATTRIBS) != 0 && name.equals("Code")) {
if (name.equals("Code")) {
if ((howMuch & KNOWNATTRIBS) != 0) {
bytecode = new BytecodeInfo(this);
bytecode.read(cp, input);
} else
input.readFully(new byte[length]);
} else if (name.equals("Exceptions")) {
int count = input.readUnsignedShort();
exceptions = new String[count];

@ -663,6 +663,10 @@ public class ClassIdentifier extends Identifier {
}
}
/* Drop unknown attributes.
* They may be broken now anyway due to renaming.
*/
info.dropInfo(info.UNKNOWN_ATTRIBUTES);
info.setFields((FieldInfo[]) newFields.toArray
(new FieldInfo[newFields.size()]));
info.setMethods((MethodInfo[]) newMethods.toArray

@ -102,7 +102,7 @@ public class PackageIdentifier extends Identifier {
loadedClasses.put(subclazz, ident);
swappedClasses = null;
bundle.addClassIdentifier(ident);
((ClassIdentifier) ident).initClass();
ident.initClass();
}
}
// Everything is loaded, we don't need to load on demand anymore.
@ -131,7 +131,7 @@ public class PackageIdentifier extends Identifier {
public ClassIdentifier loadClass(String name) {
int index = name.indexOf('.');
if (index == -1) {
ClassIdentifier ident = (Identifier) loadedClasses.get(name);
ClassIdentifier ident = (ClassIdentifier) loadedClasses.get(name);
if (ident == null) {
String subFull =
(fullName.length() > 0) ? fullName + "."+ name : name;
@ -156,7 +156,7 @@ public class PackageIdentifier extends Identifier {
loadedClasses.put(name, ident);
swappedClasses = null;
bundle.addClassIdentifier(ident);
((ClassIdentifier) ident).initClass();
ident.initClass();
}
}
return ident;

Loading…
Cancel
Save