|
|
|
/* FieldInfo Copyright (C) 1998-2002 Jochen Hoenicke.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; see the file COPYING.LESSER. If not, write to
|
|
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
package net.sf.jode.bytecode;
|
|
|
|
import java.io.DataInputStream;
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.lang.reflect.Modifier;
|
|
|
|
///#def COLLECTIONEXTRA java.lang
|
|
|
|
import java.lang.Comparable;
|
|
|
|
///#enddef
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a java bytecode field (class variable). A field
|
|
|
|
* consists of the following parts:
|
|
|
|
*
|
|
|
|
* <dl>
|
|
|
|
*
|
|
|
|
* <dt>name</dt><dd>The field's name</dd>
|
|
|
|
*
|
|
|
|
* <dt>type</dt><dd>The field's {@link TypeSignature type signature}
|
|
|
|
* in bytecode format.</dd>
|
|
|
|
*
|
|
|
|
* <dt>modifiers</dt><dd>The modifiers of the field like private, public etc.
|
|
|
|
* These are created by or-ing the constants {@link Modifier#PUBLIC},
|
|
|
|
* {@link Modifier#PRIVATE}, {@link Modifier#PROTECTED},
|
|
|
|
* {@link Modifier#STATIC}, {@link Modifier#FINAL},
|
|
|
|
* {@link Modifier#VOLATILE}, {@link Modifier#TRANSIENT},
|
|
|
|
* {@link Modifier#STRICT}
|
|
|
|
* of class {@link java.lang.reflect.Modifier}. </dt>
|
|
|
|
*
|
|
|
|
* <dt>synthetic</dt><dd>true if this field is synthetic.</dd>
|
|
|
|
*
|
|
|
|
* <dt>deprecated</dt><dd>true if this field is deprecated.</dd>
|
|
|
|
*
|
|
|
|
* <dt>constant</dt> <dd>Final static fields may have a constant
|
|
|
|
* value. This is either of type String, Integer, Long, Float or
|
|
|
|
* Double. </dt>
|
|
|
|
*
|
|
|
|
* </dl>
|
|
|
|
*
|
|
|
|
* @author Jochen Hoenicke
|
|
|
|
* @see net.sf.jode.bytecode.TypeSignature
|
|
|
|
* @see net.sf.jode.bytecode.BasicBlocks
|
|
|
|
*/
|
|
|
|
public final class FieldInfo extends BinaryInfo implements Comparable {
|
|
|
|
int modifier;
|
|
|
|
String name;
|
|
|
|
String typeSig;
|
|
|
|
|
|
|
|
Object constant;
|
|
|
|
boolean syntheticFlag;
|
|
|
|
boolean deprecatedFlag;
|
|
|
|
/**
|
|
|
|
* The type signature that also contains template information.
|
|
|
|
*/
|
|
|
|
private String signature;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new empty field info.
|
|
|
|
*/
|
|
|
|
public FieldInfo() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new field with given name, type and modifiers.
|
|
|
|
* @param name the name of the field.
|
|
|
|
* @param typeSig the typeSig the type signature.
|
|
|
|
* @param modifier the modifier
|
|
|
|
* @see TypeSignature
|
|
|
|
* @see Modifier
|
|
|
|
*/
|
|
|
|
public FieldInfo(String name, String typeSig, int modifier) {
|
|
|
|
this.name = name;
|
|
|
|
this.typeSig = typeSig;
|
|
|
|
this.modifier = modifier;
|
|
|
|
}
|
|
|
|
|
Documentation updates (INSTALL, javadoc).
Added JUnit Test cases.
* build.xml: Big update.
* net/sf/jode/bytecode/BasicBlock.java:
(updateMaxStackLocals): new method to calculate maxStack and
maxLocals.
(setBlocks): fixed calculation of handlers, call updateMaxLocals.
* net/sf/jode/bytecode/BasicBlockReader.java:
(maxLocals, maxStack): new fields.
(readCode): read maxStack/Locals into private fields.
(convert): check that maxStack/Locals match what we calculate.
* net/sf/jode/bytecode/BinaryInfo.java:
(getKnownAttributeCount): renamed to...
(getAttributeCount): ... this, and also count internal attributes.
Made it protected.
(readAttribute): made protected.
(drop): made protected.
(prepareAttributes): made protected.
(writeKnownAttributes): removed.
(writeAttributes): made protected, use getAttributeCount.
Changed policy: it doesn't call writeKnownAttribute, but instead
it expects sub classes to override this method.
(getAttributeSize): made protected, subclasses should override it.
Changed all subclasses to new policy.
* net/sf/jode/bytecode/Block.java:
(lineNr): Removed, it wasn't used.
(pop,push): Removed, replaced by ...
(maxpop,maxpush,delta): ... these, with slightly changed semantics.
(stackHeight): New variable.
(Block): Default Constructor doesn't initialize fields now.
(getCatchers): Renamed to ...
(getHandlers): ... this, changed all callers.
(initCode): Calculate maxpop, maxpush, delta correctly.
(getStackPopPush): Changed accordingly to new fields.
(setCode): Removed debugging output for illegal contents.
* net/sf/jode/bytecode/Classes.java: Reworked handling of inner
classes.
(innerClasses): Field mustn't be null anymore when loaded.
(setName): Update class in classpath.
* net/sf/jode/bytecode/ClassPath.java:
(renameClassInfo): new function, should only used by ClassInfo.
* net/sf/jode/bytecode/ConstantPool.java: made public.
(getUTF8,getRef,getClassType,getClassName): Don't allow the 0 index.
(iterateClassNames): New method.
* net/sf/jode/decompiler/Main.java:
(decompileClass): Catch ClassFormatExceptions and decompile
remaining classes.
* net/sf/jode/obfuscator/ClassIdentifier.java:
Updated handling of inner/extra classes to new ClassInfo behaviour.
(initSuperClasses): Load DECLARATION of super classes.
* net/sf/jode/obfuscator/PackageIdentifier.java:
Replace deprecated methods of ClassInfo with corresponding classpath
calls.
(loadMatchingClasses): Initialize packages loaded on demand if we
are initialize.
* net/sf/jode/obfuscator/modules/ConstantAnalyzer.java:
Now extends SimpleAnalyzer.
(canonizeIfaceRef): Removed; it is now inherited.
(canonizeRef): likewise.
Big updates to handle jsr correctly.
(handleOpcode): Moved method to BlockInfo.
* net/sf/jode/obfuscator/modules/SimpleAnalyzer.java:
(canonizeIfaceRef): New method, copied from ConstantAnalyzer.
(canonizeRef): call canonizeIfaceRef for interfaces.
* net/sf/jode/util/UnifyHash.java
(iterateHashCode): iterator now supports remove().
(remove): New method.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1337 379699f6-c40d-0410-875b-85095c16579e
23 years ago
|
|
|
protected void readAttribute(String name, int length,
|
|
|
|
ConstantPool cp,
|
|
|
|
DataInputStream input,
|
|
|
|
int howMuch) throws IOException {
|
|
|
|
if (howMuch >= ClassInfo.DECLARATIONS
|
|
|
|
&& name.equals("ConstantValue")) {
|
|
|
|
if (length != 2)
|
|
|
|
throw new ClassFormatException
|
|
|
|
("ConstantValue attribute has wrong length");
|
|
|
|
int index = input.readUnsignedShort();
|
|
|
|
constant = cp.getConstant(index);
|
|
|
|
} else if (name.equals("Synthetic")) {
|
|
|
|
syntheticFlag = true;
|
|
|
|
if (length != 0)
|
|
|
|
throw new ClassFormatException
|
|
|
|
("Synthetic attribute has wrong length");
|
|
|
|
} else if (name.equals("Deprecated")) {
|
|
|
|
deprecatedFlag = true;
|
|
|
|
if (length != 0)
|
|
|
|
throw new ClassFormatException
|
|
|
|
("Deprecated attribute has wrong length");
|
|
|
|
} else if (name.equals("Signature")) {
|
|
|
|
signature = cp.getUTF8(input.readUnsignedShort());
|
|
|
|
} else
|
|
|
|
super.readAttribute(name, length, cp, input, howMuch);
|
|
|
|
}
|
* ConstantInstruction.java,IncInstruction.java,ReferenceInstruction.java,SlotInstruction.java,TypeDimensionInstruction.java,TypeInstruction.java: Class and Constructors no longer public.
* Instruction.java (forOpcode): added method to create instructions.
* SlotInstruction.java,IncInstruction.java: Use a LocalVariableInfo
entry instead of slot+addr
* BasicBlockReader.java, BasicBlockWriter.java: Adapted Instruction interface.
* BinaryInfo.java: package private class now.
* BinaryInfo.java,FieldInfo.java,MethodInfo.java: Made some methods
package private.
* BasicBlocks.java (getAllInstructions): removed.
(read,readAttribute): no longer protected.
* ClassInfo.java (isGuessed): added.
All classes: bug fixes, etc.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1266 379699f6-c40d-0410-875b-85095c16579e
24 years ago
|
|
|
|
|
|
|
void read(ConstantPool constantPool,
|
|
|
|
DataInputStream input, int howMuch) throws IOException {
|
|
|
|
modifier = input.readUnsignedShort();
|
|
|
|
name = constantPool.getUTF8(input.readUnsignedShort());
|
|
|
|
typeSig = constantPool.getUTF8(input.readUnsignedShort());
|
|
|
|
readAttributes(constantPool, input, howMuch);
|
|
|
|
}
|
|
|
|
|
* ConstantInstruction.java,IncInstruction.java,ReferenceInstruction.java,SlotInstruction.java,TypeDimensionInstruction.java,TypeInstruction.java: Class and Constructors no longer public.
* Instruction.java (forOpcode): added method to create instructions.
* SlotInstruction.java,IncInstruction.java: Use a LocalVariableInfo
entry instead of slot+addr
* BasicBlockReader.java, BasicBlockWriter.java: Adapted Instruction interface.
* BinaryInfo.java: package private class now.
* BinaryInfo.java,FieldInfo.java,MethodInfo.java: Made some methods
package private.
* BasicBlocks.java (getAllInstructions): removed.
(read,readAttribute): no longer protected.
* ClassInfo.java (isGuessed): added.
All classes: bug fixes, etc.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1266 379699f6-c40d-0410-875b-85095c16579e
24 years ago
|
|
|
void reserveSmallConstants(GrowableConstantPool gcp) {
|
|
|
|
}
|
|
|
|
|
* ConstantInstruction.java,IncInstruction.java,ReferenceInstruction.java,SlotInstruction.java,TypeDimensionInstruction.java,TypeInstruction.java: Class and Constructors no longer public.
* Instruction.java (forOpcode): added method to create instructions.
* SlotInstruction.java,IncInstruction.java: Use a LocalVariableInfo
entry instead of slot+addr
* BasicBlockReader.java, BasicBlockWriter.java: Adapted Instruction interface.
* BinaryInfo.java: package private class now.
* BinaryInfo.java,FieldInfo.java,MethodInfo.java: Made some methods
package private.
* BasicBlocks.java (getAllInstructions): removed.
(read,readAttribute): no longer protected.
* ClassInfo.java (isGuessed): added.
All classes: bug fixes, etc.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1266 379699f6-c40d-0410-875b-85095c16579e
24 years ago
|
|
|
void prepareWriting(GrowableConstantPool gcp) {
|
|
|
|
gcp.putUTF8(name);
|
|
|
|
gcp.putUTF8(typeSig);
|
|
|
|
if (constant != null) {
|
|
|
|
gcp.putUTF8("ConstantValue");
|
|
|
|
if (typeSig.charAt(0) == 'J' || typeSig.charAt(0) == 'D')
|
|
|
|
gcp.putLongConstant(constant);
|
|
|
|
else
|
|
|
|
gcp.putConstant(constant);
|
|
|
|
}
|
|
|
|
if (syntheticFlag)
|
|
|
|
gcp.putUTF8("Synthetic");
|
|
|
|
if (deprecatedFlag)
|
|
|
|
gcp.putUTF8("Deprecated");
|
|
|
|
prepareAttributes(gcp);
|
|
|
|
}
|
|
|
|
|
Documentation updates (INSTALL, javadoc).
Added JUnit Test cases.
* build.xml: Big update.
* net/sf/jode/bytecode/BasicBlock.java:
(updateMaxStackLocals): new method to calculate maxStack and
maxLocals.
(setBlocks): fixed calculation of handlers, call updateMaxLocals.
* net/sf/jode/bytecode/BasicBlockReader.java:
(maxLocals, maxStack): new fields.
(readCode): read maxStack/Locals into private fields.
(convert): check that maxStack/Locals match what we calculate.
* net/sf/jode/bytecode/BinaryInfo.java:
(getKnownAttributeCount): renamed to...
(getAttributeCount): ... this, and also count internal attributes.
Made it protected.
(readAttribute): made protected.
(drop): made protected.
(prepareAttributes): made protected.
(writeKnownAttributes): removed.
(writeAttributes): made protected, use getAttributeCount.
Changed policy: it doesn't call writeKnownAttribute, but instead
it expects sub classes to override this method.
(getAttributeSize): made protected, subclasses should override it.
Changed all subclasses to new policy.
* net/sf/jode/bytecode/Block.java:
(lineNr): Removed, it wasn't used.
(pop,push): Removed, replaced by ...
(maxpop,maxpush,delta): ... these, with slightly changed semantics.
(stackHeight): New variable.
(Block): Default Constructor doesn't initialize fields now.
(getCatchers): Renamed to ...
(getHandlers): ... this, changed all callers.
(initCode): Calculate maxpop, maxpush, delta correctly.
(getStackPopPush): Changed accordingly to new fields.
(setCode): Removed debugging output for illegal contents.
* net/sf/jode/bytecode/Classes.java: Reworked handling of inner
classes.
(innerClasses): Field mustn't be null anymore when loaded.
(setName): Update class in classpath.
* net/sf/jode/bytecode/ClassPath.java:
(renameClassInfo): new function, should only used by ClassInfo.
* net/sf/jode/bytecode/ConstantPool.java: made public.
(getUTF8,getRef,getClassType,getClassName): Don't allow the 0 index.
(iterateClassNames): New method.
* net/sf/jode/decompiler/Main.java:
(decompileClass): Catch ClassFormatExceptions and decompile
remaining classes.
* net/sf/jode/obfuscator/ClassIdentifier.java:
Updated handling of inner/extra classes to new ClassInfo behaviour.
(initSuperClasses): Load DECLARATION of super classes.
* net/sf/jode/obfuscator/PackageIdentifier.java:
Replace deprecated methods of ClassInfo with corresponding classpath
calls.
(loadMatchingClasses): Initialize packages loaded on demand if we
are initialize.
* net/sf/jode/obfuscator/modules/ConstantAnalyzer.java:
Now extends SimpleAnalyzer.
(canonizeIfaceRef): Removed; it is now inherited.
(canonizeRef): likewise.
Big updates to handle jsr correctly.
(handleOpcode): Moved method to BlockInfo.
* net/sf/jode/obfuscator/modules/SimpleAnalyzer.java:
(canonizeIfaceRef): New method, copied from ConstantAnalyzer.
(canonizeRef): call canonizeIfaceRef for interfaces.
* net/sf/jode/util/UnifyHash.java
(iterateHashCode): iterator now supports remove().
(remove): New method.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1337 379699f6-c40d-0410-875b-85095c16579e
23 years ago
|
|
|
protected int getAttributeCount() {
|
|
|
|
int count = super.getAttributeCount();
|
|
|
|
if (constant != null)
|
|
|
|
count++;
|
|
|
|
if (syntheticFlag)
|
|
|
|
count++;
|
|
|
|
if (deprecatedFlag)
|
|
|
|
count++;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
Documentation updates (INSTALL, javadoc).
Added JUnit Test cases.
* build.xml: Big update.
* net/sf/jode/bytecode/BasicBlock.java:
(updateMaxStackLocals): new method to calculate maxStack and
maxLocals.
(setBlocks): fixed calculation of handlers, call updateMaxLocals.
* net/sf/jode/bytecode/BasicBlockReader.java:
(maxLocals, maxStack): new fields.
(readCode): read maxStack/Locals into private fields.
(convert): check that maxStack/Locals match what we calculate.
* net/sf/jode/bytecode/BinaryInfo.java:
(getKnownAttributeCount): renamed to...
(getAttributeCount): ... this, and also count internal attributes.
Made it protected.
(readAttribute): made protected.
(drop): made protected.
(prepareAttributes): made protected.
(writeKnownAttributes): removed.
(writeAttributes): made protected, use getAttributeCount.
Changed policy: it doesn't call writeKnownAttribute, but instead
it expects sub classes to override this method.
(getAttributeSize): made protected, subclasses should override it.
Changed all subclasses to new policy.
* net/sf/jode/bytecode/Block.java:
(lineNr): Removed, it wasn't used.
(pop,push): Removed, replaced by ...
(maxpop,maxpush,delta): ... these, with slightly changed semantics.
(stackHeight): New variable.
(Block): Default Constructor doesn't initialize fields now.
(getCatchers): Renamed to ...
(getHandlers): ... this, changed all callers.
(initCode): Calculate maxpop, maxpush, delta correctly.
(getStackPopPush): Changed accordingly to new fields.
(setCode): Removed debugging output for illegal contents.
* net/sf/jode/bytecode/Classes.java: Reworked handling of inner
classes.
(innerClasses): Field mustn't be null anymore when loaded.
(setName): Update class in classpath.
* net/sf/jode/bytecode/ClassPath.java:
(renameClassInfo): new function, should only used by ClassInfo.
* net/sf/jode/bytecode/ConstantPool.java: made public.
(getUTF8,getRef,getClassType,getClassName): Don't allow the 0 index.
(iterateClassNames): New method.
* net/sf/jode/decompiler/Main.java:
(decompileClass): Catch ClassFormatExceptions and decompile
remaining classes.
* net/sf/jode/obfuscator/ClassIdentifier.java:
Updated handling of inner/extra classes to new ClassInfo behaviour.
(initSuperClasses): Load DECLARATION of super classes.
* net/sf/jode/obfuscator/PackageIdentifier.java:
Replace deprecated methods of ClassInfo with corresponding classpath
calls.
(loadMatchingClasses): Initialize packages loaded on demand if we
are initialize.
* net/sf/jode/obfuscator/modules/ConstantAnalyzer.java:
Now extends SimpleAnalyzer.
(canonizeIfaceRef): Removed; it is now inherited.
(canonizeRef): likewise.
Big updates to handle jsr correctly.
(handleOpcode): Moved method to BlockInfo.
* net/sf/jode/obfuscator/modules/SimpleAnalyzer.java:
(canonizeIfaceRef): New method, copied from ConstantAnalyzer.
(canonizeRef): call canonizeIfaceRef for interfaces.
* net/sf/jode/util/UnifyHash.java
(iterateHashCode): iterator now supports remove().
(remove): New method.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1337 379699f6-c40d-0410-875b-85095c16579e
23 years ago
|
|
|
protected void writeAttributes(GrowableConstantPool gcp,
|
|
|
|
DataOutputStream output)
|
|
|
|
throws IOException {
|
Documentation updates (INSTALL, javadoc).
Added JUnit Test cases.
* build.xml: Big update.
* net/sf/jode/bytecode/BasicBlock.java:
(updateMaxStackLocals): new method to calculate maxStack and
maxLocals.
(setBlocks): fixed calculation of handlers, call updateMaxLocals.
* net/sf/jode/bytecode/BasicBlockReader.java:
(maxLocals, maxStack): new fields.
(readCode): read maxStack/Locals into private fields.
(convert): check that maxStack/Locals match what we calculate.
* net/sf/jode/bytecode/BinaryInfo.java:
(getKnownAttributeCount): renamed to...
(getAttributeCount): ... this, and also count internal attributes.
Made it protected.
(readAttribute): made protected.
(drop): made protected.
(prepareAttributes): made protected.
(writeKnownAttributes): removed.
(writeAttributes): made protected, use getAttributeCount.
Changed policy: it doesn't call writeKnownAttribute, but instead
it expects sub classes to override this method.
(getAttributeSize): made protected, subclasses should override it.
Changed all subclasses to new policy.
* net/sf/jode/bytecode/Block.java:
(lineNr): Removed, it wasn't used.
(pop,push): Removed, replaced by ...
(maxpop,maxpush,delta): ... these, with slightly changed semantics.
(stackHeight): New variable.
(Block): Default Constructor doesn't initialize fields now.
(getCatchers): Renamed to ...
(getHandlers): ... this, changed all callers.
(initCode): Calculate maxpop, maxpush, delta correctly.
(getStackPopPush): Changed accordingly to new fields.
(setCode): Removed debugging output for illegal contents.
* net/sf/jode/bytecode/Classes.java: Reworked handling of inner
classes.
(innerClasses): Field mustn't be null anymore when loaded.
(setName): Update class in classpath.
* net/sf/jode/bytecode/ClassPath.java:
(renameClassInfo): new function, should only used by ClassInfo.
* net/sf/jode/bytecode/ConstantPool.java: made public.
(getUTF8,getRef,getClassType,getClassName): Don't allow the 0 index.
(iterateClassNames): New method.
* net/sf/jode/decompiler/Main.java:
(decompileClass): Catch ClassFormatExceptions and decompile
remaining classes.
* net/sf/jode/obfuscator/ClassIdentifier.java:
Updated handling of inner/extra classes to new ClassInfo behaviour.
(initSuperClasses): Load DECLARATION of super classes.
* net/sf/jode/obfuscator/PackageIdentifier.java:
Replace deprecated methods of ClassInfo with corresponding classpath
calls.
(loadMatchingClasses): Initialize packages loaded on demand if we
are initialize.
* net/sf/jode/obfuscator/modules/ConstantAnalyzer.java:
Now extends SimpleAnalyzer.
(canonizeIfaceRef): Removed; it is now inherited.
(canonizeRef): likewise.
Big updates to handle jsr correctly.
(handleOpcode): Moved method to BlockInfo.
* net/sf/jode/obfuscator/modules/SimpleAnalyzer.java:
(canonizeIfaceRef): New method, copied from ConstantAnalyzer.
(canonizeRef): call canonizeIfaceRef for interfaces.
* net/sf/jode/util/UnifyHash.java
(iterateHashCode): iterator now supports remove().
(remove): New method.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1337 379699f6-c40d-0410-875b-85095c16579e
23 years ago
|
|
|
super.writeAttributes(gcp, output);
|
|
|
|
if (constant != null) {
|
|
|
|
output.writeShort(gcp.putUTF8("ConstantValue"));
|
|
|
|
output.writeInt(2);
|
|
|
|
int index;
|
|
|
|
if (typeSig.charAt(0) == 'J'
|
|
|
|
|| typeSig.charAt(0) == 'D')
|
|
|
|
index = gcp.putLongConstant(constant);
|
|
|
|
else
|
|
|
|
index = gcp.putConstant(constant);
|
|
|
|
output.writeShort(index);
|
|
|
|
}
|
|
|
|
if (syntheticFlag) {
|
|
|
|
output.writeShort(gcp.putUTF8("Synthetic"));
|
|
|
|
output.writeInt(0);
|
|
|
|
}
|
|
|
|
if (deprecatedFlag) {
|
|
|
|
output.writeShort(gcp.putUTF8("Deprecated"));
|
|
|
|
output.writeInt(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* ConstantInstruction.java,IncInstruction.java,ReferenceInstruction.java,SlotInstruction.java,TypeDimensionInstruction.java,TypeInstruction.java: Class and Constructors no longer public.
* Instruction.java (forOpcode): added method to create instructions.
* SlotInstruction.java,IncInstruction.java: Use a LocalVariableInfo
entry instead of slot+addr
* BasicBlockReader.java, BasicBlockWriter.java: Adapted Instruction interface.
* BinaryInfo.java: package private class now.
* BinaryInfo.java,FieldInfo.java,MethodInfo.java: Made some methods
package private.
* BasicBlocks.java (getAllInstructions): removed.
(read,readAttribute): no longer protected.
* ClassInfo.java (isGuessed): added.
All classes: bug fixes, etc.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1266 379699f6-c40d-0410-875b-85095c16579e
24 years ago
|
|
|
void write(GrowableConstantPool constantPool,
|
|
|
|
DataOutputStream output) throws IOException {
|
|
|
|
output.writeShort(modifier);
|
|
|
|
output.writeShort(constantPool.putUTF8(name));
|
|
|
|
output.writeShort(constantPool.putUTF8(typeSig));
|
|
|
|
writeAttributes(constantPool, output);
|
|
|
|
}
|
|
|
|
|
Documentation updates (INSTALL, javadoc).
Added JUnit Test cases.
* build.xml: Big update.
* net/sf/jode/bytecode/BasicBlock.java:
(updateMaxStackLocals): new method to calculate maxStack and
maxLocals.
(setBlocks): fixed calculation of handlers, call updateMaxLocals.
* net/sf/jode/bytecode/BasicBlockReader.java:
(maxLocals, maxStack): new fields.
(readCode): read maxStack/Locals into private fields.
(convert): check that maxStack/Locals match what we calculate.
* net/sf/jode/bytecode/BinaryInfo.java:
(getKnownAttributeCount): renamed to...
(getAttributeCount): ... this, and also count internal attributes.
Made it protected.
(readAttribute): made protected.
(drop): made protected.
(prepareAttributes): made protected.
(writeKnownAttributes): removed.
(writeAttributes): made protected, use getAttributeCount.
Changed policy: it doesn't call writeKnownAttribute, but instead
it expects sub classes to override this method.
(getAttributeSize): made protected, subclasses should override it.
Changed all subclasses to new policy.
* net/sf/jode/bytecode/Block.java:
(lineNr): Removed, it wasn't used.
(pop,push): Removed, replaced by ...
(maxpop,maxpush,delta): ... these, with slightly changed semantics.
(stackHeight): New variable.
(Block): Default Constructor doesn't initialize fields now.
(getCatchers): Renamed to ...
(getHandlers): ... this, changed all callers.
(initCode): Calculate maxpop, maxpush, delta correctly.
(getStackPopPush): Changed accordingly to new fields.
(setCode): Removed debugging output for illegal contents.
* net/sf/jode/bytecode/Classes.java: Reworked handling of inner
classes.
(innerClasses): Field mustn't be null anymore when loaded.
(setName): Update class in classpath.
* net/sf/jode/bytecode/ClassPath.java:
(renameClassInfo): new function, should only used by ClassInfo.
* net/sf/jode/bytecode/ConstantPool.java: made public.
(getUTF8,getRef,getClassType,getClassName): Don't allow the 0 index.
(iterateClassNames): New method.
* net/sf/jode/decompiler/Main.java:
(decompileClass): Catch ClassFormatExceptions and decompile
remaining classes.
* net/sf/jode/obfuscator/ClassIdentifier.java:
Updated handling of inner/extra classes to new ClassInfo behaviour.
(initSuperClasses): Load DECLARATION of super classes.
* net/sf/jode/obfuscator/PackageIdentifier.java:
Replace deprecated methods of ClassInfo with corresponding classpath
calls.
(loadMatchingClasses): Initialize packages loaded on demand if we
are initialize.
* net/sf/jode/obfuscator/modules/ConstantAnalyzer.java:
Now extends SimpleAnalyzer.
(canonizeIfaceRef): Removed; it is now inherited.
(canonizeRef): likewise.
Big updates to handle jsr correctly.
(handleOpcode): Moved method to BlockInfo.
* net/sf/jode/obfuscator/modules/SimpleAnalyzer.java:
(canonizeIfaceRef): New method, copied from ConstantAnalyzer.
(canonizeRef): call canonizeIfaceRef for interfaces.
* net/sf/jode/util/UnifyHash.java
(iterateHashCode): iterator now supports remove().
(remove): New method.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1337 379699f6-c40d-0410-875b-85095c16579e
23 years ago
|
|
|
protected void drop(int keep) {
|
* ConstantInstruction.java,IncInstruction.java,ReferenceInstruction.java,SlotInstruction.java,TypeDimensionInstruction.java,TypeInstruction.java: Class and Constructors no longer public.
* Instruction.java (forOpcode): added method to create instructions.
* SlotInstruction.java,IncInstruction.java: Use a LocalVariableInfo
entry instead of slot+addr
* BasicBlockReader.java, BasicBlockWriter.java: Adapted Instruction interface.
* BinaryInfo.java: package private class now.
* BinaryInfo.java,FieldInfo.java,MethodInfo.java: Made some methods
package private.
* BasicBlocks.java (getAllInstructions): removed.
(read,readAttribute): no longer protected.
* ClassInfo.java (isGuessed): added.
All classes: bug fixes, etc.
git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1266 379699f6-c40d-0410-875b-85095c16579e
24 years ago
|
|
|
if (keep < ClassInfo.DECLARATIONS)
|
|
|
|
constant = null;
|
|
|
|
super.drop(keep);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the name of the field.
|
|
|
|
* @return the name.
|
|
|
|
*/
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the type signature of the field.
|
|
|
|
* @return the type signature.
|
|
|
|
* @see TypeSignature
|
|
|
|
*/
|
|
|
|
public String getType() {
|
|
|
|
return typeSig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the modifier of the field.
|
|
|
|
* @return the modifiers.
|
|
|
|
* @see Modifier
|
|
|
|
*/
|
|
|
|
public int getModifiers() {
|
|
|
|
return modifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells whether this field is synthetic.
|
|
|
|
* @return true if the field is synthetic.
|
|
|
|
*/
|
|
|
|
public boolean isSynthetic() {
|
|
|
|
return syntheticFlag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells whether this field is deprecated.
|
|
|
|
* @return true if the field is deprecated.
|
|
|
|
*/
|
|
|
|
public boolean isDeprecated() {
|
|
|
|
return deprecatedFlag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the constant value of the field. For static final fields
|
|
|
|
* that have a simple String, int, float, double or long constant,
|
|
|
|
* this returns the corresponding constant as String, Integer, Float
|
|
|
|
* Double or long. For other fields it returns null.
|
|
|
|
* @return The constant, or null.
|
|
|
|
*/
|
|
|
|
public Object getConstant() {
|
|
|
|
return constant;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the name of the field.
|
|
|
|
* @param newName the name.
|
|
|
|
*/
|
|
|
|
public void setName(String newName) {
|
|
|
|
name = newName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the type signature of the field.
|
|
|
|
* @param newType the type signature.
|
|
|
|
* @see TypeSignature
|
|
|
|
*/
|
|
|
|
public void setType(String newType) {
|
|
|
|
typeSig = newType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the modifier of the field.
|
|
|
|
* @param newModifier the modifiers.
|
|
|
|
* @see Modifier
|
|
|
|
*/
|
|
|
|
public void setModifiers(int newModifier) {
|
|
|
|
modifier = newModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSynthetic(boolean flag) {
|
|
|
|
syntheticFlag = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDeprecated(boolean flag) {
|
|
|
|
deprecatedFlag = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setConstant(Object newConstant) {
|
|
|
|
constant = newConstant;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compares two FieldInfo objects for field order. The field
|
|
|
|
* order is as follows: First the static class intializer followed
|
|
|
|
* by constructor with type signature sorted lexicographic. Then
|
|
|
|
* all other fields sorted lexicographically by name. If two
|
|
|
|
* fields have the same name, they are sorted by type signature,
|
|
|
|
* though that can only happen for obfuscated code.
|
|
|
|
*
|
|
|
|
* @return a positive number if this field follows the other in
|
|
|
|
* field order, a negative number if it preceeds the
|
|
|
|
* other, and 0 if they are equal.
|
|
|
|
* @exception ClassCastException if other is not a ClassInfo. */
|
|
|
|
public int compareTo(Object other) {
|
|
|
|
FieldInfo fi = (FieldInfo) other;
|
|
|
|
int result = name.compareTo(fi.name);
|
|
|
|
if (result == 0)
|
|
|
|
result = typeSig.compareTo(fi.typeSig);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
return "Field "+Modifier.toString(modifier)+" "+
|
|
|
|
typeSig+" "+name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|