本文整理汇总了Java中org.objectweb.asm.Opcodes.ANEWARRAY属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.ANEWARRAY属性的具体用法?Java Opcodes.ANEWARRAY怎么用?Java Opcodes.ANEWARRAY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.objectweb.asm.Opcodes
的用法示例。
在下文中一共展示了Opcodes.ANEWARRAY属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitTypeInsn
@Override
public void visitTypeInsn(final int opcode, final String type) {
Type t = Type.getObjectType(type);
switch (opcode) {
case Opcodes.NEW:
anew(t);
break;
case Opcodes.ANEWARRAY:
newarray(t);
break;
case Opcodes.CHECKCAST:
checkcast(t);
break;
case Opcodes.INSTANCEOF:
instanceOf(t);
break;
default:
throw new IllegalArgumentException();
}
}
示例2: visitTypeInsn
public void visitTypeInsn(int opcode, String type) {
if (firstInstruction)
addInc();
super.visitTypeInsn(opcode, type);
// we deal with Opcodes.NEW through the constructors
if (opcode == Opcodes.ANEWARRAY) {
int siteId = getNextSiteId();
addLog(true, siteId);
} else if (DO_NEW_INVOKESPECIAL_SEQUENCE && opcode == Opcodes.NEW) {
super.visitInsn(Opcodes.DUP);
Triplet p = new Triplet();
p.type = type;
p.var = this.localsBase + 1 + newTypeStack.size();
p.siteId = getNextSiteId();
if (this.maxLocals < p.var) {
this.maxLocals = p.var;
methodToLargestLocal.put(this.encodedName, new Integer(
p.var));
}
super.setLocalType(p.var, JAVA_LANG_OBJECT_TYPE); // super.newLocal(OBJECT_TYPE);
newTypeStack.addLast(p);
super.visitVarInsn(Opcodes.ASTORE, p.var);
}
}
示例3: updateState
private void updateState(TypeInsnNode insn) {
Type type = Type.getObjectType(insn.desc);
switch (insn.getOpcode()) {
case Opcodes.NEW: {
state.push(type);
break;
}
case Opcodes.ANEWARRAY: {
Type arrayType = makeArrayType(type);
state.pop();
state.push(arrayType);
break;
}
case Opcodes.CHECKCAST: {
// Pop the top value and push it back on with the checked type.
state.pop(type);
state.push(type);
break;
}
case Opcodes.INSTANCEOF: {
state.pop(JarState.REFERENCE_TYPE);
state.push(Type.INT_TYPE);
break;
}
default:
throw new Unreachable("Unexpected TypeInsn opcode: " + insn.getOpcode());
}
}
示例4: unaryOperation
@Override
public BasicValue unaryOperation(AbstractInsnNode insnNode, BasicValue value) throws AnalyzerException {
if (insnNode.getOpcode() == Opcodes.ANEWARRAY && value instanceof IntegerConstantBasicValue) {
IntegerConstantBasicValue constantBasicValue = (IntegerConstantBasicValue) value;
String desc = ((TypeInsnNode) insnNode).desc;
return new ArraySizeBasicValue(Type.getType("[" + Type.getObjectType(desc)), constantBasicValue.minValue,
constantBasicValue.maxValue);
}
return super.unaryOperation(insnNode, value);
}
示例5: visitTypeInsn
/**
* Imports instructions with a single type operand (allocation of reference
* arrays, allocation of objects, casting and type checks).
*
* @param opcode Opcode.
* @param descriptor String descriptor of the type operand.
*/
@Override
public void visitTypeInsn(final int opcode, final String descriptor) {
Type type = Type.getObjectType(descriptor);
switch(opcode) {
// News
case Opcodes.ANEWARRAY: ordered.add(stack.push(new NewArray(type, stack.pop()))); break;
case Opcodes.NEW: ordered.add(stack.push(new NewObject(type))); break;
// Type Checks
case Opcodes.CHECKCAST: ordered.add(stack.push(new CheckCast(stack.pop(), type))); break;
case Opcodes.INSTANCEOF:ordered.add(stack.push(new InstanceOf(stack.pop(), type)));break;
}
}
示例6: canThrow
private boolean canThrow(AbstractInsnNode insn) {
switch (insn.getOpcode()) {
case Opcodes.AALOAD:
case Opcodes.AASTORE:
case Opcodes.ANEWARRAY:
// ARETURN does not throw in its dex image.
case Opcodes.ARRAYLENGTH:
case Opcodes.ATHROW:
case Opcodes.BALOAD:
case Opcodes.BASTORE:
case Opcodes.CALOAD:
case Opcodes.CASTORE:
case Opcodes.CHECKCAST:
case Opcodes.DALOAD:
case Opcodes.DASTORE:
// DRETURN does not throw in its dex image.
case Opcodes.FALOAD:
case Opcodes.FASTORE:
// FRETURN does not throw in its dex image.
case Opcodes.GETFIELD:
case Opcodes.GETSTATIC:
case Opcodes.IALOAD:
case Opcodes.IASTORE:
case Opcodes.IDIV:
case Opcodes.INSTANCEOF:
case Opcodes.INVOKEDYNAMIC:
case Opcodes.INVOKEINTERFACE:
case Opcodes.INVOKESPECIAL:
case Opcodes.INVOKESTATIC:
case Opcodes.INVOKEVIRTUAL:
case Opcodes.IREM:
// IRETURN does not throw in its dex image.
case Opcodes.LALOAD:
case Opcodes.LASTORE:
case Opcodes.LDIV:
case Opcodes.LREM:
// LRETURN does not throw in its dex image.
case Opcodes.MONITORENTER:
case Opcodes.MONITOREXIT:
case Opcodes.MULTIANEWARRAY:
case Opcodes.NEW:
case Opcodes.NEWARRAY:
case Opcodes.PUTFIELD:
case Opcodes.PUTSTATIC:
// RETURN does not throw in its dex image.
case Opcodes.SALOAD:
case Opcodes.SASTORE:
return true;
case Opcodes.LDC: {
// const-class and const-string* may throw in dex.
LdcInsnNode ldc = (LdcInsnNode) insn;
return ldc.cst instanceof String || ldc.cst instanceof Type;
}
default:
return false;
}
}