public String toString() { if (this == BOGUS) return "BOGUS"; if (this == UNINIT) return "UNINIT"; if (this == RETURN_ADDRESS) return "RETURN ADDRESS"; if (this == TOP) return "TOP"; return clazz == null ? "null" : clazz.getName(); } }
/** * Returns <code>true</code> if this class extends or implements * <code>clazz</code>. It also returns <code>true</code> if * this class is the same as <code>clazz</code>. */ public boolean subtypeOf(CtClass clazz) throws NotFoundException { return this == clazz || getName().equals(clazz.getName()); }
/** * Implemented in subclasses to add to the {@link #toString()} result. * Subclasses should put a space before each token added to the buffer. */ protected void extendToString(StringBuffer buffer) { buffer.append(getName()); }
/** * Makes a unique member name. This method guarantees that * the returned name is not used as a prefix of any methods * or fields visible in this class. * If the returned name is XYZ, then any method or field names * in this class do not start with XYZ. * * @param prefix the prefix of the member name. */ public String makeUniqueName(String prefix) { throw new RuntimeException("not available in " + getName()); }
/** * Prevents a mapping from the specified class name to another name. */ public void fix(CtClass clazz) { fix(clazz.getName()); }
/** * Returns the JVM-internal representation of this class name. */ protected String getThisName() { return MemberResolver.javaToJvmName(thisClass.getName()); }
private Map getAllMultiInterfaces(MultiType type) { Map map = new HashMap(); Iterator iter = type.interfaces.values().iterator(); while (iter.hasNext()) { CtClass intf = (CtClass)iter.next(); map.put(intf.getName(), intf); getAllInterfaces(intf, map); } return map; }
public static CtClass getSuperInterface(CtClass c, String interfaceName) throws CompileError { try { CtClass[] intfs = c.getInterfaces(); for (int i = 0; i < intfs.length; i++) if (intfs[i].getName().equals(interfaceName)) return intfs[i]; } catch (NotFoundException e) {} throw new CompileError("cannot find the super inetrface " + interfaceName + " of " + c.getName()); }
public TransformCall(Transformer next, CtMethod origMethod, CtMethod substMethod) { this(next, origMethod.getName(), substMethod); classname = origMethod.getDeclaringClass().getName(); }
public String resolveClassName(ASTList name) throws CompileError { if (name == null) return null; else return javaToJvmName(lookupClassByName(name).getName()); }
/** * Returns the JVM-internal representation of this super class name. */ protected String getSuperName() throws CompileError { return MemberResolver.javaToJvmName( MemberResolver.getSuperclass(thisClass).getName()); }
public void addInterface(CtClass anInterface) { checkModify(); if (anInterface != null) getClassFile2().addInterface(anInterface.getName()); }
/** * 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()); }
protected String getAccessibleConstructor(String desc, CtClass declClass, MethodInfo minfo) throws CompileError { if (isEnclosing(declClass, thisClass)) { AccessorMaker maker = declClass.getAccessorMaker(); if (maker != null) return maker.getConstructor(declClass, desc, minfo); } throw new CompileError("the called constructor is private in " + declClass.getName()); }
/** * Returns the method name followed by parameter types * such as <code>javassist.CtMethod.setBody(String)</code>. * * @since 3.5 */ public String getLongName() { return getDeclaringClass().getName() + "." + getName() + Descriptor.toString(getSignature()); }
synchronized void classNameChanged(String oldname, CtClass clazz) { CtClass c = (CtClass)getCached(oldname); if (c == clazz) // must check this equation. removeCached(oldname); // see getAndRename(). String newName = clazz.getName(); checkNotFrozen(newName); cacheCtClass(newName, clazz, false); }
public void setSuperclass(CtClass clazz) throws CannotCompileException { checkModify(); if (isInterface()) addInterface(clazz); else getClassFile2().setSuperclass(clazz.getName()); }
public TransformCall(Transformer next, String oldMethodName, CtMethod substMethod) { super(next); methodname = oldMethodName; methodDescriptor = substMethod.getMethodInfo2().getDescriptor(); classname = newClassname = substMethod.getDeclaringClass().getName(); newMethodname = substMethod.getName(); constPool = null; newMethodIsPrivate = Modifier.isPrivate(substMethod.getModifiers()); }
private int addFieldrefInfo(CtField f, FieldInfo finfo) { ConstPool cp = bytecode.getConstPool(); String cname = f.getDeclaringClass().getName(); int ci = cp.addClassInfo(cname); String name = finfo.getName(); String type = finfo.getDescriptor(); return cp.addFieldrefInfo(ci, name, type); }