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


Java Type.getInternalName方法代碼示例

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


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

示例1: getIdentifier

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public Object getIdentifier() {
    Type typ = getTypeRef();
    if (typ == null) return null;
    switch (typ.getSort()) {
        case Type.OBJECT:
            return typ.getInternalName();
        case Type.ARRAY:
            int i = 0;
            final String nam = typ.getInternalName();
            while (nam.charAt(i) == '[') i++;
            if (nam.charAt(i) == 'L' && nam.endsWith(";"))
                return nam.substring(i + 1, nam.length() - 1);
            break;
    }
    return null;
}
 
開發者ID:iamahuman,項目名稱:IdentObf,代碼行數:18,代碼來源:AsmTypeRefReference.java

示例2: generateMethodTest5

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 shadows another default method from a super interface.
 */
private void generateMethodTest5(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test5", "()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),
      "bsmCreateCallCallingtargetMethodTest6", 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("targetMethodTest6", "(Linvokecustom/I;)V", bootstrap,
      new Handle(Opcodes.H_INVOKEINTERFACE, Type.getInternalName(I.class),
          "targetMethodTest6", "()V", true));
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:23,代碼來源:TestGenerator.java

示例3: 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

示例4: visitClass

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private void visitClass() {
		internalName = Type.getInternalName(clazz); // com/github/javalbert/reflection/test/Foo
		String classAccessSimpleName = clazz.getSimpleName() + "ClassAccess"; // FooClassAccess
		classAccessInternalName = internalName + "$" + classAccessSimpleName; // com/github/javalbert/reflection/test/Foo$FooClassAccess
		
		cw.visit(
				V1_8,
				ACC_PUBLIC + ACC_SUPER,
				classAccessInternalName,
				internalName,
				"sun/reflect/MagicAccessorImpl"/*CREDIT: https://github.com/dimzon/reflectasm/blob/master/src/com/esotericsoftware/reflectasm/ClassAccess.java*/,
				new String[] { Type.getInternalName(ClassAccess.class) });
		cw.visitSource(clazz.getSimpleName() + ".java", null);
		cw.visitInnerClass(classAccessInternalName, internalName, classAccessSimpleName, ACC_PUBLIC + ACC_STATIC);
		
		// For the lamda function Class::getName in methodIndex() method
		// Appears not to be required
//		cw.visitInnerClass(
//				"java/lang/invoke/MethodHandles$Lookup",
//				"java/lang/invoke/MethodHandles",
//				"Lookup",
//				ACC_PUBLIC + ACC_FINAL + ACC_STATIC);
		
		classAccessTypeDescriptor = "L" + classAccessInternalName + ";";
		classTypeDescriptor = "L" + internalName + ";";
	}
 
開發者ID:Javalbert,項目名稱:faster-than-reflection,代碼行數:27,代碼來源:ClassAccessFactory.java

示例5: generateMethodTest12

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 get instance. The method handle read an instance field from a class.
 */
private void generateMethodTest12(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test12", "()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),
      "bsmCreateCallCallingtargetMethod", mt.toMethodDescriptorString(), false);
  mv.visitFieldInsn(Opcodes.GETSTATIC,
      "java/lang/System",
      "out",
      "Ljava/io/PrintStream;");
  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("instanceField1", "(Linvokecustom/InvokeCustom;)Ljava/lang/String;",
      bootstrap, new Handle(Opcodes.H_GETFIELD, Type.getInternalName(InvokeCustom.class),
          "instanceField1", "Ljava/lang/String;", false));
  mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
      "java/io/PrintStream",
      "println",
      "(Ljava/lang/String;)V", false);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:30,代碼來源:TestGenerator.java

示例6: booleanValue

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static AbstractInsnNode booleanValue() {
  return new MethodInsnNode(
      INVOKEVIRTUAL,
      Type.getInternalName(Boolean.class),
      "booleanValue",
      Type.getMethodDescriptor(
          Type.BOOLEAN_TYPE),
      false);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:10,代碼來源:BoxedPrimitivesMethods.java

示例7: loadReturnBuffer

import org.objectweb.asm.Type; //導入方法依賴的package包/類
static AbstractInsnNode loadReturnBuffer() {
  return new MethodInsnNode(
      INVOKEINTERFACE,
      Type.getInternalName(ExecutionContext.class),
      "getReturnBuffer",
      Type.getMethodDescriptor(
          Type.getType(ReturnBuffer.class)),
      true);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:10,代碼來源:BytecodeEmitVisitor.java

示例8: unboxedNumberToLuaFormatString

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static AbstractInsnNode unboxedNumberToLuaFormatString(Type tpe) {
  Check.isTrue(tpe.equals(Type.DOUBLE_TYPE) || tpe.equals(Type.LONG_TYPE));
  return new MethodInsnNode(
      INVOKESTATIC,
      Type.getInternalName(LuaFormat.class),
      "toString",
      Type.getMethodDescriptor(
          Type.getType(String.class),
          tpe),
      false);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:12,代碼來源:ConversionMethods.java

示例9: booleanValueOf

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static AbstractInsnNode booleanValueOf() {
  return new MethodInsnNode(
      INVOKESTATIC,
      Type.getInternalName(Conversions.class),
      "booleanValueOf",
      Type.getMethodDescriptor(
          Type.BOOLEAN_TYPE,
          Type.getType(Object.class)),
      false);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:11,代碼來源:ConversionMethods.java

示例10: generateMethodTest3

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 *  Generate test with an invokedynamic, a static bootstrap method with extra args and no arg
 *  to the target method.
 */
private void generateMethodTest3(ClassVisitor cv) {
  MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "test3", "()V",
      null, null);
  MethodType mt = MethodType.methodType(
          CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class, int.class,
      long.class, float.class, double.class);
  Handle bootstrap = new Handle( Opcodes.H_INVOKESTATIC, Type.getInternalName(InvokeCustom.class),
      "bsmLookupStaticWithExtraArgs", mt.toMethodDescriptorString(), false);
  mv.visitInvokeDynamicInsn("targetMethodTest3", "()V", bootstrap, new Integer(1),
      new Long(123456789), new Float(123.456), new Double(123456.789123));
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(-1, -1);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:18,代碼來源:TestGenerator.java

示例11: loadBoxedBoolean

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static AbstractInsnNode loadBoxedBoolean(boolean value) {
  return new FieldInsnNode(
      GETSTATIC,
      Type.getInternalName(Boolean.class),
      value ? "TRUE" : "FALSE",
      Type.getDescriptor(Boolean.class));
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:8,代碼來源:BoxedPrimitivesMethods.java

示例12: throwExceptionsList

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static InsnList throwExceptionsList(MethodNode methodNode, ClassNode classNode) {
    try {
        String runtimeException = Type.getInternalName(RuntimeException.class);
        Constructor<RuntimeException> constructor =
                RuntimeException.class.getConstructor(String.class);
        
        InsnList instructions = new InsnList();
        instructions.add(
                new TypeInsnNode(Opcodes.NEW, runtimeException));
        instructions.add(new InsnNode(Opcodes.DUP));
        
        String className = classNode.name.replace('/', '.');
        instructions.add(new LdcInsnNode("Method " + methodNode.name + " in " + className
                + " not mocked. "
                + "See http://g.co/androidstudio/not-mocked for details."));
        instructions.add(new MethodInsnNode(
                Opcodes.INVOKESPECIAL,
                runtimeException,
                CONSTRUCTOR,
                Type.getType(constructor).getDescriptor(),
                false));
        instructions.add(new InsnNode(Opcodes.ATHROW));
        
        return instructions;
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:codezjx,項目名稱:MockableJarGenerator,代碼行數:29,代碼來源:MockableJarGenerator.java

示例13: rawset

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static AbstractInsnNode rawset() {
  return new MethodInsnNode(
      INVOKEVIRTUAL,
      Type.getInternalName(Table.class),
      "rawset",
      Type.getMethodDescriptor(
          Type.VOID_TYPE,
          Type.getType(Object.class),
          Type.getType(Object.class)),
      false);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:12,代碼來源:TableMethods.java

示例14: dynamic

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static AbstractInsnNode dynamic(String methodName, int numArgs) {
  ArrayList<Type> args = new ArrayList<>();
  args.add(Type.getType(ExecutionContext.class));
  for (int i = 0; i < numArgs; i++) {
    args.add(Type.getType(Object.class));
  }
  return new MethodInsnNode(
      INVOKESTATIC,
      Type.getInternalName(Dispatch.class),
      methodName,
      Type.getMethodDescriptor(
          Type.VOID_TYPE,
          args.toArray(new Type[0])),
      false);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:16,代碼來源:DispatchMethods.java

示例15: generateMethodArgs

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static byte[] generateMethodArgs(Class<?> classToProxy, Method method, int methodId) throws Exception {

        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);

        String classToProxyDescriptor = Type.getDescriptor(classToProxy);
        String classToProxyInternalName = Type.getInternalName(classToProxy);

        String suffix = SUFFIX_START + method.getName() + methodId;
        String selfClassInternalName = classToProxyInternalName + suffix;
        String selfClassDescriptor = BytecodeGenUtils.makeSuffixClassDescriptor(classToProxyDescriptor, suffix);

        String updaterClassInternalName = classToProxyInternalName + MethodArgumentssUpdaterGenerator.SUFFIX_START + method.getName() + methodId;

        String constDesc = Type.getMethodDescriptor(Type.VOID_TYPE,
                Stream.concat(Stream.of(List.class), Stream.of(method.getParameterTypes())).map(Type::getType)
                        .toArray(Type[]::new));

        cw.visit(52, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, selfClassInternalName, null, "java/lang/Object",
                new String[] { "io/primeval/reflex/arguments/Arguments" });
        Parameter[] parameters = method.getParameters();

        generateFields(method, cw, parameters);
        generateConstructor(method, cw, selfClassInternalName, selfClassDescriptor, constDesc, parameters);
        generateHashCodeMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);
        generateEqualsMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);
        generateToStringMethod(cw, selfClassInternalName, selfClassDescriptor, parameters);

        generateUpdaterMethod(cw, selfClassInternalName, selfClassDescriptor, updaterClassInternalName, constDesc, parameters);

        generateParametersGetter(cw, selfClassInternalName, selfClassDescriptor);
        generateArgumentGetters(cw, selfClassInternalName, selfClassDescriptor, parameters);
        cw.visitEnd();

        return cw.toByteArray();
    }
 
開發者ID:primeval-io,項目名稱:primeval-reflex,代碼行數:36,代碼來源:MethodArgumentsGenerator.java


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