本文整理汇总了Java中org.apache.bcel.Constants.PUTFIELD属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.PUTFIELD属性的具体用法?Java Constants.PUTFIELD怎么用?Java Constants.PUTFIELD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.Constants
的用法示例。
在下文中一共展示了Constants.PUTFIELD属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanMethod
private void scanMethod(Method method, Set<XField> assignableFieldSet) throws ClassNotFoundException {
MethodGen methodGen = classContext.getMethodGen(method);
InstructionList il = methodGen.getInstructionList();
InstructionHandle handle = il.getStart();
ConstantPoolGen cpg = methodGen.getConstantPool();
while (handle != null) {
Instruction ins = handle.getInstruction();
short opcode = ins.getOpcode();
if (opcode == Constants.PUTFIELD) {
PUTFIELD putfield = (PUTFIELD) ins;
XField instanceField = Hierarchy.findXField(putfield, cpg);
if (instanceField != null && assignableFieldSet.contains(instanceField)) {
Set<XField> assignedFieldSetForMethod = getAssignedFieldSetForMethod(method);
assignedFieldSetForMethod.add(instanceField);
}
}
handle = handle.getNext();
}
}
示例2: isGetterMethod
/**
* Determine whether or not the the given method is
* a getter method. I.e., if it just returns the
* value of an instance field.
*
* @param classContext the ClassContext for the class containing the method
* @param method the method
*/
public static boolean isGetterMethod(ClassContext classContext, Method method) {
MethodGen methodGen = classContext.getMethodGen(method);
InstructionList il = methodGen.getInstructionList();
// System.out.println("Checking getter method: " + method.getName());
if (il.getLength() > 60)
return false;
int count = 0;
Iterator it = il.iterator();
while (it.hasNext()) {
InstructionHandle ih = (InstructionHandle) it.next();
switch (ih.getInstruction().getOpcode()) {
case Constants.GETFIELD:
count++;
if (count > 1) return false;
break;
case Constants.PUTFIELD:
case Constants.BALOAD:
case Constants.CALOAD:
case Constants.DALOAD:
case Constants.FALOAD:
case Constants.IALOAD:
case Constants.LALOAD:
case Constants.SALOAD:
case Constants.AALOAD:
case Constants.BASTORE:
case Constants.CASTORE:
case Constants.DASTORE:
case Constants.FASTORE:
case Constants.IASTORE:
case Constants.LASTORE:
case Constants.SASTORE:
case Constants.AASTORE:
case Constants.PUTSTATIC:
return false;
case Constants.INVOKESTATIC:
case Constants.INVOKEVIRTUAL:
case Constants.INVOKEINTERFACE:
case Constants.INVOKESPECIAL:
case Constants.GETSTATIC:
// no-op
}
}
// System.out.println("Found getter method: " + method.getName());
return true;
}
示例3: handleInstruction
public void handleInstruction(int opcode, int index) {
switch (opcode) {
case Constants.GETFIELD:
case Constants.PUTFIELD:
setField(getIndex(instructionList, index), false, opcode == Constants.GETFIELD);
break;
case Constants.GETSTATIC:
case Constants.PUTSTATIC:
setField(getIndex(instructionList, index), true, opcode == Constants.GETSTATIC);
break;
}
}