public void visitAnyClass(Clazz clazz) { // Check the class itself. if ((clazz.getAccessFlags() & ClassConstants.ACC_PUBLIC) == 0) { setPackageVisibleMembers(clazz); } else { // Check the members. clazz.fieldsAccept(this); clazz.methodsAccept(this); } }
public void visitAnyClass(Clazz clazz) { // Check the class itself. if ((clazz.getAccessFlags() & ClassConstants.ACC_PUBLIC) == 0) { setPackageVisibleMembers(clazz); } else { // Check the members. clazz.fieldsAccept(this); clazz.methodsAccept(this); } }
public void visitAnyClass(Clazz clazz) { // Check the class itself. if ((clazz.getAccessFlags() & ClassConstants.ACC_PUBLIC) == 0) { setPackageVisibleMembers(clazz); } else { // Check the members. clazz.fieldsAccept(this); clazz.methodsAccept(this); } }
/** * Returns whether the two given classes have initializers with the same * descriptors. */ private boolean haveAnyIdenticalInitializers(Clazz clazz, Clazz targetClass) { MemberCounter counter = new MemberCounter(); // TODO: Currently checking shared methods, not just initializers. // TODO: Allow identical methods. // Visit all methods, counting the ones that are also present in the // target class. clazz.methodsAccept(//new MemberNameFilter(new FixedStringMatcher(ClassConstants.INTERNAL_METHOD_NAME_INIT), new SimilarMemberVisitor(targetClass, true, false, false, false, new MemberAccessFilter(0, ClassConstants.INTERNAL_ACC_ABSTRACT, counter))); return counter.getCount() > 0; }
/** * Returns whether the two given classes have class members with the same * name and descriptor. */ private boolean haveAnyIdenticalMethods(Clazz clazz, Clazz targetClass) { MemberCounter counter = new MemberCounter(); // Visit all non-abstract methods, counting the ones that are also // present in the target class. clazz.methodsAccept(new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, new SimilarMemberVisitor(targetClass, true, false, false, false, new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, counter)))); return counter.getCount() > 0; }
/** * Returns whether the two given classes have class members with the same * name and descriptor. */ private boolean haveAnyIdenticalMethods(Clazz clazz, Clazz targetClass) { MemberCounter counter = new MemberCounter(); // Visit all non-abstract methods, counting the ones that are also // present in the target class. clazz.methodsAccept(new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, new SimilarMemberVisitor(targetClass, true, false, false, false, new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, counter)))); return counter.getCount() > 0; }
/** * Returns whether the two given classes have class members with the same * name and descriptor. */ private boolean haveAnyIdenticalMethods(Clazz clazz, Clazz targetClass) { MemberCounter counter = new MemberCounter(); // Visit all non-abstract methods, counting the ones that are also // present in the target class. clazz.methodsAccept(new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, new SimilarMemberVisitor(targetClass, true, false, false, false, new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, counter)))); return counter.getCount() > 0; }
/** * Returns whether the given class would introduce any abstract methods * in the target class. */ private boolean introducesUnwantedAbstractMethods(Clazz clazz, ProgramClass targetClass) { // It's ok if the target class is already abstract and does not // have any subclasses except for maybe the source class. if ((targetClass.getAccessFlags() & (ClassConstants.ACC_ABSTRACT | ClassConstants.ACC_INTERFACE)) != 0 && (targetClass.subClasses == null || isOnlySubClass(clazz, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); Set targetSet = new HashSet(); // Collect all abstract methods, and similar abstract methods in the // class hierarchy of the target class. clazz.methodsAccept(new MemberAccessFilter(ClassConstants.ACC_ABSTRACT, 0, new MultiMemberVisitor( counter, new SimilarMemberVisitor(targetClass, true, true, true, false, new MemberAccessFilter(ClassConstants.ACC_ABSTRACT, 0, new MemberCollector(false, true, true, targetSet))) ))); return targetSet.size() < counter.getCount(); }
clazz.methodsAccept(new MemberAccessFilter(ClassConstants.INTERNAL_ACC_ABSTRACT, 0, new MultiMemberVisitor(new MemberVisitor[]
/** * Returns whether the given class would introduce any abstract methods * in the target class. */ private boolean introducesUnwantedAbstractMethods(Clazz clazz, ProgramClass targetClass) { // It's ok if the target class is already abstract and does not // have any subclasses except for maybe the source class. if ((targetClass.getAccessFlags() & (ClassConstants.ACC_ABSTRACT | ClassConstants.ACC_INTERFACE)) != 0 && (targetClass.subClasses == null || isOnlySubClass(clazz, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); Set targetSet = new HashSet(); // Collect all abstract methods, and similar abstract methods in the // class hierarchy of the target class. clazz.methodsAccept(new MemberAccessFilter(ClassConstants.ACC_ABSTRACT, 0, new MultiMemberVisitor( counter, new SimilarMemberVisitor(targetClass, true, true, true, false, new MemberAccessFilter(ClassConstants.ACC_ABSTRACT, 0, new MemberCollector(false, true, true, targetSet))) ))); return targetSet.size() < counter.getCount(); }
/** * Returns whether the given class would introduce any abstract methods * in the target class. */ private boolean introducesUnwantedAbstractMethods(Clazz clazz, ProgramClass targetClass) { // It's ok if the target class is already abstract and does not // have any subclasses except for maybe the source class. if ((targetClass.getAccessFlags() & (ClassConstants.ACC_ABSTRACT | ClassConstants.ACC_INTERFACE)) != 0 && (targetClass.subClasses == null || isOnlySubClass(clazz, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); Set targetSet = new HashSet(); // Collect all abstract methods, and similar abstract methods in the // class hierarchy of the target class. clazz.methodsAccept(new MemberAccessFilter(ClassConstants.ACC_ABSTRACT, 0, new MultiMemberVisitor( counter, new SimilarMemberVisitor(targetClass, true, true, true, false, new MemberAccessFilter(ClassConstants.ACC_ABSTRACT, 0, new MemberCollector(false, true, true, targetSet))) ))); return targetSet.size() < counter.getCount(); }
/** * Returns whether the given class overrides any methods in the given * target class. */ private boolean overridesAnyMethods(Clazz clazz, ProgramClass targetClass) { // It's ok if the target class is never instantiated and does // not have any subclasses except for maybe the source class. if (!InstantiationClassMarker.isInstantiated(targetClass) && (targetClass.subClasses == null || isOnlySubClass(clazz, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); // Visit all non-abstract methods, counting the ones that are // overriding methods in the class hierarchy of the target class. clazz.methodsAccept(new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, new InitializerMethodFilter(null, new SimilarMemberVisitor(targetClass, true, true, false, false, new MemberAccessFilter(0, ClassConstants.ACC_PRIVATE | ClassConstants.ACC_STATIC | ClassConstants.ACC_ABSTRACT, counter))))); return counter.getCount() > 0; }
/** * Returns whether the given class overrides any methods in the given * target class. */ private boolean overridesAnyMethods(Clazz clazz, ProgramClass targetClass) { // It's ok if the target class is never instantiated and does // not have any subclasses except for maybe the source class. if (!InstantiationClassMarker.isInstantiated(targetClass) && (targetClass.subClasses == null || isOnlySubClass(clazz, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); // Visit all non-abstract methods, counting the ones that are // overriding methods in the class hierarchy of the target class. clazz.methodsAccept(new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, new InitializerMethodFilter(null, new SimilarMemberVisitor(targetClass, true, true, false, false, new MemberAccessFilter(0, ClassConstants.ACC_PRIVATE | ClassConstants.ACC_STATIC | ClassConstants.ACC_ABSTRACT, counter))))); return counter.getCount() > 0; }
/** * Returns whether the given class overrides any methods in the given * target class. */ private boolean overridesAnyMethods(Clazz clazz, ProgramClass targetClass) { // It's ok if the target class is never instantiated and does // not have any subclasses except for maybe the source class. if (!InstantiationClassMarker.isInstantiated(targetClass) && (targetClass.subClasses == null || isOnlySubClass(clazz, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); // Visit all non-abstract methods, counting the ones that are // overriding methods in the class hierarchy of the target class. clazz.methodsAccept(new MemberAccessFilter(0, ClassConstants.ACC_ABSTRACT, new InitializerMethodFilter(null, new SimilarMemberVisitor(targetClass, true, true, false, false, new MemberAccessFilter(0, ClassConstants.ACC_PRIVATE | ClassConstants.ACC_STATIC | ClassConstants.ACC_ABSTRACT, counter))))); return counter.getCount() > 0; }
/** * Returns whether the given class overrides any methods in the given * target class. */ private boolean overridesAnyMethods(Clazz clazz, Clazz targetClass) { MemberCounter counter = new MemberCounter(); // Visit all non-private non-static methods, counting the ones that are // being overridden in the class hierarchy of the target class. clazz.methodsAccept(new MemberAccessFilter(0, ClassConstants.INTERNAL_ACC_PRIVATE | ClassConstants.INTERNAL_ACC_STATIC | ClassConstants.INTERNAL_ACC_ABSTRACT, new MemberNameFilter(new NotMatcher(new FixedStringMatcher(ClassConstants.INTERNAL_METHOD_NAME_CLINIT)), new MemberNameFilter(new NotMatcher(new FixedStringMatcher(ClassConstants.INTERNAL_METHOD_NAME_INIT)), new SimilarMemberVisitor(targetClass, true, true, false, false, new MemberAccessFilter(0, ClassConstants.INTERNAL_ACC_PRIVATE | ClassConstants.INTERNAL_ACC_STATIC | ClassConstants.INTERNAL_ACC_ABSTRACT, counter)))))); return counter.getCount() > 0; }