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


Java Type.getMethodType方法代碼示例

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


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

示例1: mapType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type mapType(Type t) {
    switch (t.getSort()) {
    case Type.ARRAY:
        String s = mapDesc(t.getElementType().getDescriptor());
        for (int i = 0; i < t.getDimensions(); ++i) {
            s = '[' + s;
        }
        return Type.getType(s);
    case Type.OBJECT:
        s = map(t.getInternalName());
        return s != null ? Type.getObjectType(s) : t;
    case Type.METHOD:
        return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
    }
    return t;
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:17,代碼來源:Remapper.java

示例2: getMethodText

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private String getMethodText(MethodNode node) {
	Type typeMethod = Type.getMethodType(node.desc);
	// Args string
	String args = "";
	for (Type t : typeMethod.getArgumentTypes()) {
		args += getTypeStr(t, options) + ", ";
	}
	if (args.endsWith(", ")) {
		args = args.substring(0, args.length() - 2);
	}
	String s = italic(color(getTheme().memberReturnType, getTypeStr(typeMethod.getReturnType(), options))) + " ";
	s += color(getTheme().memberName, escape(node.name)) + "(";
	s += color(getTheme().memberParameterType, args);
	s += ")";
	return s;
}
 
開發者ID:Col-E,項目名稱:Recaf,代碼行數:17,代碼來源:MemberNodeRenderer.java

示例3: visitMethod

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    if (importAborted()) {
        return super.visitMethod(access, name, desc, signature, exceptions);
    }

    LOG.debug("Analysing method {}.{}:{}", className, name, desc);
    accessHandler.setContext(new CodeUnit(name, namesOf(Type.getArgumentTypes(desc)), className));

    DomainBuilders.JavaCodeUnitBuilder<?, ?> codeUnitBuilder = addCodeUnitBuilder(name);
    Type methodType = Type.getMethodType(desc);
    codeUnitBuilder
            .withName(name)
            .withModifiers(JavaModifier.getModifiersForMethod(access))
            .withParameters(typesFrom(methodType.getArgumentTypes()))
            .withReturnType(JavaTypeImporter.importAsmType(methodType.getReturnType()))
            .withDescriptor(desc);

    return new MethodProcessor(className, accessHandler, codeUnitBuilder);
}
 
開發者ID:TNG,項目名稱:ArchUnit,代碼行數:21,代碼來源:JavaClassProcessor.java

示例4: getMethodDescriptorFQNMap

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static Map<String, String> getMethodDescriptorFQNMap(String descriptor) {
    Type type = Type.getMethodType(descriptor);

    Set<String> classes = new HashSet<String>();
    classes.add(type.getReturnType().getClassName());

    Type[] arguments = type.getArgumentTypes();
    if (arguments != null) {
        for (Type arg : arguments) {
            classes.add(arg.getClassName());
        }
    }

    return fqnToMap(classes);
}
 
開發者ID:willfleury,項目名稱:prometheus-metrics-agent,代碼行數:16,代碼來源:Configuration.java

示例5: write

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
void write(MethodWriter writer, Globals globals) {
    writer.writeDebugInfo(location);

    List<Type> parameterTypes = new ArrayList<>();

    // first parameter is the receiver, we never know its type: always Object
    parameterTypes.add(Definition.DEF_TYPE.type);

    // append each argument
    for (AExpression argument : arguments) {
        parameterTypes.add(argument.actual.type);

        if (argument instanceof ILambda) {
            ILambda lambda = (ILambda) argument;

            for (Type capture : lambda.getCaptures()) {
                parameterTypes.add(capture);
            }
        }

        argument.write(writer, globals);
    }

    // create method type from return value and arguments
    Type methodType = Type.getMethodType(actual.type, parameterTypes.toArray(new Type[0]));

    List<Object> args = new ArrayList<>();
    args.add(recipe.toString());
    args.addAll(pointers);
    writer.invokeDefCall(name, methodType, DefBootstrap.METHOD_CALL, args.toArray());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:33,代碼來源:PSubDefCall.java

示例6: write

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
void write(MethodWriter writer, Globals globals) {
    if (ref != null) {
        writer.writeDebugInfo(location);
        // convert MethodTypes to asm Type for the constant pool.
        String invokedType = ref.invokedType.toMethodDescriptorString();
        Type samMethodType = Type.getMethodType(ref.samMethodType.toMethodDescriptorString());
        Type interfaceType = Type.getMethodType(ref.interfaceMethodType.toMethodDescriptorString());
        if (ref.needsBridges()) {
            writer.invokeDynamic(ref.invokedName,
                                 invokedType,
                                 LAMBDA_BOOTSTRAP_HANDLE,
                                 samMethodType,
                                 ref.implMethodASM,
                                 samMethodType,
                                 LambdaMetafactory.FLAG_BRIDGES,
                                 1,
                                 interfaceType);
        } else {
            writer.invokeDynamic(ref.invokedName,
                                 invokedType,
                                 LAMBDA_BOOTSTRAP_HANDLE,
                                 samMethodType,
                                 ref.implMethodASM,
                                 samMethodType,
                                 0);
        }
    } else {
        // TODO: don't do this: its just to cutover :)
        writer.push((String)null);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:33,代碼來源:EFunctionRef.java

示例7: getMethodType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public Type getMethodType() {
  Type[] ts = new Type[args.length];
  for (int i = 0; i < args.length; i++) {
    ts[i] = Type.getType(args[i]);
  }
  return Type.getMethodType(
      Type.getType(returnType),
      ts);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:10,代碼來源:ReflectionUtils.java

示例8: snapshotMethodType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type snapshotMethodType() {
  ArrayList<Type> args = new ArrayList<>();

  args.add(Type.INT_TYPE);
  if (context.isVararg()) {
    args.add(ASMUtils.arrayTypeFor(Object.class));
  }
  for (int i = 0; i < numOfRegisters(); i++) {
    args.add(Type.getType(Object.class));
  }
  return Type.getMethodType(context.savedStateClassType(), args.toArray(new Type[0]));
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:13,代碼來源:RunMethod.java

示例9: methodType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type methodType(Type returnType) {
  ArrayList<Type> args = new ArrayList<>();

  args.add(Type.getType(ExecutionContext.class));
  args.add(Type.INT_TYPE);
  if (context.isVararg()) {
    args.add(ASMUtils.arrayTypeFor(Object.class));
  }
  for (int i = 0; i < numOfRegisters(); i++) {
    args.add(Type.getType(Object.class));
  }
  return Type.getMethodType(returnType, args.toArray(new Type[0]));
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:14,代碼來源:RunMethod.java

示例10: insertDefaultSectionStart

import org.objectweb.asm.Type; //導入方法依賴的package包/類
protected void insertDefaultSectionStart(String key, boolean inverted) throws CompilerException {
    if(!builderLoaded && needLocal) {
        mv.visitVarInsn(ALOAD, varBuilder);
        builderLoaded = true;
    }

    if(data.getDataType() != DATA) {
        throw new CompilerException("The default section generator can't be used within a custom data type");
    }

    String methodName = "lambda$render$" + compiler.getNextLambdaId();

    mv.visitVarInsn(ALOAD, varData);
    mv.visitLdcInsn(key);

    Type methodType = Type.getMethodType(STRING, DATA);

    Handle lambda = new Handle(H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", "metafactory",
            "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;"
                    + "Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;", false);
    Handle method = new Handle(H_INVOKESTATIC, className, methodName, methodType.getDescriptor(), false);

    mv.visitInvokeDynamicInsn("render", Type.getMethodDescriptor(SIMPLE_TEMPLATE), lambda, methodType, method, methodType);

    mv.visitInsn(inverted ? ICONST_1 : ICONST_0);

    mv.visitMethodInsn(INVOKESTATIC, UTILS.getInternalName(), "renderSection", "(" + BUILDER.getDescriptor() +
            DATA.getDescriptor() + STRING.getDescriptor() + SIMPLE_TEMPLATE.getDescriptor() +"Z)" + BUILDER.getDescriptor(), false);

    BytecodeGenerator gen = new BytecodeGenerator(compiler, this, key, cw, data, className, classDesc);
    compiler.setGenerator(gen);

    gen.insertMethodStart(methodName);
}
 
開發者ID:Guichaguri,項目名稱:FastMustache,代碼行數:35,代碼來源:BytecodeGenerator.java

示例11: write

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
void write(MethodWriter writer, Globals globals) {
    writer.writeDebugInfo(location);
    if (defPointer != null) {
        // dynamic interface: push captured parameter on stack
        // TODO: don't do this: its just to cutover :)
        writer.push((String)null);
        writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.getSlot());
    } else if (ref == null) {
        // typed interface, dynamic implementation
        writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.getSlot());
        Type methodType = Type.getMethodType(expected.type, captured.type.type);
        writer.invokeDefCall(call, methodType, DefBootstrap.REFERENCE, expected.name);
    } else {
        // typed interface, typed implementation
        writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.getSlot());
        // convert MethodTypes to asm Type for the constant pool.
        String invokedType = ref.invokedType.toMethodDescriptorString();
        Type samMethodType = Type.getMethodType(ref.samMethodType.toMethodDescriptorString());
        Type interfaceType = Type.getMethodType(ref.interfaceMethodType.toMethodDescriptorString());
        if (ref.needsBridges()) {
            writer.invokeDynamic(ref.invokedName,
                                 invokedType,
                                 LAMBDA_BOOTSTRAP_HANDLE,
                                 samMethodType,
                                 ref.implMethodASM,
                                 samMethodType,
                                 LambdaMetafactory.FLAG_BRIDGES,
                                 1,
                                 interfaceType);
        } else {
            writer.invokeDynamic(ref.invokedName,
                                 invokedType,
                                 LAMBDA_BOOTSTRAP_HANDLE,
                                 samMethodType,
                                 ref.implMethodASM,
                                 samMethodType,
                                 0);
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:42,代碼來源:ECapturingFunctionRef.java

示例12: methodType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public Type methodType() {
  Type[] args = new Type[context.fn.upvals().size()];
  Arrays.fill(args, Type.getType(Variable.class));
  return Type.getMethodType(Type.VOID_TYPE, args);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:6,代碼來源:ConstructorMethod.java

示例13: translateMethodType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public Type translateMethodType(Type methodType) {
    Type[] translated = translateTypes(mcClasses, Lists.asList(methodType.getReturnType(), methodType.getArgumentTypes()).toArray(new Type[] {}));
    return Type.getMethodType(translated[0], Arrays.copyOfRange(translated, 1, translated.length));
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:5,代碼來源:ObfuscatedStateMapper.java


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