Skip to content

Commit

Permalink
#349: no IllegalStateException when method is removed from Sub-Class …
Browse files Browse the repository at this point in the history
…and Super-Class
  • Loading branch information
siom79 committed Nov 16, 2022
1 parent dd0a642 commit 5b71a6c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions japicmp/src/main/java/japicmp/compat/CompatibilityChanges.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,22 +382,23 @@ public Integer callback(JApiClass superclass, Map<String, JApiClass> classMap, J
}
if (isNotPrivate(method) && method.getChangeStatus() == JApiChangeStatus.REMOVED) {
List<Integer> returnValues = new ArrayList<>();
forAllSuperclasses(jApiClass, classMap, returnValues, new OnSuperclassCallback<Integer>() {
@Override
public Integer callback(JApiClass superclass, Map<String, JApiClass> classMap, JApiChangeStatus changeStatusOfSuperclass) {
for (JApiMethod superMethod : superclass.getMethods()) {
if (areMatching(superMethod, method)) {
if (method.getFinalModifier().getOldModifier().get() == FinalModifier.NON_FINAL
&& superMethod.getFinalModifier().getNewModifier().get() == FinalModifier.FINAL) {
return 1;
}
forAllSuperclasses(jApiClass, classMap, returnValues, (superclass, classMap1, changeStatusOfSuperclass) -> {
for (JApiMethod superMethod : superclass.getMethods()) {
if (areMatching(superMethod, method)) {
if (method.getFinalModifier().getOldModifier().isPresent()
&& method.getFinalModifier().getOldModifier().get() == FinalModifier.NON_FINAL
&& superMethod.getFinalModifier().getNewModifier().isPresent()
&& superMethod.getFinalModifier().getNewModifier().get() == FinalModifier.FINAL) {
addCompatibilityChange(superMethod, JApiCompatibilityChange.METHOD_NOW_FINAL);
return 1;
}
}
return 0;
}
return 0;
});
if (returnValues.stream().anyMatch(value -> value == 1)) {
addCompatibilityChange(method, JApiCompatibilityChange.METHOD_NOW_FINAL);
addCompatibilityChange(method, JApiCompatibilityChange.METHOD_MOVED_TO_SUPERCLASS);
}
}
// section 13.4.18 of "Java Language Specification" SE7
Expand Down

0 comments on commit 5b71a6c

Please sign in to comment.