本文整理匯總了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;
}
示例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;
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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());
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例14: makeArrayType
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private static Type makeArrayType(Type elementType) {
return Type.getObjectType("[" + elementType.getDescriptor());
}
示例15: setSrgClassName
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public ASMClassBuilder setSrgClassName(String srgInternalClassName) {
srgName = !Strings.isNullOrEmpty(srgInternalClassName) ? Type.getObjectType(srgInternalClassName) : null;
return this;
}