private JApiModifier<StaticModifier> extractStaticModifier(Optional<? extends CtBehavior> oldBehaviorOptional, Optional<? extends CtBehavior> newBehaviorOptional) { return ModifierHelper.extractModifierFromBehavior(oldBehaviorOptional, newBehaviorOptional, new ModifierHelper.ExtractModifierFromBehaviorCallback<StaticModifier>() { @Override public StaticModifier getModifierForOld(CtBehavior oldBehavior) { return Modifier.isStatic(oldBehavior.getModifiers()) ? StaticModifier.STATIC : StaticModifier.NON_STATIC; } @Override public StaticModifier getModifierForNew(CtBehavior newBehavior) { return Modifier.isStatic(newBehavior.getModifiers()) ? StaticModifier.STATIC : StaticModifier.NON_STATIC; } }); }
private JApiModifier<AccessModifier> extractAccessModifier(Optional<CtClass> oldClassOptional, Optional<CtClass> newClassOptional) { return ModifierHelper.extractModifierFromClass(oldClassOptional, newClassOptional, new ModifierHelper.ExtractModifierFromClassCallback<AccessModifier>() { @Override public AccessModifier getModifierForOld(CtClass oldClass) { return ModifierHelper.translateToModifierLevel(oldClass.getModifiers()); } @Override public AccessModifier getModifierForNew(CtClass newClass) { return ModifierHelper.translateToModifierLevel(newClass.getModifiers()); } }); }
private JApiModifier<AbstractModifier> extractAbstractModifier(Optional<CtField> oldFieldOptional, Optional<CtField> newFieldOptional) { return ModifierHelper.extractModifierFromField(oldFieldOptional, newFieldOptional, new ModifierHelper.ExtractModifierFromFieldCallback<AbstractModifier>() { @Override public AbstractModifier getModifierForOld(CtField oldField) { return Modifier.isAbstract(oldField.getModifiers()) ? AbstractModifier.ABSTRACT : AbstractModifier.NON_ABSTRACT; } @Override public AbstractModifier getModifierForNew(CtField newField) { return Modifier.isAbstract(newField.getModifiers()) ? AbstractModifier.ABSTRACT : AbstractModifier.NON_ABSTRACT; } }); }
public static boolean matchesModifierLevel(int modifierOfElement, AccessModifier modifierLevel) { AccessModifier modifierLevelOfElement = translateToModifierLevel(modifierOfElement); return matchesModifierLevel(modifierLevelOfElement, modifierLevel); }
@Override public void visit(Iterator<JApiField> iterator, JApiField element) { boolean remove = false; if (options.isOutputOnlyModifications()) { if (element.getChangeStatus() == JApiChangeStatus.UNCHANGED) { if (hasOnlyUnchangedAnnotations(element) && element.isSourceCompatible()) { remove = true; } } } if (options.isOutputOnlyBinaryIncompatibleModifications()) { if (element.isBinaryCompatible()) { remove = true; } } if (!ModifierHelper.matchesModifierLevel(element, OutputFilter.this.options.getAccessModifier())) { remove = true; } if (!ModifierHelper.includeSynthetic(element, options)) { remove = true; } if (remove) { iterator.remove(); } }
private void checkIfConstructorsHaveChangedIncompatible(JApiClass jApiClass, Map<String, JApiClass> classMap) { for (JApiConstructor constructor : jApiClass.getConstructors()) { // section 13.4.6 of "Java Language Specification" SE7 if (isNotPrivate(constructor) && constructor.getChangeStatus() == JApiChangeStatus.REMOVED) { addCompatibilityChange(constructor, JApiCompatibilityChange.CONSTRUCTOR_REMOVED); } // section 13.4.7 of "Java Language Specification" SE7 if (hasModifierLevelDecreased(constructor)) { addCompatibilityChange(constructor, JApiCompatibilityChange.CONSTRUCTOR_LESS_ACCESSIBLE); } checkIfAnnotationDeprectedAdded(constructor); } }
private boolean includeField(JApiField jApiField) { return ModifierHelper.matchesModifierLevel(jApiField, options.getAccessModifier()); }
public static boolean isSynthetic(JApiCanBeSynthetic jApiClass) { boolean isSynthetic = false; JApiModifier<SyntheticModifier> syntheticModifier = jApiClass.getSyntheticModifier(); JApiAttribute<SyntheticAttribute> syntheticAttribute = jApiClass.getSyntheticAttribute(); boolean hasSyntheticModifier = hasSyntheticModifier(syntheticModifier); boolean hasSyntheticAttribute = hasSyntheticAttribute(syntheticAttribute); if (hasSyntheticModifier || hasSyntheticAttribute) { isSynthetic = true; } return isSynthetic; }
final List<JApiField> removedAndNotOverriddenFields = new ArrayList<>(); for (JApiMethod jApiMethod : jApiClass.getMethods()) { if (!isAbstract(jApiMethod) && jApiMethod.getChangeStatus() != JApiChangeStatus.REMOVED && isNotPrivate(jApiMethod)) { implementedMethods.add(jApiMethod); if (jApiField.getChangeStatus() != JApiChangeStatus.REMOVED && isNotPrivate(jApiField)) { fields.add(jApiField); for (JApiMethod interfaceMethod : interfaceClass.getMethods()) { boolean interfaceMethodImplemented = false; if (isSynthetic(interfaceMethod)) { continue;
public static boolean includeSynthetic(JApiCanBeSynthetic jApiCanBeSynthetic, Options options) { return !isSynthetic(jApiCanBeSynthetic) || options.isIncludeSynthetic(); }
@Override public Integer callback(JApiClass superclass, Map<String, JApiClass> classMap, JApiChangeStatus changeStatusOfSuperclass) { int movedToSuperclass = 0; for (JApiField superclassField : superclass.getFields()) { if (superclassField.getName().equals(field.getName()) && fieldTypeMatches(superclassField, field) && isNotPrivate(superclassField)) { movedToSuperclass = 1; } } return movedToSuperclass; } });
private void evaluateBinaryCompatibility(JApiClass jApiClass, Map<String, JApiClass> classMap) { if (jApiClass.getChangeStatus() == JApiChangeStatus.REMOVED) { addCompatibilityChange(jApiClass, JApiCompatibilityChange.CLASS_REMOVED); } else if (jApiClass.getChangeStatus() == JApiChangeStatus.MODIFIED) { // section 13.4.1 of "Java Language Specification" SE7 if (jApiClass.getAbstractModifier().hasChangedFromTo(AbstractModifier.NON_ABSTRACT, AbstractModifier.ABSTRACT)) { addCompatibilityChange(jApiClass, JApiCompatibilityChange.CLASS_NOW_ABSTRACT); } // section 13.4.2 of "Java Language Specification" SE7 if (jApiClass.getFinalModifier().hasChangedFromTo(FinalModifier.NON_FINAL, FinalModifier.FINAL)) { addCompatibilityChange(jApiClass, JApiCompatibilityChange.CLASS_NOW_FINAL); } // section 13.4.3 of "Java Language Specification" SE7 if (jApiClass.getAccessModifier().hasChangedFrom(AccessModifier.PUBLIC)) { addCompatibilityChange(jApiClass, JApiCompatibilityChange.CLASS_NO_LONGER_PUBLIC); } } // section 13.4.4 of "Java Language Specification" SE7 checkIfSuperclassesOrInterfacesChangedIncompatible(jApiClass, classMap); checkIfMethodsHaveChangedIncompatible(jApiClass, classMap); checkIfConstructorsHaveChangedIncompatible(jApiClass, classMap); checkIfFieldsHaveChangedIncompatible(jApiClass, classMap); if (jApiClass.getClassType().getChangeStatus() == JApiChangeStatus.MODIFIED) { addCompatibilityChange(jApiClass, JApiCompatibilityChange.CLASS_TYPE_CHANGED); } checkIfAnnotationDeprectedAdded(jApiClass); if (hasModifierLevelDecreased(jApiClass)) { addCompatibilityChange(jApiClass, JApiCompatibilityChange.CLASS_LESS_ACCESSIBLE); } }
@Override public void visit(Iterator<JApiConstructor> iterator, JApiConstructor element) { boolean remove = false; if (options.isOutputOnlyModifications()) { if (element.getChangeStatus() == JApiChangeStatus.UNCHANGED && element.isSourceCompatible()) { if (hasOnlyUnchangedAnnotations(element)) { remove = true; } } } if (options.isOutputOnlyBinaryIncompatibleModifications()) { if (element.isBinaryCompatible()) { remove = true; } } if (!ModifierHelper.matchesModifierLevel(element, OutputFilter.this.options.getAccessModifier())) { remove = true; } if (!ModifierHelper.includeSynthetic(element, options)) { remove = true; } if (remove) { iterator.remove(); } }
private void checkIfConstructorsHaveChangedIncompatible(JApiClass jApiClass, Map<String, JApiClass> classMap) { for (JApiConstructor constructor : jApiClass.getConstructors()) { // section 13.4.6 of "Java Language Specification" SE7 if (isNotPrivate(constructor) && constructor.getChangeStatus() == JApiChangeStatus.REMOVED) { addCompatibilityChange(constructor, JApiCompatibilityChange.CONSTRUCTOR_REMOVED); } // section 13.4.7 of "Java Language Specification" SE7 if (hasModifierLevelDecreased(constructor)) { addCompatibilityChange(constructor, JApiCompatibilityChange.CONSTRUCTOR_LESS_ACCESSIBLE); } checkIfAnnotationDeprectedAdded(constructor); } }
private boolean includeMethod(JApiMethod jApiMethod) { return ModifierHelper.matchesModifierLevel(jApiMethod, options.getAccessModifier()); }
public static boolean isSynthetic(JApiCanBeSynthetic jApiClass) { boolean isSynthetic = false; JApiModifier<SyntheticModifier> syntheticModifier = jApiClass.getSyntheticModifier(); JApiAttribute<SyntheticAttribute> syntheticAttribute = jApiClass.getSyntheticAttribute(); boolean hasSyntheticModifier = hasSyntheticModifier(syntheticModifier); boolean hasSyntheticAttribute = hasSyntheticAttribute(syntheticAttribute); if (hasSyntheticModifier || hasSyntheticAttribute) { isSynthetic = true; } return isSynthetic; }
public static boolean matchesModifierLevel(int modifierOfElement, AccessModifier modifierLevel) { AccessModifier modifierLevelOfElement = translateToModifierLevel(modifierOfElement); return matchesModifierLevel(modifierLevelOfElement, modifierLevel); }
final List<JApiField> removedAndNotOverriddenFields = new ArrayList<>(); for (JApiMethod jApiMethod : jApiClass.getMethods()) { if (!isAbstract(jApiMethod) && jApiMethod.getChangeStatus() != JApiChangeStatus.REMOVED && isNotPrivate(jApiMethod)) { implementedMethods.add(jApiMethod); if (jApiField.getChangeStatus() != JApiChangeStatus.REMOVED && isNotPrivate(jApiField)) { fields.add(jApiField); for (JApiMethod interfaceMethod : interfaceClass.getMethods()) { boolean interfaceMethodImplemented = false; if (isSynthetic(interfaceMethod)) { continue;
public static boolean includeSynthetic(JApiCanBeSynthetic jApiCanBeSynthetic, JarArchiveComparatorOptions options) { return options.isIncludeSynthetic() || !isSynthetic(jApiCanBeSynthetic); }
@Override public Integer callback(JApiClass superclass, Map<String, JApiClass> classMap, JApiChangeStatus changeStatusOfSuperclass) { int movedToSuperclass = 0; for (JApiField superclassField : superclass.getFields()) { if (superclassField.getName().equals(field.getName()) && fieldTypeMatches(superclassField, field) && isNotPrivate(superclassField)) { movedToSuperclass = 1; } } return movedToSuperclass; } });