本文整理汇总了Java中jdk.internal.org.objectweb.asm.Opcodes类的典型用法代码示例。如果您正苦于以下问题:Java Opcodes类的具体用法?Java Opcodes怎么用?Java Opcodes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Opcodes类属于jdk.internal.org.objectweb.asm包,在下文中一共展示了Opcodes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public byte[] visit(Return node) {
node.getExpression().accept(this);
Type result = node.getResultType();
if (result instanceof TypeKlass) {
currentMV.visitInsn(Opcodes.ARETURN);
} else if (result.equals(TypeList.VOID)) {
currentMV.visitInsn(Opcodes.RETURN);
} else if (result.equals(TypeList.DOUBLE)) {
currentMV.visitInsn(Opcodes.DRETURN);
} else if (result.equals(TypeList.FLOAT)) {
currentMV.visitInsn(Opcodes.FRETURN);
} else if (result.equals(TypeList.LONG)) {
currentMV.visitInsn(Opcodes.LRETURN);
} else {
currentMV.visitInsn(Opcodes.IRETURN);
}
return EMPTY_BYTE_ARRAY;
}
示例2: visitTypeInsn
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitTypeInsn(final int opcode, final String type) {
if (opcode == Opcodes.NEW) {
if (labels == null) {
Label l = new Label();
labels = new ArrayList<Label>(3);
labels.add(l);
if (mv != null) {
mv.visitLabel(l);
}
}
for (int i = 0; i < labels.size(); ++i) {
uninitializedTypes.put(labels.get(i), type);
}
}
if (mv != null) {
mv.visitTypeInsn(opcode, type);
}
execute(opcode, 0, type);
}
示例3: visitIntInsn
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitIntInsn(final int opcode, final int operand) {
checkStartCode();
checkEndCode();
checkOpcode(opcode, 1);
switch (opcode) {
case Opcodes.BIPUSH:
checkSignedByte(operand, "Invalid operand");
break;
case Opcodes.SIPUSH:
checkSignedShort(operand, "Invalid operand");
break;
// case Constants.NEWARRAY:
default:
if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
throw new IllegalArgumentException(
"Invalid operand (must be an array type code T_...): "
+ operand);
}
}
super.visitIntInsn(opcode, operand);
++insnCount;
}
示例4: visitInnerClass
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitInnerClass(final String name, final String outerName,
final String innerName, final int access) {
buf.setLength(0);
buf.append(tab).append("// access flags 0x");
buf.append(
Integer.toHexString(access & ~Opcodes.ACC_SUPER).toUpperCase())
.append('\n');
buf.append(tab);
appendAccess(access);
buf.append("INNERCLASS ");
appendDescriptor(INTERNAL_NAME, name);
buf.append(' ');
appendDescriptor(INTERNAL_NAME, outerName);
buf.append(' ');
appendDescriptor(INTERNAL_NAME, innerName);
buf.append('\n');
text.add(buf.toString());
}
示例5: visitLocalVar
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
private byte[] visitLocalVar(Initialization node) {
VariableInfo vi = node.getVariableInfo();
int index = locals.addLocal(vi);
int store;
node.getChild(0).accept(this); // place initialization expression on stack
emitDup(vi.type);
if (vi.type instanceof TypeKlass) {
store = Opcodes.ASTORE;
} else if (vi.type.equals(TypeList.DOUBLE)) {
store = Opcodes.DSTORE;
} else if (vi.type.equals(TypeList.LONG)) {
store = Opcodes.LSTORE;
} else if (vi.type.equals(TypeList.FLOAT)) {
store = Opcodes.FSTORE;
} else {
store = Opcodes.ISTORE;
}
currentMV.visitVarInsn(store, index);
return EMPTY_BYTE_ARRAY;
}
示例6: visitTypeInsn
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@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();
}
}
示例7: visitField
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public FieldVisitor visitField(final int access, final String name,
final String desc, final String signature, final Object value) {
checkState();
checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
+ Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
+ Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE
+ Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC
+ Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED + 0x40000); // ClassWriter.ACC_SYNTHETIC_ATTRIBUTE
CheckMethodAdapter.checkUnqualifiedName(version, name, "field name");
CheckMethodAdapter.checkDesc(desc, false);
if (signature != null) {
checkFieldSignature(signature);
}
if (value != null) {
CheckMethodAdapter.checkConstant(value);
}
FieldVisitor av = super
.visitField(access, name, desc, signature, value);
return new CheckFieldAdapter(av);
}
示例8: visitLdcInsn
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitLdcInsn(final Object cst) {
if (mv != null) {
mv.visitLdcInsn(cst);
}
if (this.locals == null) {
labels = null;
return;
}
if (cst instanceof Integer) {
push(Opcodes.INTEGER);
} else if (cst instanceof Long) {
push(Opcodes.LONG);
push(Opcodes.TOP);
} else if (cst instanceof Float) {
push(Opcodes.FLOAT);
} else if (cst instanceof Double) {
push(Opcodes.DOUBLE);
push(Opcodes.TOP);
} else if (cst instanceof String) {
push("java/lang/String");
} else if (cst instanceof Type) {
int sort = ((Type) cst).getSort();
if (sort == Type.OBJECT || sort == Type.ARRAY) {
push("java/lang/Class");
} else if (sort == Type.METHOD) {
push("java/lang/invoke/MethodType");
} else {
throw new IllegalArgumentException();
}
} else if (cst instanceof Handle) {
push("java/lang/invoke/MethodHandle");
} else {
throw new IllegalArgumentException();
}
labels = null;
}
示例9: check
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
/**
* Checks that this field node is compatible with the given ASM API version.
* This methods checks that this node, and all its nodes recursively, do not
* contain elements that were introduced in more recent versions of the ASM
* API than the given version.
*
* @param api
* an ASM API version. Must be one of {@link Opcodes#ASM4} or
* {@link Opcodes#ASM5}.
*/
public void check(final int api) {
if (api == Opcodes.ASM4) {
if (visibleTypeAnnotations != null
&& visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (invisibleTypeAnnotations != null
&& invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
}
}
示例10: visitMethodInsn
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitMethodInsn(final int opcode, final String owner,
final String name, final String desc, final boolean itf) {
if (api < Opcodes.ASM5) {
super.visitMethodInsn(opcode, owner, name, desc, itf);
return;
}
doVisitMethodInsn(opcode, owner, name, desc, itf);
}
示例11: visitMethodInsn
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitMethodInsn(int opcode, String owner, String name,
String desc, boolean itf) {
if (api < Opcodes.ASM5) {
super.visitMethodInsn(opcode, owner, name, desc, itf);
return;
}
doVisitMethodInsn(opcode, owner, name, desc, itf);
}
示例12: push
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
/**
* Generates the instruction to push the given value on the stack.
*
* @param value
* the value to be pushed on the stack. May be <tt>null</tt>.
*/
public void push(final String value) {
if (value == null) {
mv.visitInsn(Opcodes.ACONST_NULL);
} else {
mv.visitLdcInsn(value);
}
}
示例13: visitVarInsn
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitVarInsn(final int opcode, final int var) {
Type type;
switch (opcode) {
case Opcodes.LLOAD:
case Opcodes.LSTORE:
type = Type.LONG_TYPE;
break;
case Opcodes.DLOAD:
case Opcodes.DSTORE:
type = Type.DOUBLE_TYPE;
break;
case Opcodes.FLOAD:
case Opcodes.FSTORE:
type = Type.FLOAT_TYPE;
break;
case Opcodes.ILOAD:
case Opcodes.ISTORE:
type = Type.INT_TYPE;
break;
default:
// case Opcodes.ALOAD:
// case Opcodes.ASTORE:
// case RET:
type = OBJECT_TYPE;
break;
}
mv.visitVarInsn(opcode, remap(var, type));
}
示例14: widen
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
void widen(Wrapper ws, Wrapper wt) {
if (ws != wt) {
int opcode = wideningOpcodes[ws.ordinal()][wt.ordinal()];
if (opcode != Opcodes.NOP) {
visitInsn(opcode);
}
}
}
示例15: visitField
import jdk.internal.org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public FieldVisitor visitField(final int access, final String name,
final String desc, final String signature, final Object value) {
if (computeSVUID) {
if ("serialVersionUID".equals(name)) {
// since the class already has SVUID, we won't be computing it.
computeSVUID = false;
hasSVUID = true;
}
/*
* Remember field for SVUID computation For field modifiers, only
* the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC,
* ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when
* computing serialVersionUID values.
*/
if ((access & Opcodes.ACC_PRIVATE) == 0
|| (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) {
int mods = access
& (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE
| Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
| Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT);
svuidFields.add(new Item(name, mods, desc));
}
}
return super.visitField(access, name, desc, signature, value);
}