/** * Returns whether the given class would introduce any unwanted fields * in the target class. */ private boolean introducesUnwantedFields(ProgramClass programClass, ProgramClass targetClass) { // The class must not have any fields, or it must not be instantiated, // without any other subclasses. return programClass.u2fieldsCount != 0 && (InstantiationClassMarker.isInstantiated(targetClass) || (targetClass.subClasses != null && !isOnlySubClass(programClass, targetClass))); }
/** * Returns whether the given class would introduce any unwanted fields * in the target class. */ private boolean introducesUnwantedFields(Clazz programClass, 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(programClass, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); // Count all non-static fields in the the source class. programClass.fieldsAccept(new MemberAccessFilter(0, ClassConstants.ACC_STATIC, counter)); return counter.getCount() > 0; }
/** * Returns whether the given class would introduce any unwanted fields * in the target class. */ private boolean introducesUnwantedFields(Clazz programClass, 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(programClass, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); // Count all non-static fields in the the source class. programClass.fieldsAccept(new MemberAccessFilter(0, ClassConstants.ACC_STATIC, counter)); return counter.getCount() > 0; }
/** * Returns whether the given class would introduce any unwanted fields * in the target class. */ private boolean introducesUnwantedFields(Clazz programClass, 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(programClass, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); // Count all non-static fields in the the source class. programClass.fieldsAccept(new MemberAccessFilter(0, ClassConstants.ACC_STATIC, counter)); return counter.getCount() > 0; }
ClassConstants.INTERNAL_ACC_INTERFACE)) != 0 && (targetClass.subClasses == null || isOnlySubClass(clazz, targetClass)))
/** * 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 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; }
(ClassConstants.ACC_INTERFACE | ClassConstants.ACC_ABSTRACT)) || (isOnlySubClass(programClass, targetClass) && programClass.getSuperClass() != null && (programClass.getSuperClass().equals(targetClass) ||
(ClassConstants.ACC_INTERFACE | ClassConstants.ACC_ABSTRACT)) || (isOnlySubClass(programClass, targetClass) && programClass.getSuperClass() != null && (programClass.getSuperClass().equals(targetClass) ||
(ClassConstants.ACC_INTERFACE | ClassConstants.ACC_ABSTRACT)) || (isOnlySubClass(programClass, targetClass) && programClass.getSuperClass() != null && (programClass.getSuperClass().equals(targetClass) ||