本文整理匯總了Java中org.objectweb.asm.MethodVisitor.visitJumpInsn方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodVisitor.visitJumpInsn方法的具體用法?Java MethodVisitor.visitJumpInsn怎麽用?Java MethodVisitor.visitJumpInsn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.MethodVisitor
的用法示例。
在下文中一共展示了MethodVisitor.visitJumpInsn方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: insertCollectionStart
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
private void insertCollectionStart(MethodVisitor mv) {
// collection.iterator()
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "iterator", "()Ljava/util/Iterator;", true);
mv.visitVarInsn(ASTORE, varArray);
mv.visitLabel(loopStart);
// Append a new frame preserving the same locals from the last one
mv.visitFrame(F_APPEND, 2, new Object[]{BUILDER.getInternalName(), "java/util/Iterator"}, 0, null);
// if(iterator.hasNext()) break;
mv.visitVarInsn(ALOAD, varArray);
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true);
mv.visitJumpInsn(IFEQ, loopEnd);
// (String)iterator.next()
mv.visitVarInsn(ALOAD, varArray);
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(member.component));
mv.visitVarInsn(ASTORE, varObject);
}
示例2: unboxType
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
private void unboxType(MethodVisitor methodVisitor, Class<?> primitiveClass) {
// Float f = (Float) tmp
// f==null?0:f.floatValue()
Class<?> boxedType = BOXED_TYPES.get(primitiveClass);
Type primitiveType = Type.getType(primitiveClass);
methodVisitor.visitTypeInsn(CHECKCAST, Type.getInternalName(boxedType));
methodVisitor.visitInsn(DUP);
Label exit = new Label();
Label elseValue = new Label();
methodVisitor.visitJumpInsn(IFNONNULL, elseValue);
methodVisitor.visitInsn(POP);
pushDefaultValue(methodVisitor, primitiveClass);
methodVisitor.visitJumpInsn(GOTO, exit);
methodVisitor.visitLabel(elseValue);
methodVisitor.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(boxedType), primitiveClass.getSimpleName() + "Value", Type.getMethodDescriptor(primitiveType), false);
methodVisitor.visitLabel(exit);
}
示例3: visit
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
@Override
public Object visit(ASTStreamBlock node, Object data) throws CompileException {
TContextFunc func_ctx = (TContextFunc) getTopContext().getClosestAncestor(AbsType.FORM_FUNC);
if (func_ctx != null) {
MethodVisitor mv = func_ctx.getMethodVisitor();
Label streamblock_end_label = new Label();
mv.visitLabel(streamblock_end_label);
node.setStreamBlockEndLabel(streamblock_end_label);
LangUnitNode stream_node = (LangUnitNode) node.jjtGetParent();
Debug.assertion(stream_node != null, "stream_node should be valid");
if (stream_node.isNodeId(JJTSTREAM)) {
int catchnode_child_idx = stream_node.getChildIdxWithId(JJTCATCH, 0);
if (catchnode_child_idx != -1) {
Label stream_end_label = stream_node.getStreamEndLabel();
Debug.assertion(stream_end_label != null, "stream_end_label should be valid");
LOG.info("GOTO stream_end_label({}) in stream block end", stream_end_label);
mv.visitJumpInsn(GOTO, stream_end_label);
}
}
}
return null;
}
示例4: addGetMetaClass
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
private void addGetMetaClass() {
Label lookup = new Label();
MethodVisitor methodVisitor = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "getMetaClass", RETURN_META_CLASS, null, null);
methodVisitor.visitCode();
// if (this.metaClass != null) { return this.metaClass; }
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitFieldInsn(Opcodes.GETFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());
methodVisitor.visitInsn(Opcodes.DUP);
methodVisitor.visitJumpInsn(Opcodes.IFNULL, lookup);
methodVisitor.visitInsn(Opcodes.ARETURN);
methodVisitor.visitLabel(lookup);
methodVisitor.visitFrame(Opcodes.F_NEW, 1, new Object[]{className}, 1, new Object[]{META_CLASS_TYPE.getInternalName()});
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); // for storing to field
// GroovySystem.getMetaClassRegistry()
methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, GROOVY_SYSTEM_TYPE.getInternalName(), "getMetaClassRegistry", RETURN_META_CLASS_REGISTRY, false);
// this.getClass()
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, OBJECT_TYPE.getInternalName(), "getClass", RETURN_CLASS, false);
// getMetaClass(..)
methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, META_CLASS_REGISTRY_TYPE.getInternalName(), "getMetaClass", RETURN_META_CLASS_FROM_CLASS, true);
// this.metaClass = <value>
methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());
// return this.metaClass
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitFieldInsn(Opcodes.GETFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());
methodVisitor.visitInsn(Opcodes.ARETURN);
methodVisitor.visitMaxs(4, 1);
methodVisitor.visitEnd();
}
示例5: insertArrayStart
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
private void insertArrayStart(MethodVisitor mv, BytecodeGenerator generator) {
// Store the array in a local variable
mv.visitVarInsn(ASTORE, varArray);
// array.length
mv.visitVarInsn(ALOAD, varArray);
mv.visitInsn(ARRAYLENGTH);
mv.visitVarInsn(ISTORE, varLength);
// i = 0
mv.visitInsn(ICONST_0);
mv.visitVarInsn(ISTORE, varIndex);
mv.visitLabel(loopStart);
// Create a compressed frame
mv.visitFrame(F_FULL, 6, new Object[]{generator.className,
generator.data.getDataType().getInternalName(), BUILDER.getInternalName(),
member.clazzType.getInternalName(), INTEGER, INTEGER}, 0, new Object[0]);
// if(index >= length) break;
mv.visitVarInsn(ILOAD, varIndex);
mv.visitVarInsn(ILOAD, varLength);
mv.visitJumpInsn(IF_ICMPGE, loopEnd);
// array[i]
mv.visitVarInsn(ALOAD, varArray);
mv.visitVarInsn(ILOAD, varIndex);
mv.visitInsn(AALOAD);
mv.visitVarInsn(ASTORE, varObject);
}
示例6: insertArrayEnd
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
private void insertArrayEnd(MethodVisitor mv) {
mv.visitInsn(POP);
mv.visitIincInsn(varIndex, 1);
mv.visitJumpInsn(GOTO, loopStart);
mv.visitLabel(loopEnd);
mv.visitFrame(F_CHOP, 3, null, 0, null);
}
示例7: accept
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
@Override
public void accept(final MethodVisitor mv) {
mv.visitJumpInsn(opcode, label.getLabel());
acceptAnnotations(mv);
}
示例8: jumpToLabelIfStackEvaluatesToTrue
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
private void jumpToLabelIfStackEvaluatesToTrue(MethodVisitor methodVisitor, Label label) {
methodVisitor.visitJumpInsn(IFNE, label);
}
示例9: applyConventionMappingToGetter
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
public void applyConventionMappingToGetter(PropertyMetaData property, Method getter) throws Exception {
// GENERATE public <type> <getter>() { return (<type>)getConventionMapping().getConventionValue(super.<getter>(), '<prop>', __<prop>__); }
String flagName = propFieldName(property);
String getterName = getter.getName();
Type returnType = Type.getType(getter.getReturnType());
String methodDescriptor = Type.getMethodDescriptor(returnType);
MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, getterName, methodDescriptor, null, EMPTY_STRINGS);
methodVisitor.visitCode();
if (hasMappingField) {
// if (conventionMapping == null) { return super.<getter>; }
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitFieldInsn(Opcodes.GETFIELD, generatedType.getInternalName(), MAPPING_FIELD, CONVENTION_MAPPING_FIELD_DESCRIPTOR);
Label useConvention = new Label();
methodVisitor.visitJumpInsn(Opcodes.IFNONNULL, useConvention);
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, superclassType.getInternalName(), getterName, methodDescriptor, false);
methodVisitor.visitInsn(returnType.getOpcode(Opcodes.IRETURN));
methodVisitor.visitLabel(useConvention);
}
// else { return (<type>)getConventionMapping().getConventionValue(super.<getter>(), '<prop>', __<prop>__); }
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, CONVENTION_AWARE_TYPE.getInternalName(), "getConventionMapping", Type.getMethodDescriptor(CONVENTION_MAPPING_TYPE), true);
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, superclassType.getInternalName(), getterName, methodDescriptor, false);
Type boxedType = null;
if (getter.getReturnType().isPrimitive()) {
// Box value
boxedType = Type.getType(JavaReflectionUtil.getWrapperTypeForPrimitiveType(getter.getReturnType()));
String valueOfMethodDescriptor = Type.getMethodDescriptor(boxedType, returnType);
methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, boxedType.getInternalName(), "valueOf", valueOfMethodDescriptor, false);
}
methodVisitor.visitLdcInsn(property.getName());
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitFieldInsn(Opcodes.GETFIELD, generatedType.getInternalName(), flagName,
Type.BOOLEAN_TYPE.getDescriptor());
String getConventionValueDesc = Type.getMethodDescriptor(ConventionMapping.class.getMethod(
"getConventionValue", Object.class, String.class, Boolean.TYPE));
methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, CONVENTION_MAPPING_TYPE.getInternalName(), "getConventionValue", getConventionValueDesc, true);
if (getter.getReturnType().isPrimitive()) {
// Unbox value
methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, boxedType.getInternalName());
String valueMethodDescriptor = Type.getMethodDescriptor(returnType);
methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, boxedType.getInternalName(), getter.getReturnType().getName() + "Value", valueMethodDescriptor, false);
} else {
// Cast to return type
methodVisitor.visitTypeInsn(Opcodes.CHECKCAST,
getter.getReturnType().isArray() ? "[" + returnType.getElementType().getDescriptor()
: returnType.getInternalName());
}
methodVisitor.visitInsn(returnType.getOpcode(Opcodes.IRETURN));
methodVisitor.visitMaxs(0, 0);
methodVisitor.visitEnd();
}
示例10: makeClazz
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
private static byte[] makeClazz() {
// Code generated the class below using asm.
String clazzName = DeoptimizeOnExceptionTest.class.getName().replace('.', '/');
final ClassWriter w = new ClassWriter(0);
w.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC,
"t/TestJSR", null, "java/lang/Object",
new String[]{"java/lang/Runnable"});
MethodVisitor mv = w.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, new String[]{});
mv.visitCode();
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
mv.visitInsn(Opcodes.RETURN);
mv.visitMaxs(10, 10);
mv.visitEnd();
mv = w.visitMethod(Opcodes.ACC_PUBLIC, "run", "()V", null, null);
mv.visitCode();
mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "getM", "()Ljava/lang/Object;", false);
Label l1 = new Label();
mv.visitJumpInsn(Opcodes.JSR, l1);
mv.visitInsn(Opcodes.RETURN);
mv.visitLabel(l1);
mv.visitVarInsn(Opcodes.ASTORE, 1);
Label lElse = new Label();
Label lEnd = new Label();
mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/System", "currentTimeMillis", "()J", false);
mv.visitInsn(Opcodes.POP2);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "getM", "()Ljava/lang/Object;", false);
mv.visitInsn(Opcodes.DUP);
mv.visitJumpInsn(Opcodes.IFNULL, lElse);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "methodA", "()V", false);
mv.visitJumpInsn(Opcodes.GOTO, lEnd);
mv.visitLabel(lElse);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "methodB", "()V", false);
mv.visitLabel(lEnd);
mv.visitVarInsn(Opcodes.RET, 1);
mv.visitMaxs(10, 10);
mv.visitEnd();
return w.toByteArray();
}
示例11: insertSectionStart
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
@Override
public void insertSectionStart(MethodVisitor mv, BytecodeGenerator generator) {
mv.visitJumpInsn(inverted ? IFNULL : IFNONNULL, ifEnd);
}
示例12: insertSectionStart
import org.objectweb.asm.MethodVisitor; //導入方法依賴的package包/類
@Override
public void insertSectionStart(MethodVisitor mv, BytecodeGenerator generator) {
mv.visitJumpInsn(inverted ? IFNE : IFEQ, ifEnd);
}