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


Java Type.getObjectType方法代碼示例

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


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

示例1: getClassDependencies

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Set<String> getClassDependencies(ClassRelevancyFilter filter, ClassReader reader) {
    Set<String> out = new HashSet<String>();
    char[] charBuffer = new char[reader.getMaxStringLength()];
    for (int i = 1; i < reader.getItemCount(); i++) {
        int itemOffset = reader.getItem(i);
        if (itemOffset > 0 && reader.readByte(itemOffset - 1) == 7) {
            // A CONSTANT_Class entry, read the class descriptor
            String classDescriptor = reader.readUTF8(itemOffset, charBuffer);
            Type type = Type.getObjectType(classDescriptor);
            while (type.getSort() == Type.ARRAY) {
                type = type.getElementType();
            }
            if (type.getSort() != Type.OBJECT) {
                // A primitive type
                continue;
            }
            String name = type.getClassName();
            if (filter.isRelevant(name)) {
                out.add(name);
            }
        }
    }
    return out;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:25,代碼來源:DefaultClassDependenciesAnalyzer.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: 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

示例4: visitEnd

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public void visitEnd() {
	if (isSynchronized()) {
		has_monitor_operation = true;
		done = true;
		Label methodEndLabel = super.mark();
		if (exceptions!=null) {
			for(String ex: exceptions) {
				super.catchException(methodStartLabel,methodEndLabel,Type.getObjectType(ex));
				super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_EXIT_METHOD, LOG_CLASS_SIGNATURE);
				super.visitInsn(Opcodes.ATHROW);
			}
		}
		super.catchException(methodStartLabel,methodEndLabel,Type.getType(RuntimeException.class));
		super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_EXIT_METHOD, LOG_CLASS_SIGNATURE);
		super.visitInsn(Opcodes.ATHROW);
	}
	super.visitEnd();
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:19,代碼來源:MonitorInstrument.java

示例5: visitEnd

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public void visitEnd() {
	if (exit) {
		done = true;
		Label methodEndLabel = super.mark();
		super.catchException(methodStartLabel,methodEndLabel,Type.getType(RuntimeException.class));
		super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_STOP_METHOD, LOG_METHOD_SIGNATURE);
		super.visitInsn(Opcodes.ATHROW);
		if (exceptions!=null) {
			for(String ex: exceptions) {
				super.catchException(methodStartLabel,methodEndLabel,Type.getObjectType(ex));
				super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_STOP_METHOD, LOG_METHOD_SIGNATURE);
				super.visitInsn(Opcodes.ATHROW);
			}
		}
	}
	super.visitEnd();
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:18,代碼來源:LogInstrument.java

示例6: visitEnd

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public void visitEnd() {
	if (!methodDone && methodStartLabel != null && constructor) {
		methodDone = true;
		Label methodEndLabel = super.mark();
		super.catchException(methodStartLabel, methodEndLabel, Type
				.getType(RuntimeException.class));
		super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
				LOG_INTERNAL_ALLOC_DEC, VOID_SIGNATURE);
		super.visitInsn(Opcodes.ATHROW);
		if (exceptions != null) {
			for (String ex : exceptions) {
				super.catchException(methodStartLabel, methodEndLabel,
						Type.getObjectType(ex));
				super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
						LOG_INTERNAL_ALLOC_DEC, VOID_SIGNATURE);
				super.visitInsn(Opcodes.ATHROW);
			}
		}
	}
	super.visitEnd();
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:22,代碼來源:AllocateInstrument.java

示例7: verify

import org.objectweb.asm.Type; //導入方法依賴的package包/類
/**
 * Checks a given class.
 * 
 * @param cr
 *            a <code>ClassReader</code> that contains bytecode for the
 *            analysis.
 * @param loader
 *            a <code>ClassLoader</code> which will be used to load
 *            referenced classes. This is useful if you are verifiying
 *            multiple interdependent classes.
 * @param dump
 *            true if bytecode should be printed out not only when errors
 *            are found.
 * @param pw
 *            write where results going to be printed
 */
public static void verify(final ClassReader cr, final ClassLoader loader,
        final boolean dump, final PrintWriter pw) {
    ClassNode cn = new ClassNode();
    cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);

    Type syperType = cn.superName == null ? null : Type
            .getObjectType(cn.superName);
    List<MethodNode> methods = cn.methods;

    List<Type> interfaces = new ArrayList<Type>();
    for (Iterator<String> i = cn.interfaces.iterator(); i.hasNext();) {
        interfaces.add(Type.getObjectType(i.next()));
    }

    for (int i = 0; i < methods.size(); ++i) {
        MethodNode method = methods.get(i);
        SimpleVerifier verifier = new SimpleVerifier(
                Type.getObjectType(cn.name), syperType, interfaces,
                (cn.access & Opcodes.ACC_INTERFACE) != 0);
        Analyzer<BasicValue> a = new Analyzer<BasicValue>(verifier);
        if (loader != null) {
            verifier.setClassLoader(loader);
        }
        try {
            a.analyze(cn.name, method);
            if (!dump) {
                continue;
            }
        } catch (Exception e) {
            e.printStackTrace(pw);
        }
        printAnalyzerResult(method, a, pw);
    }
    pw.flush();
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:52,代碼來源:CheckClassAdapter.java

示例8: updateState

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private void updateState(TypeInsnNode insn) {
  Type type = Type.getObjectType(insn.desc);
  switch (insn.getOpcode()) {
    case Opcodes.NEW: {
      state.push(type);
      break;
    }
    case Opcodes.ANEWARRAY: {
      Type arrayType = makeArrayType(type);
      state.pop();
      state.push(arrayType);
      break;
    }
    case Opcodes.CHECKCAST: {
      // Pop the top value and push it back on with the checked type.
      state.pop(type);
      state.push(type);
      break;
    }
    case Opcodes.INSTANCEOF: {
      state.pop(JarState.REFERENCE_TYPE);
      state.push(Type.INT_TYPE);
      break;
    }
    default:
      throw new Unreachable("Unexpected TypeInsn opcode: " + insn.getOpcode());
  }

}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:30,代碼來源:JarSourceCode.java

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

示例10: build

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private void build(MultiANewArrayInsnNode insn, IRBuilder builder) {
  // Type of the full array.
  Type arrayType = Type.getObjectType(insn.desc);
  DexType dexArrayType = application.getType(arrayType);
  // Type of the members. Can itself be of array type, eg, 'int[]' for 'new int[x][y][]'
  DexType memberType = application.getTypeFromDescriptor(insn.desc.substring(insn.dims));
  // Push an array containing the dimensions of the desired multi-dimensional array.
  DexType dimArrayType = application.getTypeFromDescriptor(INT_ARRAY_DESC);
  Slot[] slots = state.popReverse(insn.dims, Type.INT_TYPE);
  int[] dimensions = new int[insn.dims];
  for (int i = 0; i < insn.dims; i++) {
    dimensions[i] = slots[i].register;
  }
  builder.addInvokeNewArray(dimArrayType, insn.dims, dimensions);
  int dimensionsDestTemp = state.push(INT_ARRAY_TYPE);
  builder.addMoveResult(MoveType.OBJECT, dimensionsDestTemp);
  // Push the class object for the member type of the array.
  int classDestTemp = state.push(CLASS_TYPE);
  builder.ensureBlockForThrowingInstruction();
  builder.addConstClass(classDestTemp, memberType);
  // Create the actual multi-dimensional array using java.lang.reflect.Array::newInstance
  DexType reflectArrayClass = application.getTypeFromDescriptor(REFLECT_ARRAY_DESC);
  DexMethod newInstance = application.getMethod(reflectArrayClass,
      REFLECT_ARRAY_NEW_INSTANCE_NAME, REFLECT_ARRAY_NEW_INSTANCE_DESC);
  List<MoveType> argumentTypes = Arrays.asList(moveType(CLASS_TYPE), moveType(INT_ARRAY_TYPE));
  List<Integer> argumentRegisters = Arrays.asList(classDestTemp, dimensionsDestTemp);
  builder.ensureBlockForThrowingInstruction();
  builder.addInvoke(Invoke.Type.STATIC, newInstance, null, argumentTypes, argumentRegisters);
  // Pop the temporaries and push the final result.
  state.pop(); // classDestTemp.
  state.pop(); // dimensionsDestTemp.
  int result = state.push(arrayType);
  builder.addMoveResult(moveType(arrayType), result);
  // Insert cast check to satisfy verification.
  builder.ensureBlockForThrowingInstruction();
  builder.addCheckCast(result, dexArrayType);
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:38,代碼來源:JarSourceCode.java

示例11: visitFieldInsn

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public void visitFieldInsn(int opcode, String owner, String fieldName,
		String desc) {
	if (firstInstruction)
		addInc();
	if (logPointerChange && opcode == Opcodes.PUTFIELD
			&& desc.charAt(0) == 'L') {
		if (constructor && !doneSuperConstructor && name.equals(owner)
				&& finalFields.contains(fieldName))
			delayedFieldPointer.put(fieldName, desc);
		else {
			// instrument reference changes from
			// putfield ...,obj,v' => ...
			// to
			// dup2 ...,obj,v' => ...,obj,v',obj,v'
			// swap ...,obj,v',obj,v' => ...,obj,v',v',obj
			// dup ...,obj,v',v',obj => ...,obj,v',v',obj,obj
			// getfield ...,obj,v',v',obj,obj => ...,obj,v',v',obj,v
			// invokespecial
			// pointerchangelog(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
			// ...,obj,v',v',obj,v => ...,obj,v'
			// putfield ...,obj,v' =>
			super.visitInsn(Opcodes.DUP2);
			super.visitInsn(Opcodes.SWAP);
			super.visitInsn(Opcodes.DUP);
			super.visitFieldInsn(Opcodes.GETFIELD, owner, fieldName,
					desc);
			super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
					LOG_INTERNAL_POINTER_CHANGE,
					POINTER_CHANGE_SIGNATURE);
		}
	} else if (logPointerChange && opcode == Opcodes.PUTSTATIC
			&& desc.charAt(0) == 'L') {
		// if (finalFields.contains(fieldName)) {
		// // assume field is initially null
		// super.visitInsn(Opcodes.DUP);
		// } else {
		// instrument reference changes from
		// putstatic ...,v' => ...
		// to
		// dup ...,v' => ...,v',v'
		// ldc owner.class ...,v',v' => ...,v',v',k
		// getstatic ...,v',v',k => ...,v',v',k,v
		// invokespecial
		// staticpointerchangelog(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/Object;)V
		// ...,v',v',k,v => ...,v'
		super.visitInsn(Opcodes.DUP);
		super.visitLdcInsn(Type.getObjectType(owner));
		super.visitFieldInsn(Opcodes.GETSTATIC, owner, fieldName, desc);
		super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
				LOG_INTERNAL_STATIC_POINTER_CHANGE,
				STATIC_POINTER_CHANGE_SIGNATURE);
		// }
	}
	super.visitFieldInsn(opcode, owner, fieldName, desc);
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:56,代碼來源:AllocateInstrument.java

示例12: visitMethodInsn

import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc,
                            boolean itf) {
    Type receiver = Type.getObjectType(owner);
    if (incompatibleChange != InstantRunVerifierStatus.INCOMPATIBLE) {
        if (opcode == Opcodes.INVOKEVIRTUAL && blackListedMethods.containsKey(receiver)) {
            for (Method method : blackListedMethods.get(receiver)) {
                if (method.getName().equals(name) && method.getDescriptor().equals(desc)) {
                    incompatibleChange = InstantRunVerifierStatus.INCOMPATIBLE;
                }
            }
        }
    }
    super.visitMethodInsn(opcode, owner, name, desc, itf);
}
 
開發者ID:meili,項目名稱:Aceso,代碼行數:16,代碼來源:InstantRunMethodVerifier.java

示例13: beginNewTypeName

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public void beginNewTypeName(String typeQName, int classVersion, String superClassQName, String[] interfaces)
{
    this.asmType = Type.getObjectType(typeQName);
    this.classVersion = classVersion;
    this.asmSuperType = !Strings.isNullOrEmpty(superClassQName) ? Type.getObjectType(superClassQName) : null;
    for (String intf : interfaces)
        this.interfaces.add(intf);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:9,代碼來源:ASMModParser.java

示例14: makeArrayType

import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static Type makeArrayType(Type elementType) {
  return Type.getObjectType("[" + elementType.getDescriptor());
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:4,代碼來源:JarSourceCode.java

示例15: setSrgClassName

import org.objectweb.asm.Type; //導入方法依賴的package包/類
public ASMClassBuilder setSrgClassName(String srgInternalClassName) {
    srgName = !Strings.isNullOrEmpty(srgInternalClassName) ? Type.getObjectType(srgInternalClassName) : null;
    return this;
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:5,代碼來源:ASMClassBuilder.java


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