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> 2005-09-13 Jochen Hoenicke <jochen@gnu.org>
Check for NullPointer in SyntheticAnalyzer. Based on 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, protected void readAttribute(String name, int length, ConstantPool cp,
DataInputStream input, DataInputStream input,
int howMuch) throws IOException { int howMuch) throws IOException {
if ((howMuch & KNOWNATTRIBS) != 0 if (name.equals("LocalVariableTable")) {
&& name.equals("LocalVariableTable")) { if ((howMuch & KNOWNATTRIBS) != 0){
if ((GlobalOptions.debuggingFlags & GlobalOptions.DEBUG_LVT) != 0) if ((GlobalOptions.debuggingFlags & GlobalOptions.DEBUG_LVT) != 0)
GlobalOptions.err.println("LocalVariableTable of "+methodInfo); GlobalOptions.err.println("LocalVariableTable of "+methodInfo);
int count = input.readUnsignedShort(); int count = input.readUnsignedShort();
@ -273,8 +273,10 @@ public class BytecodeInfo extends BinaryInfo implements Opcodes {
+" range "+start+" - "+end +" range "+start+" - "+end
+" slot "+slot); +" slot "+slot);
} }
} else if ((howMuch & KNOWNATTRIBS) != 0 } else
&& name.equals("LineNumberTable")) { input.readFully(new byte[length]);
} else if (name.equals("LineNumberTable")) {
if ((howMuch & KNOWNATTRIBS) != 0) {
int count = input.readUnsignedShort(); int count = input.readUnsignedShort();
if (length != 2 + count * 4) { if (length != 2 + count * 4) {
GlobalOptions.err.println GlobalOptions.err.println
@ -295,6 +297,8 @@ public class BytecodeInfo extends BinaryInfo implements Opcodes {
lnt[i].start = startInstr; lnt[i].start = startInstr;
lnt[i].linenr = input.readUnsignedShort(); lnt[i].linenr = input.readUnsignedShort();
} }
} else
input.readFully(new byte[length]);
} else } else
super.readAttribute(name, length, cp, input, howMuch); super.readAttribute(name, length, cp, input, howMuch);
} }

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

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

@ -51,9 +51,12 @@ public class MethodInfo extends BinaryInfo {
protected void readAttribute(String name, int length, ConstantPool cp, protected void readAttribute(String name, int length, ConstantPool cp,
DataInputStream input, DataInputStream input,
int howMuch) throws IOException { int howMuch) throws IOException {
if ((howMuch & KNOWNATTRIBS) != 0 && name.equals("Code")) { if (name.equals("Code")) {
if ((howMuch & KNOWNATTRIBS) != 0) {
bytecode = new BytecodeInfo(this); bytecode = new BytecodeInfo(this);
bytecode.read(cp, input); bytecode.read(cp, input);
} else
input.readFully(new byte[length]);
} else if (name.equals("Exceptions")) { } else if (name.equals("Exceptions")) {
int count = input.readUnsignedShort(); int count = input.readUnsignedShort();
exceptions = new String[count]; 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 info.setFields((FieldInfo[]) newFields.toArray
(new FieldInfo[newFields.size()])); (new FieldInfo[newFields.size()]));
info.setMethods((MethodInfo[]) newMethods.toArray info.setMethods((MethodInfo[]) newMethods.toArray

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

Loading…
Cancel
Save