下面列出了org.objectweb.asm.Opcodes# NULL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Checks a stack frame value.
*
* @param value the value to be checked.
*/
private void checkFrameValue(final Object value) {
if (value == Opcodes.TOP
|| value == Opcodes.INTEGER
|| value == Opcodes.FLOAT
|| value == Opcodes.LONG
|| value == Opcodes.DOUBLE
|| value == Opcodes.NULL
|| value == Opcodes.UNINITIALIZED_THIS) {
return;
} else if (value instanceof String) {
checkInternalName(version, (String) value, "Invalid stack frame value");
} else if (value instanceof Label) {
referencedLabels.add((Label) value);
} else {
throw new IllegalArgumentException("Invalid stack frame value: " + value);
}
}
/**
* Checks a stack frame value.
*
* @param value
* the value to be checked.
*/
void checkFrameValue(final Object value) {
if (value == Opcodes.TOP || value == Opcodes.INTEGER || value == Opcodes.FLOAT || value == Opcodes.LONG || value == Opcodes.DOUBLE
|| value == Opcodes.NULL || value == Opcodes.UNINITIALIZED_THIS) {
return;
}
if (value instanceof String) {
checkInternalName((String) value, "Invalid stack frame value");
return;
}
if (!(value instanceof Label)) {
throw new IllegalArgumentException("Invalid stack frame value: " + value);
} else {
usedLabels.add((Label) value);
}
}
/**
* Checks a stack frame value.
*
* @param value the value to be checked.
*/
private void checkFrameValue(final Object value) {
if (value == Opcodes.TOP
|| value == Opcodes.INTEGER
|| value == Opcodes.FLOAT
|| value == Opcodes.LONG
|| value == Opcodes.DOUBLE
|| value == Opcodes.NULL
|| value == Opcodes.UNINITIALIZED_THIS) {
return;
} else if (value instanceof String) {
checkInternalName(version, (String) value, "Invalid stack frame value");
} else if (value instanceof Label) {
referencedLabels.add((Label) value);
} else {
throw new IllegalArgumentException("Invalid stack frame value: " + value);
}
}
/**
* Checks a stack frame value.
*
* @param value the value to be checked.
*/
private void checkFrameValue(final Object value) {
if (value == Opcodes.TOP
|| value == Opcodes.INTEGER
|| value == Opcodes.FLOAT
|| value == Opcodes.LONG
|| value == Opcodes.DOUBLE
|| value == Opcodes.NULL
|| value == Opcodes.UNINITIALIZED_THIS) {
return;
} else if (value instanceof String) {
checkInternalName(version, (String) value, "Invalid stack frame value");
} else if (value instanceof Label) {
referencedLabels.add((Label) value);
} else {
throw new IllegalArgumentException("Invalid stack frame value: " + value);
}
}
@Override
public void visitJumpInsn(int opcode, Label label) {
// There are only two opcodes for comparing object references.
if (opcode != Opcodes.IF_ACMPEQ && opcode != Opcodes.IF_ACMPNE) {
return;
}
// There should be two arguments on the stack.
Preconditions.checkState(adapter.stack.size() >= 2);
Object val1 = adapter.stack.get(adapter.stack.size() - 2);
Object val2 = adapter.stack.get(adapter.stack.size() - 1);
// If either is known null, then the comparison is benign.
if (val1 == Opcodes.NULL || val2 == Opcodes.NULL) {
return;
}
// If not, they both should be strings (class names).
Preconditions.checkState(val1 instanceof String);
Preconditions.checkState(val2 instanceof String);
// If both are risky, report.
if (RISKY_TYPES.contains(val1) && RISKY_TYPES.contains(val2)) {
log.add(
String.format((Locale) null, "RegisterSpec comparison: %s.%s", className, methodName));
}
}
static Type deferLocalDesc(Object object) {
if (object instanceof String)
return Type.getObjectType((String) object);
// TODO: analyze opcode at pos label
if (object instanceof Label)
return Type.getType(Object.class);
int intObject = (Integer) object;
if (intObject == Opcodes.TOP)
return null;
if (intObject == Opcodes.INTEGER)
return Type.INT_TYPE;
if (intObject == Opcodes.FLOAT)
return Type.FLOAT_TYPE;
if (intObject == Opcodes.LONG)
return Type.LONG_TYPE;
if (intObject == Opcodes.DOUBLE)
return Type.getType(double.class);
if (intObject == Opcodes.LONG)
return Type.getType(long.class);
if (intObject == Opcodes.NULL)
return Type.getType(Object.class);
// TODO: defer from containing class
if (intObject == Opcodes.UNINITIALIZED_THIS)
return Type.getType(Object.class);
throw new BuildStackFrameException("Couldnt defer desc for " + object);
}
protected Object parseFrameType(Map<String, Label> labels, String typeStr) throws Exception {
if(typeStr.length() == 1) //Base type
{
if(typeStr.equals("T"))
return Opcodes.TOP;
else if(typeStr.equals("I"))
return Opcodes.INTEGER;
else if(typeStr.equals("F"))
return Opcodes.FLOAT;
else if(typeStr.equals("D"))
return Opcodes.DOUBLE;
else if(typeStr.equals("J"))
return Opcodes.LONG;
else if(typeStr.equals("N"))
return Opcodes.NULL;
else if(typeStr.equals("U"))
return Opcodes.UNINITIALIZED_THIS;
else
throw new Exception(getCurrentTokenLine() + ": Error while parsing frame type, found no type for " + typeStr);
}
//Label
if(typeStr.startsWith("L") && StringUtils.isNumeric(typeStr.substring(1)))
return getLabel(labels, typeStr);
//Class name
return typeStr;
}
/** Convert the type in stack map frame to inference type. */
private InferredType convertTypeInStackMapFrame(Object typeInStackMapFrame) {
if (typeInStackMapFrame == Opcodes.TOP) {
return InferredType.TOP;
} else if (typeInStackMapFrame == Opcodes.INTEGER) {
return InferredType.INT;
} else if (typeInStackMapFrame == Opcodes.FLOAT) {
return InferredType.FLOAT;
} else if (typeInStackMapFrame == Opcodes.DOUBLE) {
return InferredType.DOUBLE;
} else if (typeInStackMapFrame == Opcodes.LONG) {
return InferredType.LONG;
} else if (typeInStackMapFrame == Opcodes.NULL) {
return InferredType.NULL;
} else if (typeInStackMapFrame == Opcodes.UNINITIALIZED_THIS) {
return InferredType.UNINITIALIZED_THIS;
} else if (typeInStackMapFrame instanceof String) {
String referenceTypeName = (String) typeInStackMapFrame;
if (referenceTypeName.charAt(0) == '[') {
return InferredType.create(referenceTypeName);
} else {
return InferredType.create('L' + referenceTypeName + ';');
}
} else if (typeInStackMapFrame instanceof Label) {
return InferredType.UNINITIALIZED;
} else {
throw new RuntimeException(
"Cannot reach here. Unhandled element: value="
+ typeInStackMapFrame
+ ", class="
+ typeInStackMapFrame.getClass()
+ ". The current method being desugared is "
+ methodSignature);
}
}