當前位置: 首頁>>代碼示例>>Java>>正文


Java Type類代碼示例

本文整理匯總了Java中org.objectweb.asm.Type的典型用法代碼示例。如果您正苦於以下問題:Java Type類的具體用法?Java Type怎麽用?Java Type使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Type類屬於org.objectweb.asm包,在下文中一共展示了Type類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onMethodEnter

import org.objectweb.asm.Type; //導入依賴的package包/類
@SuppressWarnings("unused")
protected void onMethodEnter() {
	if (done) return;

	overridden = true;
	Label start  = new Label();
	Label normal = new Label();
	super.visitLabel(start);
	super.visitFieldInsn(Opcodes.GETSTATIC, CONFIGURATION, CONFIGURATION_FIELD_NAME, Type.INT_TYPE.getDescriptor());
	super.visitInsn(Opcodes.DUP);
	super.visitJumpInsn(Opcodes.IFEQ, normal);
	super.visitInsn(Opcodes.IRETURN);
	super.visitLabel(normal);
	super.visitInsn(Opcodes.POP);
	Label end = new Label();
	super.visitJumpInsn(Opcodes.GOTO, end);
	super.visitLabel(end);
	super.visitTryCatchBlock(start, normal, end, Type.getType(Throwable.class).getDescriptor());
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:20,代碼來源:RuntimeInstrument.java

示例2: generateMethodTest6

import org.objectweb.asm.Type; //導入依賴的package包/類
/**
 *  Generate test with an invokedynamic, a static bootstrap method with an extra arg that is a
 *  MethodHandle of kind invoke interface. The target method is a default method into an interface
 *  that is at the end of a chain of interfaces.
 */
private void generateMethodTest6(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test6", "()V",
      null, null);
  MethodType mt = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
      MethodType.class, MethodHandle.class);
  Handle bootstrap = new Handle(Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
      "bsmCreateCallCallingtargetMethodTest7", mt.toMethodDescriptorString(), false);
  mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(InvokeCustom.class));
  mv.visitInsn(Opcodes.DUP);
  mv.visitMethodInsn(
      Opcodes.INVOKESPECIAL, Type.getInternalName(InvokeCustom.class), "<init>", "()V", false);
  mv.visitInvokeDynamicInsn("targetMethodTest7", "(Linvokecustom/J;)V", bootstrap,
      new Handle(Opcodes.H_INVOKEINTERFACE, Type.getInternalName(J.class),
          "targetMethodTest7", "()V", true));
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:23,代碼來源:TestGenerator.java

示例3: checkAnnotation

import org.objectweb.asm.Type; //導入依賴的package包/類
private boolean checkAnnotation(AnnotationNode a) {
  if (a.desc.equals("Lcom/rakuten/tech/mobile/perf/core/annotations/Exists;")) {
    if (!exists(((Type) a.values.get(1)).getClassName())) {
      return false;
    }
  } else if (a.desc
      .equals("Lcom/rakuten/tech/mobile/perf/core/annotations/MinCompileSdkVersion;")) {
    if (_compileSdkVersion < (int) a.values.get(1)) {
      return false;
    }
  } else if (a.desc
      .equals("Lcom/rakuten/tech/mobile/perf/core/annotations/MaxCompileSdkVersion;")) {
    if (_compileSdkVersion > (int) a.values.get(1)) {
      return false;
    }
  }
  return true;
}
 
開發者ID:rakutentech,項目名稱:android-perftracking,代碼行數:19,代碼來源:ClassTrimmer.java

示例4: hookMethod

import org.objectweb.asm.Type; //導入依賴的package包/類
/**
 * (none-javadoc)
 *
 * @see com.fuxi.javaagent.hook.AbstractClassHook#hookMethod(int, String, String, String, String[], MethodVisitor) (String)
 */
@Override
protected MethodVisitor hookMethod(int access, String name, String desc,
                                   String signature, String[] exceptions, MethodVisitor mv) {
    if ("resolveClass".equals(name) && "(Ljava/io/ObjectStreamClass;)Ljava/lang/Class;".equals(desc)) {
        return new AdviceAdapter(Opcodes.ASM5, mv, access, name, desc) {
            @Override
            protected void onMethodEnter() {
                loadArg(0);
                invokeStatic(Type.getType(DeserializationHook.class),
                        new Method("checkDeserializationClass", "(Ljava/io/ObjectStreamClass;)V"));
            }
        };
    }
    return mv;
}
 
開發者ID:baidu,項目名稱:openrasp,代碼行數:21,代碼來源:DeserializationHook.java

示例5: putMethod

import org.objectweb.asm.Type; //導入依賴的package包/類
public void putMethod(MethodRef a, MethodRef b) {
    Method descriptor = new Method(b.getMethodName(), b.getMethodDesc());
    TypeNameEnforcer returnType = new TypeNameEnforcer(descriptor.getReturnType()
            .getClassName());
    if (classMappings.containsKey(returnType.getJvmStandard())) {
        returnType = new TypeNameEnforcer(classMappings.get(returnType.getJvmStandard()));
    }
    List<TypeNameEnforcer> parameterTypes = new ArrayList<>();
    for (Type type : descriptor.getArgumentTypes()) {
        if (classMappings.containsKey(new TypeNameEnforcer(type.getClassName()).getJvmStandard())) {
            parameterTypes.add(new TypeNameEnforcer(classMappings.get(new TypeNameEnforcer
                    (type.getClassName()).getJvmStandard())));
        } else {
            parameterTypes.add(new TypeNameEnforcer(type.getClassName()));
        }
    }
    MethodRef newB = new MethodRef(b.getClassName(), b.getMethodName(), createDescriptor
            (returnType, parameterTypes));
    methodMappings.put(a, newB);
}
 
開發者ID:PizzaCrust,項目名稱:GraphiteMappings,代碼行數:21,代碼來源:Mappings.java

示例6: getMethodTransformers

import org.objectweb.asm.Type; //導入依賴的package包/類
@Override
public MethodTransformer[] getMethodTransformers() {
	MethodTransformer loadWorldTransformer = new MethodTransformer() {
		public String getMethodName() {return CoreLoader.isObfuscated ? "a" : "loadWorld";}
		public String getDescName() {return "(L" + (CoreLoader.isObfuscated ? "bnq" : Type.getInternalName(WorldClient.class)) + ";Ljava/lang/String;)V";}
		
		public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) {
			CLTLog.info("Found method: " + method.name + " " + method.desc);
			CLTLog.info("begining at start of method " + getMethodName());
			
			//TransformerUtil.onWorldLoad(WorldClient worldClientIn)
			InsnList toInsert = new InsnList();
			toInsert.add(new VarInsnNode(ALOAD, 1)); //worldClientIn
			toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(TransformerUtil.class),
					"onWorldLoad", "(L" + Type.getInternalName(WorldClient.class) + ";)V", false));
			method.instructions.insertBefore(method.instructions.getFirst(), toInsert);
		}
	};
	
	return new MethodTransformer[] {loadWorldTransformer};
}
 
開發者ID:18107,項目名稱:MC-Ray-Tracer,代碼行數:22,代碼來源:MinecraftTransformer.java

示例7: unboxType

import org.objectweb.asm.Type; //導入依賴的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);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:18,代碼來源:ManagedProxyClassGenerator.java

示例8: visit

import org.objectweb.asm.Type; //導入依賴的package包/類
@Override
public void visit(Branch.Condition.NumLoopEnd cond) {
  assert (destLabel != null);
  il.add(new VarInsnNode(ALOAD, slot(cond.var())));
  il.add(new TypeInsnNode(CHECKCAST, Type.getInternalName(Number.class)));
  il.add(new VarInsnNode(ALOAD, slot(cond.limit())));
  il.add(new TypeInsnNode(CHECKCAST, Type.getInternalName(Number.class)));
  il.add(new VarInsnNode(ALOAD, slot(cond.step())));
  il.add(new TypeInsnNode(CHECKCAST, Type.getInternalName(Number.class)));
  il.add(DispatchMethods.continueLoop());

  if (!isSub() || resolver.isLocalLabel(destLabel)) {
    // local jump
    il.add(new JumpInsnNode(IFEQ, l(destLabel)));
  } else {
    // non-local jump
    LabelNode l_nojump = new LabelNode();
    il.add(new JumpInsnNode(IFNE, l_nojump));
    il.add(_nonLocalGoto(destLabel));
    il.add(l_nojump);
    il.add(new FrameNode(F_SAME, 0, null, 0, null));
  }
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:24,代碼來源:BytecodeEmitVisitor.java

示例9: visitTypeInsn

import org.objectweb.asm.Type; //導入依賴的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();
    }
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:21,代碼來源:InstructionAdapter.java

示例10: generateMethodTest7

import org.objectweb.asm.Type; //導入依賴的package包/類
/**
 *  Generate test with an invokedynamic, a static bootstrap method with an extra arg that is a
 *  MethodHandle of kind invoke interface. The target method is a method into an interface
 *  that is shadowed by another definition into a sub interfaces.
 */
private void generateMethodTest7(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test7", "()V",
      null, null);
  MethodType mt = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
      MethodType.class, MethodHandle.class);
  Handle bootstrap = new Handle(Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
      "bsmCreateCallCallingtargetMethodTest8", mt.toMethodDescriptorString(), false);
  mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(InvokeCustom.class));
  mv.visitInsn(Opcodes.DUP);
  mv.visitMethodInsn(
      Opcodes.INVOKESPECIAL, Type.getInternalName(InvokeCustom.class), "<init>", "()V", false);
  mv.visitInvokeDynamicInsn("targetMethodTest8", "(Linvokecustom/J;)V", bootstrap,
      new Handle(Opcodes.H_INVOKEINTERFACE, Type.getInternalName(J.class),
          "targetMethodTest8", "()V", true));
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:23,代碼來源:TestGenerator.java

示例11: toString

import org.objectweb.asm.Type; //導入依賴的package包/類
@Override
public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append(String.format("CLASS[states=%d]{", className.getStateCount()));
    Iterator<State> it = Arrays.asList(State.values()).iterator();
    boolean needsSeparator = false;
    while(it.hasNext()) {
        State next = it.next();
        Type type = className.getByState(next);
        if(type != null) {
            if(needsSeparator) builder.append(",");
            builder.append(next.name());
            builder.append("=");
            builder.append(type.getInternalName());
            needsSeparator = true;
        }
    }
    builder.append("}");
    return builder.toString();
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:21,代碼來源:ASMClass.java

示例12: isSubTypeOf

import org.objectweb.asm.Type; //導入依賴的package包/類
@Override
protected boolean isSubTypeOf(final BasicValue value,
        final BasicValue expected) {
    Type expectedType = expected.getType();
    Type type = value.getType();
    switch (expectedType.getSort()) {
    case Type.INT:
    case Type.FLOAT:
    case Type.LONG:
    case Type.DOUBLE:
        return type.equals(expectedType);
    case Type.ARRAY:
    case Type.OBJECT:
        if ("Lnull;".equals(type.getDescriptor())) {
            return true;
        } else if (type.getSort() == Type.OBJECT
                || type.getSort() == Type.ARRAY) {
            return isAssignableFrom(expectedType, type);
        } else {
            return false;
        }
    default:
        throw new Error("Internal error");
    }
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:26,代碼來源:SimpleVerifier.java

示例13: boxParameterAndLoad

import org.objectweb.asm.Type; //導入依賴的package包/類
private void boxParameterAndLoad(int argIndex) {
    Type type = argTypes[argIndex];
    int stackIndex = getStackIndex(argIndex);
    
    switch (type.getSort()) {
        case Type.OBJECT: //no need to box Object
            aa.visitVarInsn(ALOAD, stackIndex);  
            break;
            
        default:
            // aa.loadArg(argIndex); //doesn't work...
            aa.visitVarInsn(type.getOpcode(Opcodes.ILOAD), stackIndex);
            aa.valueOf(type);
            break;
    }
}
 
開發者ID:willfleury,項目名稱:prometheus-metrics-agent,代碼行數:17,代碼來源:AbstractInjector.java

示例14: visitLabel

import org.objectweb.asm.Type; //導入依賴的package包/類
@Override
public void visitLabel(Label label) {
    //這個super.xx必須放到第一行
    super.visitLabel(label);
    ArrayList<String> exceptions = matchHandle.get(label);
    if(label != null && exceptions != null){
        logger.log(Level.INFO,"instrument "+exceptions);
        Label matched = new Label();
        Label end = new Label();
        //捕獲的是目標exception的實例才進行處理
        final int N = exceptions.size() - 1;
        if (N >= 1) {
            for (int i = 0; i < N; i++) {
                compareInstance(IFNE, exceptions.get(i), matched);
            }
        }
        compareInstance(IFEQ, exceptions.get(N), end);
        visitLabel(matched);
        dup();
        invokeStatic(Type.getObjectType("test/github/monitor/Monitor")
                , new Method("pushException", "(Ljava/lang/Throwable;)V"));
        visitLabel(end);
    }
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:25,代碼來源:ExceptionHookMethodAdapter.java

示例15: rawBinaryOperator

import org.objectweb.asm.Type; //導入依賴的package包/類
public static AbstractInsnNode rawBinaryOperator(String methodName, Type returnType,
    Type argType) {
  return new MethodInsnNode(
      INVOKESTATIC,
      Type.getInternalName(LuaMathOperators.class),
      methodName,
      Type.getMethodDescriptor(
          returnType,
          argType,
          argType),
      false);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:13,代碼來源:OperatorMethods.java


注:本文中的org.objectweb.asm.Type類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。