@Override protected String getCommonSuperClass(final String type1, final String type2) { final String key = type1 + "!_!" + type2; final String previous = this.cache.get(key); if (previous != null) { return previous; } final ClassReader info1 = typeInfo(type1); final ClassReader info2 = typeInfo(type2); final String result = getCommonSuperClass(type1, info1, type2, info2); this.cache.put(key, result); return result; }
/** * Returns the internal names of the ancestor classes of the given type. * * @param type * the internal name of a class or interface. * @param info * the ClassReader corresponding to 'type'. * @return a StringBuilder containing the ancestor classes of 'type', * separated by ';'. The returned string has the following format: * ";type1;type2 ... ;typeN", where type1 is 'type', and typeN is a * direct subclass of Object. If 'type' is Object, the returned string * is empty. */ private StringBuilder typeAncestors(String type, ClassReader info) { final StringBuilder b = new StringBuilder(); while (!"java/lang/Object".equals(type)) { b.append(';').append(type); type = info.getSuperName(); info = typeInfo(type); } return b; }
/** * Returns true if the given type implements the given interface. * * @param type * the internal name of a class or interface. * @param info * the ClassReader corresponding to 'type'. * @param itf * the internal name of a interface. * @return true if 'type' implements directly or indirectly 'itf' */ private boolean typeImplements(String type, ClassReader info, final String itf) { final String cleanItf = itf.replace(".", "/"); while (!"java/lang/Object".equals(type)) { final String[] itfs = info.getInterfaces(); for (final String itf2 : itfs) { if (itf2.equals(cleanItf)) { return true; } } for (final String itf2 : itfs) { if (typeImplements(itf2, typeInfo(itf2), cleanItf)) { return true; } } type = info.getSuperName(); info = typeInfo(type); } return false; }
@Override protected String getCommonSuperClass(final String type1, final String type2) { final String key = type1 + "!_!" + type2; final String previous = this.cache.get(key); if (previous != null) { return previous; } final ClassReader info1 = typeInfo(type1); final ClassReader info2 = typeInfo(type2); final String result = getCommonSuperClass(type1, info1, type2, info2); this.cache.put(key, result); return result; }
/** * Returns the internal names of the ancestor classes of the given type. * * @param type * the internal name of a class or interface. * @param info * the ClassReader corresponding to 'type'. * @return a StringBuilder containing the ancestor classes of 'type', * separated by ';'. The returned string has the following format: * ";type1;type2 ... ;typeN", where type1 is 'type', and typeN is a * direct subclass of Object. If 'type' is Object, the returned string * is empty. */ private StringBuilder typeAncestors(String type, ClassReader info) { final StringBuilder b = new StringBuilder(); while (!"java/lang/Object".equals(type)) { b.append(';').append(type); type = info.getSuperName(); info = typeInfo(type); } return b; }
/** * Returns true if the given type implements the given interface. * * @param type * the internal name of a class or interface. * @param info * the ClassReader corresponding to 'type'. * @param itf * the internal name of a interface. * @return true if 'type' implements directly or indirectly 'itf' */ private boolean typeImplements(String type, ClassReader info, final String itf) { final String cleanItf = itf.replace(".", "/"); while (!"java/lang/Object".equals(type)) { final String[] itfs = info.getInterfaces(); for (final String itf2 : itfs) { if (itf2.equals(cleanItf)) { return true; } } for (final String itf2 : itfs) { if (typeImplements(itf2, typeInfo(itf2), cleanItf)) { return true; } } type = info.getSuperName(); info = typeInfo(type); } return false; }