Skip to content

Commit

Permalink
#392 added new JApiCompatibilityChangeType.ANNOTATION_MODIFIED
Browse files Browse the repository at this point in the history
  • Loading branch information
siom79 committed Apr 22, 2024
1 parent 1966906 commit 70e68e5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
37 changes: 21 additions & 16 deletions japicmp/src/main/java/japicmp/compat/CompatibilityChanges.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,22 +477,27 @@ private void checkIfAnnotationsChanged(JApiHasAnnotations jApiHasAnnotations, Ma
if (status == JApiChangeStatus.REMOVED) {
addCompatibilityChange(jApiHasAnnotations, JApiCompatibilityChangeType.ANNOTATION_REMOVED);
} else {
final boolean isNoAnnotations = this.jarArchiveComparator.getJarArchiveComparatorOptions().isNoAnnotations();
final boolean isDeprecated = annotation.getFullyQualifiedName().equals(Deprecated.class.getName());
final JApiClass annotationClass;
if (isNoAnnotations && !isDeprecated) {
annotationClass = null;
} else {
annotationClass = classMap.computeIfAbsent(annotation.getFullyQualifiedName(), fqn -> loadClass(fqn, EnumSet.allOf(Classpath.class)));
annotation.setJApiClass(annotationClass);
}
if (status == JApiChangeStatus.NEW || status == JApiChangeStatus.MODIFIED) {
addCompatibilityChange(jApiHasAnnotations, isDeprecated ? JApiCompatibilityChangeType.ANNOTATION_DEPRECATED_ADDED : JApiCompatibilityChangeType.ANNOTATION_ADDED);
} else if (annotationClass != null) {
checkIfMethodsHaveChangedIncompatible(annotationClass, classMap);
checkIfFieldsHaveChangedIncompatible(annotationClass, classMap);
if (!annotationClass.isSourceCompatible() || !annotationClass.isBinaryCompatible()) {
addCompatibilityChange(jApiHasAnnotations, JApiCompatibilityChangeType.ANNOTATION_MODIFIED_INCOMPATIBLE);
boolean isNoAnnotations = this.jarArchiveComparator.getJarArchiveComparatorOptions().isNoAnnotations();
if (!isNoAnnotations) {
boolean isDeprecated = annotation.getFullyQualifiedName().equals(Deprecated.class.getName());
if (isDeprecated && status == JApiChangeStatus.NEW) {
addCompatibilityChange(jApiHasAnnotations, JApiCompatibilityChangeType.ANNOTATION_DEPRECATED_ADDED);
} else {
JApiClass annotationClass = classMap.computeIfAbsent(annotation.getFullyQualifiedName(), fqn -> loadClass(fqn, EnumSet.allOf(Classpath.class)));
if (annotationClass != null) {
annotation.setJApiClass(annotationClass);
if (status == JApiChangeStatus.NEW) {
addCompatibilityChange(jApiHasAnnotations, JApiCompatibilityChangeType.ANNOTATION_ADDED);
} else {
checkIfMethodsHaveChangedIncompatible(annotationClass, classMap);
checkIfFieldsHaveChangedIncompatible(annotationClass, classMap);
if (!annotationClass.isSourceCompatible() || !annotationClass.isBinaryCompatible()) {
addCompatibilityChange(jApiHasAnnotations, JApiCompatibilityChangeType.ANNOTATION_MODIFIED_INCOMPATIBLE);
} else {
addCompatibilityChange(jApiHasAnnotations, JApiCompatibilityChangeType.ANNOTATION_MODIFIED);
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public enum JApiCompatibilityChangeType {
ANNOTATION_ADDED(true, true, JApiSemanticVersionLevel.PATCH),
ANNOTATION_DEPRECATED_ADDED(true, true, JApiSemanticVersionLevel.MINOR),
ANNOTATION_MODIFIED(true, true, JApiSemanticVersionLevel.PATCH),
ANNOTATION_MODIFIED_INCOMPATIBLE(true, true, JApiSemanticVersionLevel.PATCH),
ANNOTATION_REMOVED(true, true, JApiSemanticVersionLevel.PATCH),
CLASS_REMOVED(false, false, JApiSemanticVersionLevel.MAJOR),
Expand Down
4 changes: 4 additions & 0 deletions src/site/markdown/MavenPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ for each check. This allows you to customize the following verifications:

| Check | Default binary compatible | Default source compatible | Default semantic version level
|-------|---------------------------|---------------------------|--------------------------------|
| ANNOTATION_ADDED | true | true | PATCH |
| ANNOTATION_DEPRECATED_ADDED | true | true | MINOR |
| ANNOTATION_MODIFIED | true | true | PATCH |
| ANNOTATION_MODIFIED_INCOMPATIBLE | true | true | PATCH |
| ANNOTATION_REMOVED | true | true | PATCH |
| CLASS_REMOVED | false | false | MAJOR |
| CLASS_NOW_ABSTRACT | false | false | MAJOR |
| CLASS_NOW_FINAL | false | false | MAJOR |
Expand Down

0 comments on commit 70e68e5

Please sign in to comment.