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


Java Type.getType方法代碼示例

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


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

示例1: writeConstructor

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private void writeConstructor(ClassVisitor visitor, Type generatedType, Type superclassType, StructSchema<?> delegateSchema, Type backingStateType) {
    String constructorDescriptor;
    Type delegateType;
    if (delegateSchema == null) {
        delegateType = null;
        constructorDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, backingStateType, TYPE_CONVERTER_TYPE);
    } else {
        delegateType = Type.getType(delegateSchema.getType().getConcreteClass());
        constructorDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, backingStateType, TYPE_CONVERTER_TYPE, delegateType);
    }
    MethodVisitor constructorVisitor = declareMethod(visitor, CONSTRUCTOR_NAME, constructorDescriptor, CONCRETE_SIGNATURE);

    invokeSuperConstructor(constructorVisitor, superclassType);
    assignStateField(constructorVisitor, generatedType);
    assignTypeConverterField(constructorVisitor, generatedType);
    if (delegateType != null) {
        assignDelegateField(constructorVisitor, generatedType, delegateType);
    }
    setCanCallSettersField(constructorVisitor, generatedType, true);
    finishVisitingMethod(constructorVisitor);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:22,代碼來源:ManagedProxyClassGenerator.java

示例2: 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:acmerli,項目名稱:fastAOP,代碼行數:17,代碼來源:Remapper.java

示例3: generateConstructors

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private <T> void generateConstructors(ClassWriter visitor, Class<? extends T> implClass, Type superclassType) {
    for (Constructor<?> constructor : implClass.getConstructors()) {
        Type[] paramTypes = new Type[constructor.getParameterTypes().length];
        for (int i = 0; i < paramTypes.length; i++) {
            paramTypes[i] = Type.getType(constructor.getParameterTypes()[i]);
        }
        String methodDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, paramTypes);
        MethodVisitor constructorVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, CONSTRUCTOR_NAME, methodDescriptor, CONCRETE_SIGNATURE, NO_EXCEPTIONS);
        constructorVisitor.visitCode();
        putThisOnStack(constructorVisitor);
        for (int i = 0; i < paramTypes.length; i++) {
            constructorVisitor.visitVarInsn(paramTypes[i].getOpcode(Opcodes.ILOAD), i + 1);
        }
        constructorVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, superclassType.getInternalName(), CONSTRUCTOR_NAME, methodDescriptor, false);
        finishVisitingMethod(constructorVisitor);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:18,代碼來源:ManagedCollectionProxyClassGenerator.java

示例4: updateState

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private void updateState(IntInsnNode insn) {
  switch (insn.getOpcode()) {
    case Opcodes.BIPUSH:
    case Opcodes.SIPUSH: {
      state.push(Type.INT_TYPE);
      break;
    }
    case Opcodes.NEWARRAY: {
      String desc = arrayTypeDesc(insn.operand);
      Type type = Type.getType(desc);
      state.pop();
      state.push(type);
      break;
    }
    default:
      throw new Unreachable("Unexpected IntInsn opcode: " + insn.getOpcode());
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:19,代碼來源:JarSourceCode.java

示例5: build

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private void build(IntInsnNode insn, IRBuilder builder) {
  switch (insn.getOpcode()) {
    case Opcodes.BIPUSH:
    case Opcodes.SIPUSH: {
      int dest = state.push(Type.INT_TYPE);
      builder.addIntConst(dest, insn.operand);
      break;
    }
    case Opcodes.NEWARRAY: {
      String desc = arrayTypeDesc(insn.operand);
      Type type = Type.getType(desc);
      DexType dexType = application.getTypeFromDescriptor(desc);
      int count = state.pop(Type.INT_TYPE).register;
      int array = state.push(type);
      builder.addNewArrayEmpty(array, count, dexType);
      break;
    }
    default:
      throw new Unreachable("Unexpected IntInsn opcode: " + insn.getOpcode());
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:22,代碼來源:JarSourceCode.java

示例6: addSetMethod

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public void addSetMethod(PropertyMetaData property, Method setter) throws Exception {
    Type paramType = Type.getType(setter.getParameterTypes()[0]);
    Type returnType = Type.getType(setter.getReturnType());
    String setterDescriptor = Type.getMethodDescriptor(returnType, paramType);

    // GENERATE public void <propName>(<type> v) { <setter>(v) }
    String setMethodDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, paramType);
    MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, property.getName(), setMethodDescriptor, null, EMPTY_STRINGS);
    methodVisitor.visitCode();

    // GENERATE <setter>(v)

    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitVarInsn(paramType.getOpcode(Opcodes.ILOAD), 1);

    methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, generatedType.getInternalName(), setter.getName(), setterDescriptor, false);

    // END

    methodVisitor.visitInsn(Opcodes.RETURN);
    methodVisitor.visitMaxs(0, 0);
    methodVisitor.visitEnd();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:24,代碼來源:AsmBackedClassGenerator.java

示例7: mapDesc

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public String mapDesc(String desc) {
    Type t = Type.getType(desc);
    switch (t.getSort()) {
    case Type.ARRAY:
        String s = mapDesc(t.getElementType().getDescriptor());
        for (int i = 0; i < t.getDimensions(); ++i) {
            s = '[' + s;
        }
        return s;
    case Type.OBJECT:
        String newType = map(t.getInternalName());
        if (newType != null) {
            return 'L' + newType + ';';
        }
    }
    return desc;
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:18,代碼來源:Remapper.java

示例8: fix

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type fix(final Type t) {
    if (t.getSort() == Type.OBJECT) {
        return Type.getObjectType(map(t.getInternalName()));
    } else if (t.getSort() == Type.ARRAY) {
        String s = fix(t.getElementType()).getDescriptor();
        for (int i = 0; i < t.getDimensions(); ++i) {
            s = '[' + s;
        }
        return Type.getType(s);
    } else {
        return t;
    }
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:14,代碼來源:NameMapping.java

示例9: writeGetter

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private void writeGetter(ClassVisitor visitor, Type generatedType, String propertyName, Class<?> propertyClass, WeaklyTypeReferencingMethod<?, ?> weakGetter) {
    Method getter = weakGetter.getMethod();
    Type propertyType = Type.getType(propertyClass);
    MethodVisitor methodVisitor = declareMethod(
        visitor,
        getter.getName(),
        Type.getMethodDescriptor(propertyType),
        AsmClassGeneratorUtils.signature(getter));

    putStateFieldValueOnStack(methodVisitor, generatedType);
    putConstantOnStack(methodVisitor, propertyName);
    invokeStateGetMethod(methodVisitor);
    castFirstStackElement(methodVisitor, propertyClass);
    finishVisitingMethod(methodVisitor, returnCode(propertyType));
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:16,代碼來源:ManagedProxyClassGenerator.java

示例10: getSuperClass

import org.objectweb.asm.Type; //導入方法依賴的package包/類
protected Type getSuperClass(final Type t) {
    if (currentClass != null && t.equals(currentClass)) {
        return currentSuperClass;
    }
    Class<?> c = getClass(t).getSuperclass();
    return c == null ? null : Type.getType(c);
}
 
開發者ID:ItzSomebody,項目名稱:BukkitPlugin-Message-Injector,代碼行數:8,代碼來源:SimpleVerifier.java

示例11: newValue

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public BasicValue newValue(final Type type) {
    if (type == null) {
        return BasicValue.UNINITIALIZED_VALUE;
    }

    boolean isArray = type.getSort() == Type.ARRAY;
    if (isArray) {
        switch (type.getElementType().getSort()) {
        case Type.BOOLEAN:
        case Type.CHAR:
        case Type.BYTE:
        case Type.SHORT:
            return new BasicValue(type);
        }
    }

    BasicValue v = super.newValue(type);
    if (BasicValue.REFERENCE_VALUE.equals(v)) {
        if (isArray) {
            v = newValue(type.getElementType());
            String desc = v.getType().getDescriptor();
            for (int i = 0; i < type.getDimensions(); ++i) {
                desc = '[' + desc;
            }
            v = new BasicValue(Type.getType(desc));
        } else {
            v = new BasicValue(type);
        }
    }
    return v;
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Attribute-Remover,代碼行數:33,代碼來源:SimpleVerifier.java

示例12: remap

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Object remap(Object o) {
    if (o instanceof Type) {
        return Type.getType(remap(((Type) o).getDescriptor()));
    }
    if (RuleVisitor.SOURCE_URI_TOKEN.equals(o)) {
        URI uri = scriptSource.getResource().getLocation().getURI();
        return uri == null ? null : uri.toString();
    }
    if (RuleVisitor.SOURCE_DESC_TOKEN.equals(o)) {
        return scriptSource.getDisplayName();
    }
    return o;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:14,代碼來源:FileCacheBackedScriptClassCompiler.java

示例13: unaryOperation

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public BasicValue unaryOperation(AbstractInsnNode insnNode, BasicValue value) throws AnalyzerException {
    if (insnNode.getOpcode() == Opcodes.ANEWARRAY && value instanceof IntegerConstantBasicValue) {
        IntegerConstantBasicValue constantBasicValue = (IntegerConstantBasicValue) value;
        String desc = ((TypeInsnNode) insnNode).desc;
        return new ArraySizeBasicValue(Type.getType("[" + Type.getObjectType(desc)), constantBasicValue.minValue,
            constantBasicValue.maxValue);
    }
    return super.unaryOperation(insnNode, value);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:ESLoggerUsageChecker.java

示例14: visitLocalVariableAnnotation

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
        TypePath typePath, Label[] start, Label[] end, int[] index,
        String desc, boolean visible) {
    Type t = Type.getType(desc);
    int[] newIndex = new int[index.length];
    for (int i = 0; i < newIndex.length; ++i) {
        newIndex[i] = remap(index[i], t);
    }
    return mv.visitLocalVariableAnnotation(typeRef, typePath, start, end,
            newIndex, desc, visible);
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:13,代碼來源:LocalVariablesSorter.java

示例15: insertGetObject

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
static private void insertGetObject(ClassWriter cw, String classNameInternal, ArrayList<Field> fields) {
	int maxStack = 6;
	MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "get", "(Ljava/lang/Object;I)Ljava/lang/Object;", null, null);
	mv.visitCode();
	mv.visitVarInsn(ILOAD, 2);

	if (!fields.isEmpty()) {
		maxStack--;
		Label[] labels = new Label[fields.size()];
		for (int i = 0, n = labels.length; i < n; i++)
			labels[i] = new Label();
		Label defaultLabel = new Label();
		mv.visitTableSwitchInsn(0, labels.length - 1, defaultLabel, labels);

		for (int i = 0, n = labels.length; i < n; i++) {
			Field field = fields.get(i);

			mv.visitLabel(labels[i]);
			mv.visitFrame(F_SAME, 0, null, 0, null);
			mv.visitVarInsn(ALOAD, 1);
			mv.visitTypeInsn(CHECKCAST, classNameInternal);
			mv.visitFieldInsn(GETFIELD, classNameInternal, field.getName(), Type.getDescriptor(field.getType()));

			Type fieldType = Type.getType(field.getType());
			switch (fieldType.getSort()) {
			case Type.BOOLEAN:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;");
				break;
			case Type.BYTE:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;");
				break;
			case Type.CHAR:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;");
				break;
			case Type.SHORT:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;");
				break;
			case Type.INT:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;");
				break;
			case Type.FLOAT:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;");
				break;
			case Type.LONG:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;");
				break;
			case Type.DOUBLE:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;");
				break;
			}

			mv.visitInsn(ARETURN);
		}

		mv.visitLabel(defaultLabel);
		mv.visitFrame(F_SAME, 0, null, 0, null);
	}
	insertThrowExceptionForFieldNotFound(mv);
	mv.visitMaxs(maxStack, 3);
	mv.visitEnd();
}
 
開發者ID:HankXV,項目名稱:Limitart,代碼行數:63,代碼來源:FieldAccess.java


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