/** * Finds the class member with the given name and descriptor in the given * class or its hierarchy. */ public Member findMember(Clazz referencingClass, Clazz clazz, String name, String descriptor, boolean isField) { // Organize a search in the hierarchy of superclasses and interfaces. // The class member may be in a different class, if the code was // compiled with "-target 1.2" or higher (the default in JDK 1.4). try { this.clazz = null; this.member = null; clazz.hierarchyAccept(true, true, true, false, isField ? (ClassVisitor)new NamedFieldVisitor(name, descriptor, new MemberClassAccessFilter(referencingClass, this)) : (ClassVisitor)new NamedMethodVisitor(name, descriptor, new MemberClassAccessFilter(referencingClass, this))); } catch (MemberFoundException ex) { // We've found the member we were looking for. } return member; }
private static class MemberFoundException extends RuntimeException {} private static final MemberFoundException MEMBER_FOUND = new MemberFoundException();
private static class MemberFoundException extends RuntimeException {} private static final MemberFoundException MEMBER_FOUND = new MemberFoundException();
private static class MemberFoundException extends RuntimeException {} private static final MemberFoundException MEMBER_FOUND = new MemberFoundException();