/** * Returns a string representation of this type. * * @return the descriptor of this type. */ @Override public String toString() { return getDescriptor(); } }
@Override public String toString() { if (this == UNINITIALIZED_VALUE) { return "."; } else if (this == RETURNADDRESS_VALUE) { return "A"; } else if (this == REFERENCE_VALUE) { return "R"; } else { return type.getDescriptor(); } } }
private static AnnotationNode getAnnotation(List<AnnotationNode> annotations,Class<? extends Annotation> annotationType){ String desc = Type.getDescriptor(annotationType); if(null != annotations){ for(AnnotationNode a : annotations){ if(a.desc.equals(desc)){ return a; } } } return null; }
public static boolean isAnnotationPresent(MethodNode m,Class<? extends Annotation> annotationType){ if(null == m.visibleAnnotations){ return false; } String desc = Type.getDescriptor(annotationType); for(AnnotationNode an : m.visibleAnnotations){ if(an.desc.equals(desc)){ return true; } } return false; }
public static boolean isAnnotationPresent(ClassNode n,Class<? extends Annotation> annotationType) { if(null == n.visibleAnnotations){ return false; } String desc = Type.getDescriptor(annotationType); for(AnnotationNode an : n.visibleAnnotations){ if(an.desc.equals(desc)){ return true; } } return false; }
/** * Returns the descriptor corresponding to the given Java type. * * @param c * an object class, a primitive class or an array class. * @return the descriptor corresponding to the given class. */ public static String getDescriptor(final Class<?> c) { StringBuffer buf = new StringBuffer(); getDescriptor(buf, c); return buf.toString(); }
/** * Returns the descriptor corresponding to this Java type. * * @return the descriptor corresponding to this Java type. */ public String getDescriptor() { StringBuffer buf = new StringBuffer(); getDescriptor(buf); return buf.toString(); }
/** * Returns the descriptor corresponding to the given constructor. * * @param c * a {@link Constructor Constructor} object. * @return the descriptor of the given constructor. */ public static String getConstructorDescriptor(final Constructor<?> c) { Class<?>[] parameters = c.getParameterTypes(); StringBuffer buf = new StringBuffer(); buf.append('('); for (int i = 0; i < parameters.length; ++i) { getDescriptor(buf, parameters[i]); } return buf.append(")V").toString(); }
/** * Returns the argument types of methods of this type. This method should * only be used for method types. * * @return the argument types of methods of this type. */ public Type[] getArgumentTypes() { return getArgumentTypes(getDescriptor()); }
/** * Returns the return type of methods of this type. This method should only * be used for method types. * * @return the return type of methods of this type. */ public Type getReturnType() { return getReturnType(getDescriptor()); }
/** * Returns the size of the arguments and of the return value of methods of * this type. This method should only be used for method types. * * @return the size of the arguments (plus one for the implicit this * argument), argSize, and the size of the return value, retSize, * packed into a single * int i = <tt>(argSize << 2) | retSize</tt> * (argSize is therefore equal to <tt>i >> 2</tt>, * and retSize to <tt>i & 0x03</tt>). */ public int getArgumentsAndReturnSizes() { return getArgumentsAndReturnSizes(getDescriptor()); }
@Override public void visitLdcInsn(final Object cst) { buf.setLength(0); buf.append(tab2).append("LDC "); if (cst instanceof String) { Printer.appendString(buf, (String) cst); } else if (cst instanceof Type) { buf.append(((Type) cst).getDescriptor()).append(".class"); } else { buf.append(cst); } buf.append('\n'); text.add(buf.toString()); }
protected Class<?> getClass(final Type t) { try { if (t.getSort() == Type.ARRAY) { return Class.forName(t.getDescriptor().replace('/', '.'), false, loader); } return Class.forName(t.getClassName(), false, loader); } catch (ClassNotFoundException e) { throw new RuntimeException(e.toString()); } } }
@Override protected boolean isArrayValue(final BasicValue value) { Type t = value.getType(); return t != null && ("Lnull;".equals(t.getDescriptor()) || t.getSort() == Type.ARRAY); }
@Override protected BasicValue getElementValue(final BasicValue objectArrayValue) throws AnalyzerException { Type arrayType = objectArrayValue.getType(); if (arrayType != null) { if (arrayType.getSort() == Type.ARRAY) { return newValue(Type.getType(arrayType.getDescriptor() .substring(1))); } else if ("Lnull;".equals(arrayType.getDescriptor())) { return objectArrayValue; } } throw new Error("Internal error"); }
@Override public void visitEnd() { if(!methodBodyOnly) { FieldVisitor fv = cw.visitField(Opcodes.ACC_PRIVATE, MANAGER_FIELD, MANAGER_TYPE.getDescriptor(), null, null); { AnnotationVisitor av = fv.visitAnnotation(INJECT_TYPE.getDescriptor(), true); av.visitEnd(); } fv.visitEnd(); } super.visitEnd(); }
protected void getTransactionManager() { if(!methodBodyOnly) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(GETFIELD, type.getInternalName(), MANAGER_FIELD, MANAGER_TYPE.getDescriptor()); }else{ invokeStatic(TxInst.TYPE,TxInst.MANAGER); } }
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; }
void addType(final Type t) { switch (t.getSort()) { case Type.ARRAY: addType(t.getElementType()); break; case Type.OBJECT: addName(t.getInternalName()); break; case Type.METHOD: addMethodDesc(t.getDescriptor()); break; } }
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; }