add @Overrides annotations and nuke unnecessary casts
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1198 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
fdb7a17af3
commit
60058dec8b
|
@ -1,4 +1,4 @@
|
|||
#Mon May 07 09:26:20 EDT 2007
|
||||
#Wed May 30 11:25:52 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
|
@ -28,7 +28,7 @@ org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
|||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
|
@ -47,7 +47,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
|
|
|
@ -83,6 +83,7 @@ public class AddBytecodeDebug {
|
|||
if (!putDumperAt[offset]) {
|
||||
putDumperAt[offset] = true;
|
||||
me.insertBefore(offset, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(DupInstruction.make(0));
|
||||
w.emit(Util.makeInvoke(Throwable.class, "printStackTrace", new Class[0]));
|
||||
|
|
|
@ -122,6 +122,7 @@ public class Bench {
|
|||
+ ci.getReader().getMethodName(m);
|
||||
final int noTraceLabel = me.allocateLabel();
|
||||
me.insertAtStart(new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(MethodEditor.Output w) {
|
||||
w.emit(GetInstruction.make(Constants.TYPE_boolean, CTDecoder.convertClassToType(className), fieldName, true));
|
||||
w.emit(ConstantInstruction.make(0));
|
||||
|
@ -141,6 +142,7 @@ public class Bench {
|
|||
if (instr[i] instanceof ReturnInstruction) {
|
||||
final int noTraceLabel = me.allocateLabel();
|
||||
me.insertBefore(i, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(MethodEditor.Output w) {
|
||||
w.emit(GetInstruction.make(Constants.TYPE_boolean, CTDecoder.convertClassToType(className), fieldName, true));
|
||||
w.emit(ConstantInstruction.make(0));
|
||||
|
@ -159,6 +161,7 @@ public class Bench {
|
|||
+ ci.getReader().getMethodName(m);
|
||||
final int noTraceLabel = me.allocateLabel();
|
||||
me.addMethodExceptionHandler(null, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(GetInstruction.make(Constants.TYPE_boolean, CTDecoder.convertClassToType(className), fieldName, true));
|
||||
w.emit(ConstantInstruction.make(0));
|
||||
|
|
|
@ -121,14 +121,17 @@ public class Mangler {
|
|||
me.beginPass();
|
||||
|
||||
me.visitInstructions(new MethodEditor.Visitor() {
|
||||
@Override
|
||||
public void visitGet(GetInstruction instruction) {
|
||||
if (doGet && !instruction.isStatic()) {
|
||||
insertBefore(new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(DupInstruction.make(0));
|
||||
}
|
||||
});
|
||||
insertAfter(new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(SwapInstruction.make());
|
||||
w.emit(Util.makePut(Slots.class, "o"));
|
||||
|
@ -137,9 +140,11 @@ public class Mangler {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPut(PutInstruction instruction) {
|
||||
if (doPut && !instruction.isStatic()) {
|
||||
insertBefore(new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(SwapInstruction.make());
|
||||
w.emit(DupInstruction.make(1));
|
||||
|
@ -147,6 +152,7 @@ public class Mangler {
|
|||
}
|
||||
});
|
||||
insertAfter(new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(Util.makePut(Slots.class, "o"));
|
||||
}
|
||||
|
@ -154,10 +160,12 @@ public class Mangler {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayStore(final ArrayStoreInstruction instruction) {
|
||||
if (doArrayStore) {
|
||||
final int label = me.allocateLabel();
|
||||
insertBefore(new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
String t = Util.getStackType(instruction.getType());
|
||||
w.emit(StoreInstruction.make(t, tmpAny));
|
||||
|
@ -176,6 +184,7 @@ public class Mangler {
|
|||
}
|
||||
});
|
||||
insertAfter(new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(Util.makePut(Slots.class, "o"));
|
||||
w.emit(LoadInstruction.make(Constants.TYPE_int, tmpInt));
|
||||
|
|
|
@ -24,30 +24,37 @@ final public class ArrayLengthInstruction extends Instruction {
|
|||
return preallocated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ArrayLengthInstruction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 3180901;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return Constants.TYPE_int;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitArrayLength(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ArrayLength()";
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ final public class ArrayLoadInstruction extends Instruction {
|
|||
return preallocated[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ArrayLoadInstruction) {
|
||||
ArrayLoadInstruction i = (ArrayLoadInstruction) o;
|
||||
|
@ -46,18 +47,22 @@ final public class ArrayLoadInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode + 9109101;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ArrayLoad(" + getType() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
if (types == null) {
|
||||
return getType();
|
||||
|
@ -73,6 +78,7 @@ final public class ArrayLoadInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return Util.getWordSize(getType());
|
||||
}
|
||||
|
@ -81,6 +87,7 @@ final public class ArrayLoadInstruction extends Instruction {
|
|||
return Constants.indexedTypes[opcode - OP_iaload];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitArrayLoad(this);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ final public class ArrayStoreInstruction extends Instruction {
|
|||
return preallocated[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ArrayStoreInstruction) {
|
||||
ArrayStoreInstruction i = (ArrayStoreInstruction) o;
|
||||
|
@ -46,10 +47,12 @@ final public class ArrayStoreInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode + 148791;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 3;
|
||||
}
|
||||
|
@ -58,10 +61,12 @@ final public class ArrayStoreInstruction extends Instruction {
|
|||
return Decoder.indexedTypes[opcode - OP_iastore];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ArrayStore(" + getType() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitArrayStore(this);
|
||||
}
|
||||
|
|
|
@ -15,14 +15,22 @@ package com.ibm.wala.shrikeBT;
|
|||
* the result all have the same type.
|
||||
*/
|
||||
final public class BinaryOpInstruction extends Instruction {
|
||||
public interface IOperator {}
|
||||
|
||||
public interface IOperator {
|
||||
}
|
||||
|
||||
public enum Operator implements IOperator {
|
||||
ADD, SUB, MUL, DIV, REM, AND, OR, XOR;
|
||||
ADD,
|
||||
SUB,
|
||||
MUL,
|
||||
DIV,
|
||||
REM,
|
||||
AND,
|
||||
OR,
|
||||
XOR;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase();
|
||||
return super.toString().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +39,7 @@ final public class BinaryOpInstruction extends Instruction {
|
|||
}
|
||||
|
||||
private final static BinaryOpInstruction[] arithmeticOps = preallocateArithmeticOps();
|
||||
|
||||
private final static BinaryOpInstruction[] logicalOps = preallocateLogicalOps();
|
||||
|
||||
private static BinaryOpInstruction[] preallocateArithmeticOps() {
|
||||
|
@ -71,6 +80,7 @@ final public class BinaryOpInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof BinaryOpInstruction) {
|
||||
BinaryOpInstruction i = (BinaryOpInstruction) o;
|
||||
|
@ -91,18 +101,22 @@ final public class BinaryOpInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode + 13901901;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return Util.getWordSize(getType());
|
||||
}
|
||||
|
@ -117,17 +131,22 @@ final public class BinaryOpInstruction extends Instruction {
|
|||
return indexedTypes[t];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitBinaryOp(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BinaryOp(" + getType() + "," + getOperator() + ")";
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.ibm.domo.cfg.IInstruction#isPEI()
|
||||
*/
|
||||
public boolean isPEI() {
|
||||
return opcode == Constants.OP_idiv;
|
||||
return opcode == Constants.OP_idiv;
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ final public class CheckCastInstruction extends Instruction {
|
|||
return new CheckCastInstruction(type.intern());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof CheckCastInstruction) {
|
||||
CheckCastInstruction i = (CheckCastInstruction) o;
|
||||
|
@ -37,10 +38,12 @@ final public class CheckCastInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 131111 + type.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -52,14 +55,17 @@ final public class CheckCastInstruction extends Instruction {
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) {
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -67,6 +73,7 @@ final public class CheckCastInstruction extends Instruction {
|
|||
v.visitCheckCast(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CheckCast(" + type + ")";
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ final public class ComparisonInstruction extends Instruction {
|
|||
this.opcode = opcode;
|
||||
}
|
||||
|
||||
private final static ComparisonInstruction preallocatedLCMP = new ComparisonInstruction((short) OP_lcmp);
|
||||
private final static ComparisonInstruction preallocatedLCMP = new ComparisonInstruction(OP_lcmp);
|
||||
|
||||
private final static ComparisonInstruction[] preallocatedFloatingCompares = preallocateFloatingCompares();
|
||||
|
||||
|
@ -62,6 +62,7 @@ final public class ComparisonInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ComparisonInstruction) {
|
||||
ComparisonInstruction i = (ComparisonInstruction) o;
|
||||
|
@ -104,26 +105,32 @@ final public class ComparisonInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode + 1391901;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return Constants.TYPE_boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitComparison(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Comparison(" + getType() + "," + getOperator() + ")";
|
||||
}
|
||||
|
|
|
@ -190,10 +190,12 @@ public abstract class Compiler implements Constants {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitGoto(GotoInstruction instruction) {
|
||||
visitTargets(instruction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalStore(StoreInstruction instruction) {
|
||||
localsUsed.set(instruction.getVarIndex());
|
||||
String t = instruction.getType();
|
||||
|
@ -202,10 +204,12 @@ public abstract class Compiler implements Constants {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConditionalBranch(ConditionalBranchInstruction instruction) {
|
||||
visitTargets(instruction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwitch(SwitchInstruction instruction) {
|
||||
visitTargets(instruction);
|
||||
}
|
||||
|
@ -365,7 +369,7 @@ public abstract class Compiler implements Constants {
|
|||
+ ")");
|
||||
}
|
||||
if (!visited[t]) {
|
||||
computeStackWordsAt(bt[j], stackLen, (byte[]) stackWords.clone(), visited);
|
||||
computeStackWordsAt(bt[j], stackLen, stackWords.clone(), visited);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,7 +377,7 @@ public abstract class Compiler implements Constants {
|
|||
for (int j = 0; j < hs.length; j++) {
|
||||
int t = hs[j].handler;
|
||||
if (!visited[t]) {
|
||||
byte[] newWords = (byte[]) stackWords.clone();
|
||||
byte[] newWords = stackWords.clone();
|
||||
newWords[0] = 1;
|
||||
computeStackWordsAt(t, 1, newWords, visited);
|
||||
}
|
||||
|
@ -415,6 +419,7 @@ public abstract class Compiler implements Constants {
|
|||
super(instrStart, instrOffset, targetLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean apply() {
|
||||
int delta = instructionsToOffsets[targetLabel] - instrStart;
|
||||
if ((short) delta == delta) {
|
||||
|
@ -431,6 +436,7 @@ public abstract class Compiler implements Constants {
|
|||
super(instrStart, instrOffset, targetLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean apply() {
|
||||
writeInt(instrOffset, instructionsToOffsets[targetLabel] - instrStart);
|
||||
return true;
|
||||
|
@ -489,6 +495,7 @@ public abstract class Compiler implements Constants {
|
|||
final int[] instrRef = new int[1];
|
||||
|
||||
Instruction.Visitor noOpcodeHandler = new Instruction.Visitor() {
|
||||
@Override
|
||||
public void visitPop(PopInstruction instruction) {
|
||||
int count = instruction.getPoppedCount();
|
||||
int offset = curOffsetRef[0];
|
||||
|
@ -504,6 +511,7 @@ public abstract class Compiler implements Constants {
|
|||
curOffsetRef[0] = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDup(DupInstruction instruction) {
|
||||
int size = instruction.getSize();
|
||||
int delta = instruction.getDelta();
|
||||
|
@ -527,6 +535,7 @@ public abstract class Compiler implements Constants {
|
|||
curOffsetRef[0] = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwap(SwapInstruction instruction) {
|
||||
int offset = curOffsetRef[0];
|
||||
int stackLen = stackLenRef[0];
|
||||
|
@ -1538,7 +1547,7 @@ public abstract class Compiler implements Constants {
|
|||
}
|
||||
|
||||
// make sure at most one local is defined and live on exit
|
||||
BitSet liveAtEnd = (BitSet) liveLocals[start + len];
|
||||
BitSet liveAtEnd = liveLocals[start + len];
|
||||
boolean multipleDefs = false;
|
||||
int localDefed = -1;
|
||||
int firstDef = -1;
|
||||
|
|
|
@ -70,6 +70,7 @@ public final class ConditionalBranchInstruction extends Instruction {
|
|||
return new ConditionalBranchInstruction(opcode, label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ConditionalBranchInstruction) {
|
||||
ConditionalBranchInstruction i = (ConditionalBranchInstruction) o;
|
||||
|
@ -79,10 +80,12 @@ public final class ConditionalBranchInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConditionalBranch(" + getType() + "," + getOperator() + "," + label + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getBranchTargets() {
|
||||
int[] r = { label };
|
||||
return r;
|
||||
|
@ -92,6 +95,7 @@ public final class ConditionalBranchInstruction extends Instruction {
|
|||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction redirectTargets(int[] targetMap) throws IllegalArgumentException {
|
||||
if (targetMap == null) {
|
||||
throw new IllegalArgumentException("targetMap is null");
|
||||
|
@ -115,10 +119,12 @@ public final class ConditionalBranchInstruction extends Instruction {
|
|||
return opcode < OP_if_acmpeq ? TYPE_int : TYPE_Object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 30190 * opcode + 384101 * label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
// Xiangyu, to support if_eq (if_ne)...
|
||||
if (opcode >= Constants.OP_ifeq && opcode <= Constants.OP_ifle)
|
||||
|
@ -126,6 +132,7 @@ public final class ConditionalBranchInstruction extends Instruction {
|
|||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitConditionalBranch(this);
|
||||
}
|
||||
|
|
|
@ -36,10 +36,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return preallocated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return TYPE_null;
|
||||
}
|
||||
|
@ -76,10 +78,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public Object getValue() {
|
||||
return new Integer(getIntValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getType() {
|
||||
return TYPE_int;
|
||||
}
|
||||
|
@ -101,6 +105,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
this.isSet = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntValue() {
|
||||
if (!isSet) {
|
||||
value = cp.getConstantPoolInteger(index);
|
||||
|
@ -109,10 +114,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCPIndex() {
|
||||
return index;
|
||||
}
|
||||
|
@ -141,10 +148,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public Object getValue() {
|
||||
return new Long(getLongValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getType() {
|
||||
return TYPE_long;
|
||||
}
|
||||
|
@ -166,6 +175,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
this.isSet = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLongValue() {
|
||||
if (!isSet) {
|
||||
value = cp.getConstantPoolLong(index);
|
||||
|
@ -174,10 +184,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCPIndex() {
|
||||
return index;
|
||||
}
|
||||
|
@ -206,10 +218,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public Object getValue() {
|
||||
return new Float(getFloatValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getType() {
|
||||
return TYPE_float;
|
||||
}
|
||||
|
@ -231,6 +245,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
this.isSet = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloatValue() {
|
||||
if (!isSet) {
|
||||
value = cp.getConstantPoolFloat(index);
|
||||
|
@ -239,10 +254,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCPIndex() {
|
||||
return index;
|
||||
}
|
||||
|
@ -271,10 +288,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public Object getValue() {
|
||||
return new Double(getDoubleValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getType() {
|
||||
return TYPE_double;
|
||||
}
|
||||
|
@ -296,6 +315,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
this.isSet = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDoubleValue() {
|
||||
if (!isSet) {
|
||||
value = cp.getConstantPoolDouble(index);
|
||||
|
@ -304,10 +324,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCPIndex() {
|
||||
return index;
|
||||
}
|
||||
|
@ -325,10 +347,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return new ConstString(OP_ldc_w, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getType() {
|
||||
return TYPE_String;
|
||||
}
|
||||
|
@ -344,6 +368,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
if (value == null) {
|
||||
value = cp.getConstantPoolString(index);
|
||||
|
@ -351,10 +376,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCPIndex() {
|
||||
return index;
|
||||
}
|
||||
|
@ -372,10 +399,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return new ConstClass(OP_ldc_w, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getType() {
|
||||
return TYPE_Class;
|
||||
}
|
||||
|
@ -391,6 +420,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
if (typeName == null) {
|
||||
typeName = cp.getConstantPoolClassType(index);
|
||||
|
@ -398,10 +428,12 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
return typeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCPIndex() {
|
||||
return index;
|
||||
}
|
||||
|
@ -462,7 +494,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
}
|
||||
|
||||
public static ConstantInstruction makeClass(String s) {
|
||||
return (ConstantInstruction) ConstClass.makeInternal(s);
|
||||
return ConstClass.makeInternal(s);
|
||||
}
|
||||
|
||||
static ConstantInstruction make(ConstantPoolReader cp, int index) {
|
||||
|
@ -484,6 +516,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean equals(Object o) {
|
||||
if (o instanceof ConstantInstruction) {
|
||||
ConstantInstruction i = (ConstantInstruction) o;
|
||||
|
@ -493,18 +526,22 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getPushedType(String[] types) {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
final public byte getPushedWordSize() {
|
||||
return Util.getWordSize(getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int hashCode() {
|
||||
return getType().hashCode() + 14411 * getValue().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitConstant(this);
|
||||
}
|
||||
|
@ -540,6 +577,7 @@ public abstract class ConstantInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String toString() {
|
||||
return "Constant(" + getType() + "," + quote(getValue()) + ")";
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package com.ibm.wala.shrikeBT;
|
|||
*/
|
||||
public final class ConversionInstruction extends Instruction {
|
||||
private String fromType;
|
||||
|
||||
private String toType;
|
||||
|
||||
protected ConversionInstruction(short opcode) {
|
||||
|
@ -64,6 +65,7 @@ public final class ConversionInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -80,14 +82,17 @@ public final class ConversionInstruction extends Instruction {
|
|||
return toType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return getToType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return Util.getWordSize(getToType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ConversionInstruction) {
|
||||
ConversionInstruction i = (ConversionInstruction) o;
|
||||
|
@ -97,21 +102,27 @@ public final class ConversionInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode * 143111;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Conversion(" + getFromType() + "," + getToType() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitConversion(this);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.domo.cfg.IInstruction#isPEI()
|
||||
*/
|
||||
public boolean isPEI() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.ibm.domo.cfg.IInstruction#isPEI()
|
||||
*/
|
||||
public boolean isPEI() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -371,7 +371,7 @@ public abstract class Decoder implements Constants {
|
|||
if (retAddr > 0) {
|
||||
RetInfo r = retInfo[retAddr];
|
||||
r.sub = subAddr;
|
||||
decodeAt(retToAddr, r.stackLen, (byte[]) r.stackWords.clone());
|
||||
decodeAt(retToAddr, r.stackLen, r.stackWords.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -743,7 +743,7 @@ public abstract class Decoder implements Constants {
|
|||
int t = targets[i];
|
||||
|
||||
if (t >= 0) {
|
||||
decodeAt(t, stackLen, (byte[]) stackWords.clone());
|
||||
decodeAt(t, stackLen, stackWords.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -874,7 +874,7 @@ public abstract class Decoder implements Constants {
|
|||
newCodeIndex++;
|
||||
|
||||
int subStart = newCodeIndex;
|
||||
int[] map = (int[]) callerMap.clone();
|
||||
int[] map = callerMap.clone();
|
||||
int sub = JSRs[callSite];
|
||||
|
||||
// emit the subroutine code
|
||||
|
|
|
@ -65,6 +65,7 @@ public final class DupInstruction extends Instruction {
|
|||
return make(1, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof DupInstruction) {
|
||||
DupInstruction i = (DupInstruction) o;
|
||||
|
@ -82,18 +83,22 @@ public final class DupInstruction extends Instruction {
|
|||
return delta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return size + 8431890 + 10 * delta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return size + delta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Dup(" + size + "," + delta + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) {
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException("illegal null visitor");
|
||||
|
|
|
@ -73,10 +73,12 @@ final public class ExceptionHandler {
|
|||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 1069 * handler + ((catchClass == null) ? 0 : catchClass.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ExceptionHandler) {
|
||||
return equals((ExceptionHandler) o);
|
||||
|
|
|
@ -39,6 +39,7 @@ public class GetInstruction extends Instruction {
|
|||
this.cp = cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
@ -47,6 +48,7 @@ public class GetInstruction extends Instruction {
|
|||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassType() {
|
||||
if (classType == null) {
|
||||
classType = cp.getConstantPoolMemberClassType(index);
|
||||
|
@ -54,6 +56,7 @@ public class GetInstruction extends Instruction {
|
|||
return classType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFieldName() {
|
||||
if (fieldName == null) {
|
||||
fieldName = cp.getConstantPoolMemberName(index);
|
||||
|
@ -61,6 +64,7 @@ public class GetInstruction extends Instruction {
|
|||
return fieldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFieldType() {
|
||||
if (type == null) {
|
||||
type = cp.getConstantPoolMemberType(index);
|
||||
|
@ -86,6 +90,7 @@ public class GetInstruction extends Instruction {
|
|||
return new GetInstruction(isStatic ? OP_getstatic : OP_getfield, type, className, fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean equals(Object o) {
|
||||
if (o instanceof GetInstruction) {
|
||||
GetInstruction i = (GetInstruction) o;
|
||||
|
@ -112,27 +117,33 @@ public class GetInstruction extends Instruction {
|
|||
return opcode == OP_getstatic;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int hashCode() {
|
||||
return getClassType().hashCode() + 11113 * getFieldType().hashCode() + 398011 * getFieldName().hashCode() + opcode;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int getPoppedCount() {
|
||||
return isStatic() ? 0 : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getPushedType(String[] types) {
|
||||
return getFieldType();
|
||||
}
|
||||
|
||||
@Override
|
||||
final public byte getPushedWordSize() {
|
||||
return Util.getWordSize(getFieldType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Get(" + getFieldType() + "," + (isStatic() ? "STATIC" : "NONSTATIC") + "," + getClassType() + "," + getFieldName()
|
||||
+ ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws IllegalArgumentException {
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
|
|
@ -40,10 +40,12 @@ public final class GotoInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFallThrough() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getBranchTargets() {
|
||||
return label;
|
||||
}
|
||||
|
@ -57,6 +59,7 @@ public final class GotoInstruction extends Instruction {
|
|||
*
|
||||
* @see com.ibm.wala.shrikeBT.Instruction#redirectTargets(int[])
|
||||
*/
|
||||
@Override
|
||||
public Instruction redirectTargets(int[] targetMap) throws IllegalArgumentException {
|
||||
if (targetMap == null) {
|
||||
throw new IllegalArgumentException("targetMap is null");
|
||||
|
@ -68,6 +71,7 @@ public final class GotoInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof GotoInstruction) {
|
||||
GotoInstruction i = (GotoInstruction) o;
|
||||
|
@ -77,14 +81,17 @@ public final class GotoInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return label[0] * 1348091 + 18301;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Goto(" + getLabel() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws IllegalArgumentException {
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
|
|
@ -25,6 +25,7 @@ public final class InstanceofInstruction extends Instruction {
|
|||
return new InstanceofInstruction(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof InstanceofInstruction) {
|
||||
InstanceofInstruction i = (InstanceofInstruction) o;
|
||||
|
@ -34,10 +35,12 @@ public final class InstanceofInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31980190 + type.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -46,14 +49,17 @@ public final class InstanceofInstruction extends Instruction {
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return TYPE_boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws IllegalArgumentException{
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -61,6 +67,7 @@ public final class InstanceofInstruction extends Instruction {
|
|||
v.visitInstanceof(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Instanceof(" + type + ")";
|
||||
}
|
||||
|
|
|
@ -128,11 +128,13 @@ public abstract class Instruction implements Constants, Cloneable, IInstruction
|
|||
/**
|
||||
* Subclasses must implement toString.
|
||||
*/
|
||||
@Override
|
||||
public abstract String toString();
|
||||
|
||||
/**
|
||||
* We're immutable so there's no need to clone any Instruction object.
|
||||
*/
|
||||
@Override
|
||||
final public Object clone() {
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class InvokeInstruction extends Instruction implements IInvokeInstruction
|
|||
this.cp = cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
@ -63,6 +64,7 @@ public class InvokeInstruction extends Instruction implements IInvokeInstruction
|
|||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassType() {
|
||||
if (classType == null) {
|
||||
classType = cp.getConstantPoolMemberClassType(index);
|
||||
|
@ -70,6 +72,7 @@ public class InvokeInstruction extends Instruction implements IInvokeInstruction
|
|||
return classType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodName() {
|
||||
if (methodName == null) {
|
||||
methodName = cp.getConstantPoolMemberName(index);
|
||||
|
@ -77,6 +80,7 @@ public class InvokeInstruction extends Instruction implements IInvokeInstruction
|
|||
return methodName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodSignature() {
|
||||
if (type == null) {
|
||||
type = cp.getConstantPoolMemberType(index);
|
||||
|
@ -92,6 +96,7 @@ public class InvokeInstruction extends Instruction implements IInvokeInstruction
|
|||
return new Lazy((short) mode, cp, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean equals(Object o) {
|
||||
if (o instanceof InvokeInstruction) {
|
||||
InvokeInstruction i = (InvokeInstruction) o;
|
||||
|
@ -133,14 +138,17 @@ public class InvokeInstruction extends Instruction implements IInvokeInstruction
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int hashCode() {
|
||||
return getMethodSignature().hashCode() + 9011 * getClassType().hashCode() + 317 * getMethodName().hashCode() + opcode * 3188;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int getPoppedCount() {
|
||||
return (opcode == Constants.OP_invokestatic ? 0 : 1) + Util.getParamsCount(getMethodSignature());
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getPushedType(String[] types) {
|
||||
String t = Util.getReturnType(getMethodSignature());
|
||||
if (t.equals(Constants.TYPE_void)) {
|
||||
|
@ -150,16 +158,19 @@ public class InvokeInstruction extends Instruction implements IInvokeInstruction
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public byte getPushedWordSize() {
|
||||
String t = getMethodSignature();
|
||||
int index = t.lastIndexOf(')');
|
||||
return Util.getWordSize(t, index + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitInvoke(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String toString() {
|
||||
return "Invoke(" + getInvocationModeString() + "," + getClassType() + "," + getMethodName() + "," + getMethodSignature() + ")";
|
||||
}
|
||||
|
|
|
@ -63,18 +63,22 @@ public final class LoadInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return Util.getWordSize(getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitLocalLoad(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof LoadInstruction) {
|
||||
LoadInstruction i = (LoadInstruction) o;
|
||||
|
@ -84,10 +88,12 @@ public final class LoadInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode + index * 19801901;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LocalLoad(" + getType() + "," + index + ")";
|
||||
}
|
||||
|
|
|
@ -238,6 +238,7 @@ public final class MethodData {
|
|||
return hasChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClassType() + "." + getName() + getSignature();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public final class MonitorInstruction extends Instruction {
|
|||
return entering ? enter : exit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof MonitorInstruction) {
|
||||
MonitorInstruction i = (MonitorInstruction) o;
|
||||
|
@ -38,14 +39,17 @@ public final class MonitorInstruction extends Instruction {
|
|||
return opcode == OP_monitorenter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode + 1911;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws IllegalArgumentException{
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -53,6 +57,7 @@ public final class MonitorInstruction extends Instruction {
|
|||
v.visitMonitor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Monitor(" + (isEnter() ? "ENTER" : "EXIT") + ")";
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ public final class NewInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof NewInstruction) {
|
||||
NewInstruction i = (NewInstruction) o;
|
||||
|
@ -78,18 +79,22 @@ public final class NewInstruction extends Instruction {
|
|||
return arrayBoundsCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 13111143 * type.hashCode() + arrayBoundsCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return arrayBoundsCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -98,10 +103,12 @@ public final class NewInstruction extends Instruction {
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "New(" + type + "," + arrayBoundsCount + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws IllegalArgumentException {
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
|
|
@ -32,6 +32,7 @@ public final class PopInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof PopInstruction) {
|
||||
PopInstruction i = (PopInstruction) o;
|
||||
|
@ -41,14 +42,17 @@ public final class PopInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return size + 8431890;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws IllegalArgumentException {
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -56,6 +60,7 @@ public final class PopInstruction extends Instruction {
|
|||
v.visitPop(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pop(" + size + ")";
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public class PutInstruction extends Instruction {
|
|||
this.cp = cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
ConstantPoolReader getLazyConstantPool() {
|
||||
return cp;
|
||||
}
|
||||
|
@ -47,6 +48,7 @@ public class PutInstruction extends Instruction {
|
|||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassType() {
|
||||
if (classType == null) {
|
||||
classType = cp.getConstantPoolMemberClassType(index);
|
||||
|
@ -54,6 +56,7 @@ public class PutInstruction extends Instruction {
|
|||
return classType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFieldName() {
|
||||
if (fieldName == null) {
|
||||
fieldName = cp.getConstantPoolMemberName(index);
|
||||
|
@ -61,6 +64,7 @@ public class PutInstruction extends Instruction {
|
|||
return fieldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFieldType() {
|
||||
if (type == null) {
|
||||
type = cp.getConstantPoolMemberType(index);
|
||||
|
@ -86,6 +90,7 @@ public class PutInstruction extends Instruction {
|
|||
return new PutInstruction(isStatic ? OP_putstatic : OP_putfield, type, className, fieldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean equals(Object o) {
|
||||
if (o instanceof PutInstruction) {
|
||||
PutInstruction i = (PutInstruction) o;
|
||||
|
@ -112,19 +117,23 @@ public class PutInstruction extends Instruction {
|
|||
return opcode == OP_putstatic;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int hashCode() {
|
||||
return getClassType().hashCode() + 9011 * getClassType().hashCode() + 317 * getFieldName().hashCode() + opcode;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public int getPoppedCount() {
|
||||
return isStatic() ? 1 : 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String toString() {
|
||||
return "Put(" + getFieldType() + "," + (isStatic() ? "STATIC" : "NONSTATIC") + "," + getClassType() + "," + getFieldName()
|
||||
+ ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitPut(this);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public final class ReturnInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ReturnInstruction) {
|
||||
ReturnInstruction i = (ReturnInstruction) o;
|
||||
|
@ -53,14 +54,17 @@ public final class ReturnInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFallThrough() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode + 31111;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return opcode == OP_return ? 0 : 1;
|
||||
}
|
||||
|
@ -69,10 +73,12 @@ public final class ReturnInstruction extends Instruction {
|
|||
return opcode == OP_return ? TYPE_void : indexedTypes[opcode - OP_ireturn];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitReturn(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Return(" + getType() + ")";
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ public final class ShiftInstruction extends Instruction {
|
|||
return preallocated[(operator.ordinal() - Operator.SHL.ordinal()) * 2 + t];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ShiftInstruction) {
|
||||
ShiftInstruction i = (ShiftInstruction) o;
|
||||
|
@ -59,18 +60,22 @@ public final class ShiftInstruction extends Instruction {
|
|||
return Operator.values()[(opcode - OP_ishl) / 2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return Util.getWordSize(getType());
|
||||
}
|
||||
|
@ -79,10 +84,12 @@ public final class ShiftInstruction extends Instruction {
|
|||
return indexedTypes[(opcode - OP_ishl) & 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitShift(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Shift(" + getType() + "," + getOperator() + ")";
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public final class StoreInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof StoreInstruction) {
|
||||
StoreInstruction i = (StoreInstruction) o;
|
||||
|
@ -72,18 +73,22 @@ public final class StoreInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode + index * 148091891;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LocalStore(" + getType() + "," + index + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitLocalStore(this);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public final class SwapInstruction extends Instruction {
|
|||
return preallocated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof SwapInstruction) {
|
||||
return true;
|
||||
|
@ -32,18 +33,22 @@ public final class SwapInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 84323111;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Swap()";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitSwap(this);
|
||||
}
|
||||
|
|
|
@ -75,10 +75,12 @@ public final class SwitchInstruction extends Instruction {
|
|||
return new SwitchInstruction(opcode, casesAndLabels, defaultLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFallThrough() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getBranchTargets() {
|
||||
int[] r = new int[casesAndLabels.length / 2 + 1];
|
||||
r[0] = defaultLabel;
|
||||
|
@ -88,6 +90,7 @@ public final class SwitchInstruction extends Instruction {
|
|||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction redirectTargets(int[] targetMap) throws IllegalArgumentException {
|
||||
if (targetMap == null) {
|
||||
throw new IllegalArgumentException("targetMap is null");
|
||||
|
@ -104,6 +107,7 @@ public final class SwitchInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof SwitchInstruction) {
|
||||
SwitchInstruction i = (SwitchInstruction) o;
|
||||
|
@ -113,6 +117,7 @@ public final class SwitchInstruction extends Instruction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = defaultLabel * 1348091 + 111311;
|
||||
for (int i = 0; i < casesAndLabels.length; i++) {
|
||||
|
@ -121,10 +126,12 @@ public final class SwitchInstruction extends Instruction {
|
|||
return h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer b = new StringBuffer("Switch(");
|
||||
b.append(defaultLabel);
|
||||
|
@ -136,6 +143,7 @@ public final class SwitchInstruction extends Instruction {
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws IllegalArgumentException {
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
|
|
@ -24,22 +24,27 @@ public final class ThrowInstruction extends Instruction {
|
|||
return preallocated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ThrowInstruction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFallThrough() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 99651;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws IllegalArgumentException {
|
||||
if (v == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -47,6 +52,7 @@ public final class ThrowInstruction extends Instruction {
|
|||
v.visitThrow(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Throw()";
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public final class UnaryOpInstruction extends Instruction {
|
|||
return preallocated[t];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof UnaryOpInstruction) {
|
||||
UnaryOpInstruction i = (UnaryOpInstruction) o;
|
||||
|
@ -61,18 +62,22 @@ public final class UnaryOpInstruction extends Instruction {
|
|||
return Operator.NEG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return opcode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPoppedCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPushedType(String[] types) {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPushedWordSize() {
|
||||
return Util.getWordSize(getType());
|
||||
}
|
||||
|
@ -81,10 +86,12 @@ public final class UnaryOpInstruction extends Instruction {
|
|||
return indexedTypes[opcode - OP_ineg];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) throws NullPointerException {
|
||||
v.visitUnaryOp(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UnaryOp(" + getType() + "," + getOperator() + ")";
|
||||
}
|
||||
|
|
|
@ -403,8 +403,8 @@ public class Analyzer {
|
|||
String[] locals;
|
||||
|
||||
PathElement(int index, String[] stack, String[] locals) {
|
||||
this.stack = (String[]) stack.clone();
|
||||
this.locals = (String[]) locals.clone();
|
||||
this.stack = stack.clone();
|
||||
this.locals = locals.clone();
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
@ -501,11 +501,13 @@ public class Analyzer {
|
|||
System.arraycopy(locals[i], 0, curLocals, 0, curLocalsSize[0]);
|
||||
|
||||
Instruction.Visitor localsUpdate = new Instruction.Visitor() {
|
||||
@Override
|
||||
public void visitLocalLoad(LoadInstruction instruction) {
|
||||
String t = curLocals[instruction.getVarIndex()];
|
||||
curStack[0] = t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalStore(StoreInstruction instruction) {
|
||||
int index = instruction.getVarIndex();
|
||||
curLocals[index] = curStack[0];
|
||||
|
|
|
@ -81,6 +81,7 @@ public final class Verifier extends Analyzer {
|
|||
VerifyVisitor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(int offset, List<PathElement> path, String[] curStack, String[] curLocals) {
|
||||
curIndex = offset;
|
||||
curPath = path;
|
||||
|
@ -88,6 +89,7 @@ public final class Verifier extends Analyzer {
|
|||
this.curLocals = curLocals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldContinue() {
|
||||
return ex == null;
|
||||
}
|
||||
|
@ -110,14 +112,17 @@ public final class Verifier extends Analyzer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConstant(ConstantInstruction instruction) {
|
||||
// make sure that constants are checked
|
||||
instruction.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitGoto(GotoInstruction instruction) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalLoad(LoadInstruction instruction) {
|
||||
String t = curLocals[instruction.getVarIndex()];
|
||||
if (t == null) {
|
||||
|
@ -129,59 +134,72 @@ public final class Verifier extends Analyzer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalStore(StoreInstruction instruction) {
|
||||
checkStackSubtype(0, instruction.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayLoad(ArrayLoadInstruction instruction) {
|
||||
checkStackSubtype(0, Constants.TYPE_int);
|
||||
checkArrayStackSubtype(1, instruction.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayStore(ArrayStoreInstruction instruction) {
|
||||
checkStackSubtype(0, instruction.getType());
|
||||
checkStackSubtype(1, Constants.TYPE_int);
|
||||
checkArrayStackSubtype(2, instruction.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPop(PopInstruction instruction) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDup(DupInstruction instruction) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBinaryOp(BinaryOpInstruction instruction) {
|
||||
checkStackSubtype(0, instruction.getType());
|
||||
checkStackSubtype(1, instruction.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitUnaryOp(UnaryOpInstruction instruction) {
|
||||
checkStackSubtype(0, instruction.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitShift(ShiftInstruction instruction) {
|
||||
checkStackSubtype(0, Constants.TYPE_int);
|
||||
checkStackSubtype(1, instruction.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConversion(ConversionInstruction instruction) {
|
||||
checkStackSubtype(0, instruction.getFromType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitComparison(ComparisonInstruction instruction) {
|
||||
checkStackSubtype(0, instruction.getType());
|
||||
checkStackSubtype(1, instruction.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConditionalBranch(ConditionalBranchInstruction instruction) {
|
||||
checkStackSubtype(0, instruction.getType());
|
||||
checkStackSubtype(1, instruction.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwitch(SwitchInstruction instruction) {
|
||||
checkStackSubtype(0, Constants.TYPE_int);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReturn(ReturnInstruction instruction) {
|
||||
if (instruction.getType() != Constants.TYPE_void) {
|
||||
checkStackSubtype(0, instruction.getType());
|
||||
|
@ -189,6 +207,7 @@ public final class Verifier extends Analyzer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitGet(GetInstruction instruction) {
|
||||
// make sure constant pool entries are dereferenced
|
||||
String classType = instruction.getClassType();
|
||||
|
@ -198,6 +217,7 @@ public final class Verifier extends Analyzer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPut(PutInstruction instruction) {
|
||||
// make sure constant pool entries are dereferenced
|
||||
String classType = instruction.getClassType();
|
||||
|
@ -209,6 +229,7 @@ public final class Verifier extends Analyzer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInvoke(InvokeInstruction instruction) {
|
||||
// make sure constant pool entries are dereferenced
|
||||
String classType = instruction.getClassType();
|
||||
|
@ -222,6 +243,7 @@ public final class Verifier extends Analyzer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitNew(NewInstruction instruction) {
|
||||
for (int i = 0; i < instruction.getArrayBoundsCount(); i++) {
|
||||
checkStackSubtype(i, Constants.TYPE_int);
|
||||
|
@ -230,26 +252,31 @@ public final class Verifier extends Analyzer {
|
|||
instruction.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayLength(ArrayLengthInstruction instruction) {
|
||||
if (!curStack[0].equals(Constants.TYPE_null) && !Util.isArrayType(curStack[0])) {
|
||||
ex = new FailureException(curIndex, "Expected array type at stack 0, got " + curStack[0], curPath);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitThrow(ThrowInstruction instruction) {
|
||||
checkStackSubtype(0, Constants.TYPE_Throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMonitor(MonitorInstruction instruction) {
|
||||
checkStackSubtype(0, Constants.TYPE_Object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCheckCast(CheckCastInstruction instruction) {
|
||||
checkStackSubtype(0, Constants.TYPE_Object);
|
||||
// make sure constant is dereferenced
|
||||
instruction.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInstanceof(InstanceofInstruction instruction) {
|
||||
checkStackSubtype(0, Constants.TYPE_Object);
|
||||
// make sure constant is dereferenced
|
||||
|
|
|
@ -136,106 +136,132 @@ public class InstructionTypeCounter implements MethodData.Results {
|
|||
countUnaryOps = 0;
|
||||
|
||||
Instruction.Visitor visitor = new Instruction.Visitor() {
|
||||
@Override
|
||||
public void visitArrayLength(ArrayLengthInstruction instruction) {
|
||||
countArrayLengths++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBinaryOp(BinaryOpInstruction instruction) {
|
||||
countBinaryOps++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCheckCast(CheckCastInstruction instruction) {
|
||||
countCheckCasts++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitComparison(ComparisonInstruction instruction) {
|
||||
countComparisons++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConditionalBranch(ConditionalBranchInstruction instruction) {
|
||||
countConditionalBranches++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConstant(ConstantInstruction instruction) {
|
||||
countConstants++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConversion(ConversionInstruction instruction) {
|
||||
countConversions++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDup(DupInstruction instruction) {
|
||||
countDups++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitGoto(GotoInstruction instruction) {
|
||||
countGotos++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInstanceof(InstanceofInstruction instruction) {
|
||||
countInstanceOfs++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalLoad(LoadInstruction instruction) {
|
||||
countLocalLoads++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalStore(StoreInstruction instruction) {
|
||||
countLocalStores++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitNew(NewInstruction instruction) {
|
||||
countNews++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPop(PopInstruction instruction) {
|
||||
countPops++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReturn(ReturnInstruction instruction) {
|
||||
countReturns++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitShift(ShiftInstruction instruction) {
|
||||
countShifts++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwap(SwapInstruction instruction) {
|
||||
countSwaps++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwitch(SwitchInstruction instruction) {
|
||||
countSwitches++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitThrow(ThrowInstruction instruction) {
|
||||
countThrows++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitUnaryOp(UnaryOpInstruction instruction) {
|
||||
countUnaryOps++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayLoad(ArrayLoadInstruction instruction) {
|
||||
countArrayLoads++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayStore(ArrayStoreInstruction instruction) {
|
||||
countArrayStores++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitGet(GetInstruction instruction) {
|
||||
countGets++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPut(PutInstruction instruction) {
|
||||
countPuts++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMonitor(MonitorInstruction instruction) {
|
||||
countMonitors++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInvoke(InvokeInstruction instruction) {
|
||||
countInvokes++;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public class LocalAllocator implements MethodData.Results {
|
|||
final int[] max = { Util.getParamsWordSize(info.getSignature()) + (info.getIsStatic() ? 0 : 1) };
|
||||
|
||||
Instruction.Visitor visitor = new Instruction.Visitor() {
|
||||
@Override
|
||||
public void visitLocalLoad(LoadInstruction instruction) {
|
||||
int v = instruction.getVarIndex() + Util.getWordSize(instruction.getType());
|
||||
if (v > max[0]) {
|
||||
|
@ -43,6 +44,7 @@ public class LocalAllocator implements MethodData.Results {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalStore(StoreInstruction instruction) {
|
||||
int v = instruction.getVarIndex() + Util.getWordSize(instruction.getType());
|
||||
if (v > max[0]) {
|
||||
|
|
|
@ -32,26 +32,32 @@ final public class CTCompiler extends Compiler {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolInteger(int v) {
|
||||
return cw.addCPInt(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolFloat(float v) {
|
||||
return cw.addCPFloat(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolLong(long v) {
|
||||
return cw.addCPLong(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolDouble(double v) {
|
||||
return cw.addCPDouble(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolString(String v) {
|
||||
return cw.addCPString(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolClassType(String c) {
|
||||
return cw.addCPClass(convertTypeToClass(c));
|
||||
}
|
||||
|
@ -80,18 +86,22 @@ final public class CTCompiler extends Compiler {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolField(String c, String name, String type) {
|
||||
return cw.addCPFieldRef(convertTypeToClass(c), name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolMethod(String c, String name, String sig) {
|
||||
return cw.addCPMethodRef(convertTypeToClass(c), name, sig);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int allocateConstantPoolInterfaceMethod(String c, String name, String sig) {
|
||||
return cw.addCPInterfaceMethodRef(convertTypeToClass(c), name, sig);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String createHelperMethod(boolean isStatic, String sig) {
|
||||
long r = Math.abs((new Random()).nextLong());
|
||||
String name = "_helper_" + r;
|
||||
|
|
|
@ -74,6 +74,7 @@ final public class CTDecoder extends Decoder {
|
|||
this.cp = cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConstantPoolItemType(int index) {
|
||||
return cp.getItemType(index);
|
||||
}
|
||||
|
@ -83,6 +84,7 @@ final public class CTDecoder extends Decoder {
|
|||
return new Error("Invalid class file: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConstantPoolInteger(int index) {
|
||||
try {
|
||||
return cp.getCPInt(index);
|
||||
|
@ -91,6 +93,7 @@ final public class CTDecoder extends Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getConstantPoolFloat(int index) {
|
||||
try {
|
||||
return cp.getCPFloat(index);
|
||||
|
@ -99,6 +102,7 @@ final public class CTDecoder extends Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getConstantPoolLong(int index) {
|
||||
try {
|
||||
return cp.getCPLong(index);
|
||||
|
@ -107,6 +111,7 @@ final public class CTDecoder extends Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getConstantPoolDouble(int index) {
|
||||
try {
|
||||
return cp.getCPDouble(index);
|
||||
|
@ -115,6 +120,7 @@ final public class CTDecoder extends Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConstantPoolString(int index) {
|
||||
try {
|
||||
return cp.getCPString(index);
|
||||
|
@ -123,6 +129,7 @@ final public class CTDecoder extends Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConstantPoolClassType(int index) {
|
||||
try {
|
||||
return convertClassToType(cp.getCPClass(index));
|
||||
|
@ -131,6 +138,7 @@ final public class CTDecoder extends Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConstantPoolMemberClassType(int index) {
|
||||
try {
|
||||
return convertClassToType(cp.getCPRefClass(index));
|
||||
|
@ -139,6 +147,7 @@ final public class CTDecoder extends Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConstantPoolMemberName(int index) {
|
||||
try {
|
||||
return cp.getCPRefName(index);
|
||||
|
@ -147,6 +156,7 @@ final public class CTDecoder extends Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConstantPoolMemberType(int index) {
|
||||
try {
|
||||
return cp.getCPRefType(index);
|
||||
|
|
|
@ -185,7 +185,7 @@ final public class ClassInstrumenter {
|
|||
if (classWriter == null) {
|
||||
throw new IllegalArgumentException("classWriter is null");
|
||||
}
|
||||
Instruction[] ins = (Instruction[]) instructions.toArray(new Instruction[instructions.size()]);
|
||||
Instruction[] ins = instructions.toArray(new Instruction[instructions.size()]);
|
||||
ExceptionHandler[][] handlers = new ExceptionHandler[ins.length][];
|
||||
Arrays.fill(handlers, noHandlers);
|
||||
int[] i2b = new int[ins.length];
|
||||
|
|
|
@ -31,6 +31,7 @@ final public class OfflineInstrumenter extends OfflineInstrumenterBase {
|
|||
public OfflineInstrumenter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object makeClassFromStream(BufferedInputStream s) throws IOException {
|
||||
byte[] bytes = new byte[s.available()];
|
||||
Util.readFully(s, bytes);
|
||||
|
@ -41,6 +42,7 @@ final public class OfflineInstrumenter extends OfflineInstrumenterBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getClassName(Object cl) {
|
||||
try {
|
||||
return ((ClassInstrumenter) cl).getReader().getName().replace('/', '.');
|
||||
|
@ -49,6 +51,7 @@ final public class OfflineInstrumenter extends OfflineInstrumenterBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeClassTo(Object cl, Object mods, OutputStream s) throws IOException {
|
||||
ClassInstrumenter ci = (ClassInstrumenter) cl;
|
||||
ClassWriter cw = (ClassWriter) mods;
|
||||
|
|
|
@ -56,12 +56,15 @@ public class AddSerialVersion {
|
|||
* This class implements a stream that just discards everything written to it.
|
||||
*/
|
||||
public static final class SinkOutputStream extends OutputStream {
|
||||
@Override
|
||||
public void write(int b) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) {
|
||||
}
|
||||
}
|
||||
|
@ -112,13 +115,13 @@ public class AddSerialVersion {
|
|||
}
|
||||
Arrays.sort(fields, 0, fieldCount, new Comparator<Integer>() {
|
||||
public int compare(Integer o1, Integer o2) {
|
||||
String name1 = fieldNames[((Integer) o1).intValue()];
|
||||
String name2 = fieldNames[((Integer) o2).intValue()];
|
||||
String name1 = fieldNames[o1.intValue()];
|
||||
String name2 = fieldNames[o2.intValue()];
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < fieldCount; i++) {
|
||||
int f = ((Integer) fields[i]).intValue();
|
||||
int f = fields[i].intValue();
|
||||
out.writeUTF(fieldNames[f]);
|
||||
out.writeInt(r.getFieldAccessFlags(f));
|
||||
out.writeUTF(r.getFieldType(f));
|
||||
|
@ -147,8 +150,8 @@ public class AddSerialVersion {
|
|||
}
|
||||
Arrays.sort(methods, 0, methodCount, new Comparator<Integer>() {
|
||||
public int compare(Integer o1, Integer o2) {
|
||||
int m1 = ((Integer) o1).intValue();
|
||||
int m2 = ((Integer) o2).intValue();
|
||||
int m1 = o1.intValue();
|
||||
int m2 = o2.intValue();
|
||||
if (methodKinds[m1] != methodKinds[m2]) {
|
||||
return methodKinds[m1] - methodKinds[m2];
|
||||
}
|
||||
|
@ -158,7 +161,7 @@ public class AddSerialVersion {
|
|||
}
|
||||
});
|
||||
for (int i = 0; i < methodCount; i++) {
|
||||
int m = ((Integer) methods[i]).intValue();
|
||||
int m = methods[i].intValue();
|
||||
out.writeUTF(r.getMethodName(m));
|
||||
out.writeInt(r.getMethodAccessFlags(m));
|
||||
out.writeUTF(r.getMethodType(m));
|
||||
|
|
|
@ -102,6 +102,7 @@ public class MethodTracer {
|
|||
+ ci.getReader().getMethodName(i);
|
||||
|
||||
me.insertAtStart(new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(MethodEditor.Output w) {
|
||||
w.emit(getSysErr);
|
||||
w.emit(ConstantInstruction.makeString(msg0));
|
||||
|
@ -117,6 +118,7 @@ public class MethodTracer {
|
|||
+ ci.getReader().getMethodName(i) + ":" + k + " to target " + Util.makeClass(instr.getClassType()) + "."
|
||||
+ instr.getMethodName();
|
||||
me.insertBefore(k, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(MethodEditor.Output w) {
|
||||
w.emit(getSysErr);
|
||||
w.emit(ConstantInstruction.makeString(msg));
|
||||
|
|
|
@ -230,6 +230,7 @@ public final class MethodOptimizer {
|
|||
|
||||
if (!killed) {
|
||||
editor.insertBefore(j, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(PopInstruction.make(1));
|
||||
w.emit(li);
|
||||
|
@ -268,12 +269,14 @@ public final class MethodOptimizer {
|
|||
final int newVar = LocalAllocator.allocate(data, type);
|
||||
// put a store to the newVar right after the source
|
||||
editor.insertAfter(source, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(StoreInstruction.make(type, newVar));
|
||||
}
|
||||
});
|
||||
// load newVar before storing to correct variable
|
||||
editor.insertBefore(i, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(LoadInstruction.make(type, newVar));
|
||||
}
|
||||
|
@ -281,11 +284,13 @@ public final class MethodOptimizer {
|
|||
} else {
|
||||
// remove store instruction
|
||||
editor.replaceWith(i, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
}
|
||||
});
|
||||
// replace it right after the source
|
||||
editor.insertAfter(source, new MethodEditor.Patch() {
|
||||
@Override
|
||||
public void emitTo(Output w) {
|
||||
w.emit(s);
|
||||
}
|
||||
|
|
|
@ -116,15 +116,18 @@ public abstract class OfflineInstrumenterBase {
|
|||
name = je;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream open() throws IOException {
|
||||
JarFile cachedJar = openCachedJar(file);
|
||||
return cachedJar.getInputStream(cachedJar.getEntry(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return file.getPath() + "#" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClass() {
|
||||
return name.endsWith(".class");
|
||||
}
|
||||
|
@ -169,10 +172,12 @@ public abstract class OfflineInstrumenterBase {
|
|||
file = f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream open() throws IOException {
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return file.getPath();
|
||||
}
|
||||
|
|
|
@ -78,14 +78,17 @@ public final class ClassWriter implements ClassConstants {
|
|||
this.s = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof CWString && ((CWString) o).s.equals(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return s.hashCode() + 3901;
|
||||
}
|
||||
|
||||
@Override
|
||||
byte getType() {
|
||||
return CONSTANT_String;
|
||||
}
|
||||
|
@ -98,14 +101,17 @@ public final class ClassWriter implements ClassConstants {
|
|||
this.c = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof CWClass && ((CWClass) o).c.equals(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return c.hashCode() + 1431;
|
||||
}
|
||||
|
||||
@Override
|
||||
byte getType() {
|
||||
return CONSTANT_Class;
|
||||
}
|
||||
|
@ -124,6 +130,7 @@ public final class ClassWriter implements ClassConstants {
|
|||
this.t = t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof CWRef) {
|
||||
CWRef r = (CWRef) o;
|
||||
|
@ -133,10 +140,12 @@ public final class ClassWriter implements ClassConstants {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return type + (c.hashCode() << 5) + (n.hashCode() << 3) + t.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
byte getType() {
|
||||
return type;
|
||||
}
|
||||
|
@ -151,6 +160,7 @@ public final class ClassWriter implements ClassConstants {
|
|||
this.t = t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof CWNAT) {
|
||||
CWNAT r = (CWNAT) o;
|
||||
|
@ -160,10 +170,12 @@ public final class ClassWriter implements ClassConstants {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (n.hashCode() << 3) + t.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
byte getType() {
|
||||
return CONSTANT_NameAndType;
|
||||
}
|
||||
|
@ -511,10 +523,12 @@ public final class ClassWriter implements ClassConstants {
|
|||
this.len = len;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return len;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] dest, int destOffset) {
|
||||
System.arraycopy(buf, offset, dest, destOffset, len);
|
||||
return destOffset + len;
|
||||
|
@ -595,6 +609,7 @@ public final class ClassWriter implements ClassConstants {
|
|||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
int size = 8;
|
||||
if (attributes != null) {
|
||||
|
@ -605,6 +620,7 @@ public final class ClassWriter implements ClassConstants {
|
|||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) {
|
||||
setUShort(buf, offset, access);
|
||||
setUShort(buf, offset + 2, name);
|
||||
|
|
|
@ -54,6 +54,7 @@ public final class CodeWriter extends ClassWriter.Element {
|
|||
return code.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() throws IllegalArgumentException {
|
||||
verify();
|
||||
|
||||
|
@ -66,6 +67,7 @@ public final class CodeWriter extends ClassWriter.Element {
|
|||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException {
|
||||
verify();
|
||||
|
||||
|
|
|
@ -413,7 +413,7 @@ public final class ConstantPoolParser implements ClassConstants {
|
|||
}
|
||||
|
||||
private long getLong(int i) {
|
||||
return ((long) getInt(i) << 32) + ((long) getInt(i + 4) & 0xFFFFFFFFL);
|
||||
return ((long) getInt(i) << 32) + (getInt(i + 4) & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
private float getFloat(int i) {
|
||||
|
|
|
@ -79,11 +79,13 @@ public final class ConstantValueWriter extends ClassWriter.Element {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
verify();
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException {
|
||||
verify();
|
||||
ClassWriter.setUShort(buf, offset, attrID);
|
||||
|
|
|
@ -28,10 +28,12 @@ public final class ExceptionsWriter extends ClassWriter.Element {
|
|||
attrID = w.addCPUtf8("Exceptions");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return table == null ? 8 : 8 + table.length * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException {
|
||||
ClassWriter.setUShort(buf, offset, attrID);
|
||||
ClassWriter.setInt(buf, offset + 2, getSize() - 6);
|
||||
|
|
|
@ -28,6 +28,7 @@ public final class InnerClassesWriter extends ClassWriter.Element {
|
|||
attrID = w.addCPUtf8("InnerClasses");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return table == null ? 8 : 8 + table.length * 2;
|
||||
}
|
||||
|
@ -37,6 +38,7 @@ public final class InnerClassesWriter extends ClassWriter.Element {
|
|||
*
|
||||
* @return the number of bytes copies, which must be equal to getSize()
|
||||
*/
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException {
|
||||
ClassWriter.setUShort(buf, offset, attrID);
|
||||
ClassWriter.setInt(buf, offset + 2, getSize() - 6);
|
||||
|
|
|
@ -58,10 +58,12 @@ public final class LineNumberTableWriter extends ClassWriter.Element {
|
|||
rawTable = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 8 + rawTable.length * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException {
|
||||
ClassWriter.setUShort(buf, offset, attrID);
|
||||
ClassWriter.setInt(buf, offset + 2, 2 + rawTable.length * 2);
|
||||
|
|
|
@ -61,10 +61,12 @@ public final class LocalVariableTableWriter extends ClassWriter.Element {
|
|||
rawTable = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 8 + rawTable.length * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException {
|
||||
ClassWriter.setUShort(buf, offset, attrID);
|
||||
ClassWriter.setInt(buf, offset + 2, 2 + rawTable.length * 2);
|
||||
|
|
|
@ -26,10 +26,12 @@ public class SourceDebugExtensionWriter extends ClassWriter.Element {
|
|||
attrID = w.addCPUtf8("SourceDebugExtension");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return table == null ? 6 : 6 + table.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException {
|
||||
ClassWriter.setUShort(buf, offset, attrID);
|
||||
ClassWriter.setInt(buf, offset + 2, getSize() - 6);
|
||||
|
|
|
@ -36,11 +36,13 @@ public final class SourceFileWriter extends ClassWriter.Element {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() throws IllegalArgumentException {
|
||||
verify();
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException {
|
||||
verify();
|
||||
ClassWriter.setUShort(buf, offset, attrID);
|
||||
|
|
Loading…
Reference in New Issue