/** * Converts a class name into the internal representation used in * the JVM. */ public static String toJvmName(String classname) { return Descriptor.toJvmName(classname); }
/** * Converts a class name into the internal representation used in * the JVM. */ public static String toJvmName(String classname) { return Descriptor.toJvmName(classname); }
private static String javaName(String name) { return Descriptor.toJavaName(Descriptor.toJvmName(name)); } }
private static String javaName(CtClass clazz) { return Descriptor.toJavaName(Descriptor.toJvmName(clazz)); }
/** * Converts to a descriptor from a Java class name */ public static String of(String classname) { if (classname.equals("void")) return "V"; else if (classname.equals("int")) return "I"; else if (classname.equals("byte")) return "B"; else if (classname.equals("long")) return "J"; else if (classname.equals("double")) return "D"; else if (classname.equals("float")) return "F"; else if (classname.equals("char")) return "C"; else if (classname.equals("short")) return "S"; else if (classname.equals("boolean")) return "Z"; else return "L" + toJvmName(classname) + ";"; }
/** * Returns the internal representation of the class name in the * JVM. */ public static String toJvmName(CtClass clazz) { if (clazz.isArray()) return of(clazz); else return toJvmName(clazz.getName()); }
private static String javaName(String name) { return Descriptor.toJavaName(Descriptor.toJvmName(name)); } }
private static String javaName(CtClass clazz) { return Descriptor.toJavaName(Descriptor.toJvmName(clazz)); }
private String fixTypes2(ArrayList scc, HashSet lowersSet, ClassPool cp) throws NotFoundException { Iterator it = lowersSet.iterator(); if (lowersSet.size() == 0) return null; // only NullType else if (lowersSet.size() == 1) return (String)it.next(); else { CtClass cc = cp.get((String)it.next()); while (it.hasNext()) cc = commonSuperClassEx(cc, cp.get((String)it.next())); if (cc.getSuperclass() == null || isObjectArray(cc)) cc = fixByUppers(scc, cp, new HashSet(), cc); if (cc.isArray()) return Descriptor.toJvmName(cc); else return cc.getName(); } }
private static void toDescriptor(StringBuffer desc, CtClass type) { if (type.isArray()) { desc.append('['); try { toDescriptor(desc, type.getComponentType()); } catch (NotFoundException e) { desc.append('L'); String name = type.getName(); desc.append(toJvmName(name.substring(0, name.length() - 2))); desc.append(';'); } } else if (type.isPrimitive()) { CtPrimitiveType pt = (CtPrimitiveType)type; desc.append(pt.getDescriptor()); } else { // class type desc.append('L'); desc.append(type.getName().replace('.', '/')); desc.append(';'); } }
/** * Returns the internal representation of the class name in the * JVM. */ public static String toJvmName(CtClass clazz) { if (clazz.isArray()) return of(clazz); return toJvmName(clazz.getName()); }
private String fixTypes2(List<TypeData> scc, Set<String> lowersSet, ClassPool cp) throws NotFoundException { Iterator<String> it = lowersSet.iterator(); if (lowersSet.size() == 0) return null; // only NullType else if (lowersSet.size() == 1) return it.next(); else { CtClass cc = cp.get(it.next()); while (it.hasNext()) cc = commonSuperClassEx(cc, cp.get(it.next())); if (cc.getSuperclass() == null || isObjectArray(cc)) cc = fixByUppers(scc, cp, new HashSet<TypeData>(), cc); if (cc.isArray()) return Descriptor.toJvmName(cc); return cc.getName(); } }
private String getTopType(int pos) throws BadBytecode { Frame frame = getFrame(pos); if (frame == null) return null; CtClass clazz = frame.peek().getCtClass(); return clazz != null ? Descriptor.toJvmName(clazz) : null; }
/** * Adds a new <code>CONSTANT_Class_info</code> structure. * * <p>This also adds a <code>CONSTANT_Utf8_info</code> structure * for storing the class name. * * @return the index of the added entry. */ public int addClassInfo(CtClass c) { if (c == THIS) return thisClassInfo; else if (!c.isArray()) return addClassInfo(c.getName()); else { // an array type is recorded in the hashtable with // the key "[L<classname>;" instead of "<classname>". // // note: toJvmName(toJvmName(c)) is equal to toJvmName(c). return addClassInfo(Descriptor.toJvmName(c)); } }
/** * Adds a new <code>CONSTANT_Class_info</code> structure. * * <p>This also adds a <code>CONSTANT_Utf8_info</code> structure * for storing the class name. * * @param qname a fully-qualified class name * (or the JVM-internal representation of that name). * @return the index of the added entry. */ public int addClassInfo(String qname) { int utf8 = addUtf8Info(Descriptor.toJvmName(qname)); return addItem(new ClassInfo(utf8, numOfItems)); }
private String getTopType(int pos) throws BadBytecode { Frame frame = getFrame(pos); if (frame == null) return null; CtClass clazz = frame.peek().getCtClass(); return clazz != null ? Descriptor.toJvmName(clazz) : null; }
/** * Adds a new <code>CONSTANT_Class_info</code> structure. * * <p>This also adds a <code>CONSTANT_Utf8_info</code> structure * for storing the class name. * * @param qname a fully-qualified class name * (or the JVM-internal representation of that name). * @return the index of the added entry. */ public int addClassInfo(String qname) { int utf8 = addUtf8Info(Descriptor.toJvmName(qname)); return addItem(new ClassInfo(utf8, numOfItems)); }
.toJvmName(thisclassname)); if (jvmNewThisName != null) thisclassname = Descriptor.toJavaName(jvmNewThisName);
public void replaceClassName(ClassMap classnames) throws RuntimeException { String oldClassName = getName(); String newClassName = (String)classnames.get(Descriptor.toJvmName(oldClassName)); if (newClassName != null) { newClassName = Descriptor.toJavaName(newClassName); // check this in advance although classNameChanged() below does. classPool.checkNotFrozen(newClassName); } super.replaceClassName(classnames); ClassFile cf = getClassFile2(); cf.renameClass(classnames); nameReplaced(); if (newClassName != null) { super.setName(newClassName); classPool.classNameChanged(oldClassName, this); } }