/** * Is the given instruction a read of a field? * * @param ins * the Instruction to check * @param cpg * ConstantPoolGen of the method containing the instruction * @return the Field if the instruction is a read of a field, null otherwise */ public static FieldAnnotation isRead(Instruction ins, ConstantPoolGen cpg) { if (ins instanceof GETFIELD || ins instanceof GETSTATIC) { FieldInstruction fins = (FieldInstruction) ins; String className = fins.getClassName(cpg); return new FieldAnnotation(className, fins.getName(cpg), fins.getSignature(cpg), fins instanceof GETSTATIC); } else { return null; } }
public static XField createXField(FieldInstruction fieldInstruction, ConstantPoolGen cpg) { String className = fieldInstruction.getClassName(cpg); String fieldName = fieldInstruction.getName(cpg); String fieldSig = fieldInstruction.getSignature(cpg); int opcode = fieldInstruction.getOpcode(); return createXField(className, fieldName, fieldSig, opcode == Const.GETSTATIC || opcode == Const.PUTSTATIC); }
/** * Is the instruction a write of a field? * * @param ins * the Instruction to check * @param cpg * ConstantPoolGen of the method containing the instruction * @return the Field if instruction is a write of a field, null otherwise */ public static FieldAnnotation isWrite(Instruction ins, ConstantPoolGen cpg) { if (ins instanceof PUTFIELD || ins instanceof PUTSTATIC) { FieldInstruction fins = (FieldInstruction) ins; String className = fins.getClassName(cpg); return new FieldAnnotation(className, fins.getName(cpg), fins.getSignature(cpg), fins instanceof PUTSTATIC); } else { return null; } }
/** * Look up the field referenced by given FieldInstruction, returning it as * an {@link XField XField} object. * * @param fins * the FieldInstruction * @param cpg * the ConstantPoolGen used by the class containing the * instruction * @return an XField object representing the field, or null if no such field * could be found */ public static @CheckForNull XField findXField(FieldInstruction fins, @Nonnull ConstantPoolGen cpg) { String className = fins.getClassName(cpg); String fieldName = fins.getFieldName(cpg); String fieldSig = fins.getSignature(cpg); boolean isStatic = (fins.getOpcode() == Const.GETSTATIC || fins.getOpcode() == Const.PUTSTATIC); XField xfield = findXField(className, fieldName, fieldSig, isStatic); short opcode = fins.getOpcode(); if (xfield != null && xfield.isResolved() && xfield.isStatic() == (opcode == Const.GETSTATIC || opcode == Const.PUTSTATIC)) { return xfield; } else { return null; } }
@Override public MatchResult match(InstructionHandle handle, ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after, BindingSet bindingSet) throws DataflowAnalysisException { Variable field; Instruction ins = handle.getInstruction(); FieldInstruction fieldIns; // The instruction must be GETFIELD or GETSTATIC if (ins instanceof GETFIELD) { fieldIns = (GETFIELD) ins; ValueNumber ref = before.getTopValue(); field = new FieldVariable(ref, fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg)); } else if (ins instanceof GETSTATIC) { fieldIns = (GETSTATIC) ins; field = new FieldVariable(fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg)); } else { return null; } Variable result = snarfFieldValue(fieldIns, cpg, after); return checkConsistent(field, result, bindingSet); } }
/** * Get FieldDescriptor describing the field accessed by given * FieldInstruction. * * @param fins * a FieldInstruction * @param cpg * ConstantPoolGen for the method containing the FieldInstruction * @return FieldDescriptor describing the field accessed by given * FieldInstruction */ public static FieldDescriptor getAccessedFieldDescriptor(FieldInstruction fins, ConstantPoolGen cpg) { String className = fins.getClassName(cpg); String fieldName = fins.getName(cpg); String fieldSig = fins.getSignature(cpg); boolean isStatic = (fins.getOpcode() == Const.GETSTATIC || fins.getOpcode() == Const.PUTSTATIC); return DescriptorFactory.instance().getFieldDescriptor(className, fieldName, fieldSig, isStatic); }
@Override public MatchResult match(InstructionHandle handle, ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after, BindingSet bindingSet) throws DataflowAnalysisException { Instruction ins = handle.getInstruction(); FieldInstruction fieldIns; Variable field; // The instruction must be PUTFIELD or PUTSTATIC if (ins instanceof PUTFIELD) { fieldIns = (PUTFIELD) ins; int numSlots = before.getNumSlots(); ValueNumber ref = before.getValue(isLongOrDouble(fieldIns, cpg) ? numSlots - 3 : numSlots - 2); field = new FieldVariable(ref, fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg)); } else if (ins instanceof PUTSTATIC) { fieldIns = (PUTSTATIC) ins; field = new FieldVariable(fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg)); } else { return null; } Variable value = snarfFieldValue(fieldIns, cpg, before); return checkConsistent(field, value, bindingSet); } }
/** @return type of field */ public Type getFieldType(ConstantPoolGen cpg) { return Type.getType(getSignature(cpg)); }
/** @return type of field */ public Type getFieldType( final ConstantPoolGen cpg ) { return Type.getType(getSignature(cpg)); }
/** @return size of field (1 or 2) */ protected int getFieldSize( final ConstantPoolGen cpg ) { return Type.size(Type.getTypeSize(getSignature(cpg))); }
/** * Is the instruction a write of a field? * * @param ins * the Instruction to check * @param cpg * ConstantPoolGen of the method containing the instruction * @return the Field if instruction is a write of a field, null otherwise */ public static FieldAnnotation isWrite(Instruction ins, ConstantPoolGen cpg) { if (ins instanceof PUTFIELD || ins instanceof PUTSTATIC) { FieldInstruction fins = (FieldInstruction) ins; String className = fins.getClassName(cpg); return new FieldAnnotation(className, fins.getName(cpg), fins.getSignature(cpg), fins instanceof PUTSTATIC); } else { return null; } }
/** * Is the given instruction a read of a field? * * @param ins * the Instruction to check * @param cpg * ConstantPoolGen of the method containing the instruction * @return the Field if the instruction is a read of a field, null otherwise */ public static FieldAnnotation isRead(Instruction ins, ConstantPoolGen cpg) { if (ins instanceof GETFIELD || ins instanceof GETSTATIC) { FieldInstruction fins = (FieldInstruction) ins; String className = fins.getClassName(cpg); return new FieldAnnotation(className, fins.getName(cpg), fins.getSignature(cpg), fins instanceof GETSTATIC); } else { return null; } }
public static XField createXField(FieldInstruction fieldInstruction, ConstantPoolGen cpg) { String className = fieldInstruction.getClassName(cpg); String fieldName = fieldInstruction.getName(cpg); String fieldSig = fieldInstruction.getSignature(cpg); int opcode = fieldInstruction.getOpcode(); return createXField(className, fieldName, fieldSig, opcode == Constants.GETSTATIC || opcode == Constants.PUTSTATIC); }
/** * Look up the field referenced by given FieldInstruction, returning it as * an {@link XField XField} object. * * @param fins * the FieldInstruction * @param cpg * the ConstantPoolGen used by the class containing the * instruction * @return an XField object representing the field, or null if no such field * could be found */ public static @CheckForNull XField findXField(FieldInstruction fins, @Nonnull ConstantPoolGen cpg) { String className = fins.getClassName(cpg); String fieldName = fins.getFieldName(cpg); String fieldSig = fins.getSignature(cpg); boolean isStatic = (fins.getOpcode() == Constants.GETSTATIC || fins.getOpcode() == Constants.PUTSTATIC); XField xfield = findXField(className, fieldName, fieldSig, isStatic); short opcode = fins.getOpcode(); if (xfield != null && xfield.isResolved() && xfield.isStatic() == (opcode == Constants.GETSTATIC || opcode == Constants.PUTSTATIC)) { return xfield; } else { return null; } }
@Override public MatchResult match(InstructionHandle handle, ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after, BindingSet bindingSet) throws DataflowAnalysisException { Variable field; Instruction ins = handle.getInstruction(); FieldInstruction fieldIns; // The instruction must be GETFIELD or GETSTATIC if (ins instanceof GETFIELD) { fieldIns = (GETFIELD) ins; ValueNumber ref = before.getTopValue(); field = new FieldVariable(ref, fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg)); } else if (ins instanceof GETSTATIC) { fieldIns = (GETSTATIC) ins; field = new FieldVariable(fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg)); } else { return null; } Variable result = snarfFieldValue(fieldIns, cpg, after); return checkConsistent(field, result, bindingSet); } }
/** * Get FieldDescriptor describing the field accessed by given * FieldInstruction. * * @param fins * a FieldInstruction * @param cpg * ConstantPoolGen for the method containing the FieldInstruction * @return FieldDescriptor describing the field accessed by given * FieldInstruction */ public static FieldDescriptor getAccessedFieldDescriptor(FieldInstruction fins, ConstantPoolGen cpg) { String className = fins.getClassName(cpg); String fieldName = fins.getName(cpg); String fieldSig = fins.getSignature(cpg); boolean isStatic = (fins.getOpcode() == Constants.GETSTATIC || fins.getOpcode() == Constants.PUTSTATIC); return DescriptorFactory.instance().getFieldDescriptor(className, fieldName, fieldSig, isStatic); }
@Override public MatchResult match(InstructionHandle handle, ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after, BindingSet bindingSet) throws DataflowAnalysisException { Instruction ins = handle.getInstruction(); FieldInstruction fieldIns; Variable field; // The instruction must be PUTFIELD or PUTSTATIC if (ins instanceof PUTFIELD) { fieldIns = (PUTFIELD) ins; int numSlots = before.getNumSlots(); ValueNumber ref = before.getValue(isLongOrDouble(fieldIns, cpg) ? numSlots - 3 : numSlots - 2); field = new FieldVariable(ref, fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg)); } else if (ins instanceof PUTSTATIC) { fieldIns = (PUTSTATIC) ins; field = new FieldVariable(fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg)); } else { return null; } Variable value = snarfFieldValue(fieldIns, cpg, before); return checkConsistent(field, value, bindingSet); } }
return false; String childFSig = ((FieldInstruction) childin).getSignature(childPoolGen); String parentFSig = ((FieldInstruction) parentin).getSignature(parentPoolGen); if (!childFSig.equals(parentFSig)) { return false;
return false; String childFSig = ((FieldInstruction) childin).getSignature(childPoolGen); String parentFSig = ((FieldInstruction) parentin).getSignature(parentPoolGen); if (!childFSig.equals(parentFSig)) { return false;