|
|
@ -19,8 +19,16 @@ |
|
|
|
|
|
|
|
|
|
|
|
package jode.bytecode; |
|
|
|
package jode.bytecode; |
|
|
|
import java.io.*; |
|
|
|
import java.io.*; |
|
|
|
import java.util.Enumeration; |
|
|
|
import jode.util.SimpleMap; |
|
|
|
import jode.util.SimpleDictionary; |
|
|
|
|
|
|
|
|
|
|
|
///#ifdef JDK12
|
|
|
|
|
|
|
|
///import java.util.Map;
|
|
|
|
|
|
|
|
///import java.util.Iterator;
|
|
|
|
|
|
|
|
///#else
|
|
|
|
|
|
|
|
import jode.util.Map; |
|
|
|
|
|
|
|
import jode.util.Iterator; |
|
|
|
|
|
|
|
///#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
* |
|
|
@ -36,7 +44,7 @@ public class BinaryInfo { |
|
|
|
public static final int OUTERCLASSES = 0x40; |
|
|
|
public static final int OUTERCLASSES = 0x40; |
|
|
|
public static final int FULLINFO = 0xff; |
|
|
|
public static final int FULLINFO = 0xff; |
|
|
|
|
|
|
|
|
|
|
|
protected SimpleDictionary unknownAttributes; |
|
|
|
protected Map unknownAttributes; |
|
|
|
|
|
|
|
|
|
|
|
protected void skipAttributes(DataInputStream input) throws IOException { |
|
|
|
protected void skipAttributes(DataInputStream input) throws IOException { |
|
|
|
int count = input.readUnsignedShort(); |
|
|
|
int count = input.readUnsignedShort(); |
|
|
@ -121,7 +129,7 @@ public class BinaryInfo { |
|
|
|
DataInputStream input, |
|
|
|
DataInputStream input, |
|
|
|
int howMuch) throws IOException { |
|
|
|
int howMuch) throws IOException { |
|
|
|
int count = input.readUnsignedShort(); |
|
|
|
int count = input.readUnsignedShort(); |
|
|
|
unknownAttributes = new SimpleDictionary(); |
|
|
|
unknownAttributes = new SimpleMap(); |
|
|
|
for (int i=0; i< count; i++) { |
|
|
|
for (int i=0; i< count; i++) { |
|
|
|
String attrName = |
|
|
|
String attrName = |
|
|
|
constantPool.getUTF8(input.readUnsignedShort()); |
|
|
|
constantPool.getUTF8(input.readUnsignedShort()); |
|
|
@ -136,9 +144,9 @@ public class BinaryInfo { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void prepareAttributes(GrowableConstantPool gcp) { |
|
|
|
protected void prepareAttributes(GrowableConstantPool gcp) { |
|
|
|
Enumeration enum = unknownAttributes.keys(); |
|
|
|
Iterator i = unknownAttributes.keySet().iterator(); |
|
|
|
while (enum.hasMoreElements()) |
|
|
|
while (i.hasNext()) |
|
|
|
gcp.putUTF8((String) enum.nextElement()); |
|
|
|
gcp.putUTF8((String) i.next()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void writeKnownAttributes |
|
|
|
protected void writeKnownAttributes |
|
|
@ -152,11 +160,11 @@ public class BinaryInfo { |
|
|
|
int count = unknownAttributes.size() + getKnownAttributeCount(); |
|
|
|
int count = unknownAttributes.size() + getKnownAttributeCount(); |
|
|
|
output.writeShort(count); |
|
|
|
output.writeShort(count); |
|
|
|
writeKnownAttributes(constantPool, output); |
|
|
|
writeKnownAttributes(constantPool, output); |
|
|
|
Enumeration keys = unknownAttributes.keys(); |
|
|
|
Iterator i = unknownAttributes.entrySet().iterator(); |
|
|
|
Enumeration elts = unknownAttributes.elements(); |
|
|
|
while (i.hasNext()) { |
|
|
|
while (keys.hasMoreElements()) { |
|
|
|
Map.Entry e = (Map.Entry) i.next(); |
|
|
|
String name = (String) keys.nextElement(); |
|
|
|
String name = (String) e.getKey(); |
|
|
|
byte[] data = (byte[]) elts.nextElement(); |
|
|
|
byte[] data = (byte[]) e.getValue(); |
|
|
|
output.writeShort(constantPool.putUTF8(name)); |
|
|
|
output.writeShort(constantPool.putUTF8(name)); |
|
|
|
output.writeInt(data.length); |
|
|
|
output.writeInt(data.length); |
|
|
|
output.write(data); |
|
|
|
output.write(data); |
|
|
@ -165,9 +173,9 @@ public class BinaryInfo { |
|
|
|
|
|
|
|
|
|
|
|
public int getAttributeSize() { |
|
|
|
public int getAttributeSize() { |
|
|
|
int size = 2; /* attribute count */ |
|
|
|
int size = 2; /* attribute count */ |
|
|
|
Enumeration enum = unknownAttributes.elements(); |
|
|
|
Iterator i = unknownAttributes.values().iterator(); |
|
|
|
while (enum.hasMoreElements()) |
|
|
|
while (i.hasNext()) |
|
|
|
size += 2 + 4 + ((byte[]) enum.nextElement()).length; |
|
|
|
size += 2 + 4 + ((byte[]) i.next()).length; |
|
|
|
return size; |
|
|
|
return size; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -175,8 +183,8 @@ public class BinaryInfo { |
|
|
|
return (byte[]) unknownAttributes.get(name); |
|
|
|
return (byte[]) unknownAttributes.get(name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Enumeration getAttributes() { |
|
|
|
public Iterator getAttributes() { |
|
|
|
return unknownAttributes.elements(); |
|
|
|
return unknownAttributes.values().iterator(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setAttribute(String name, byte[] content) { |
|
|
|
public void setAttribute(String name, byte[] content) { |
|
|
@ -188,6 +196,6 @@ public class BinaryInfo { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void removeAllAttributes() { |
|
|
|
public void removeAllAttributes() { |
|
|
|
unknownAttributes = new SimpleDictionary(); |
|
|
|
unknownAttributes = new SimpleMap(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|