Skip to content

Commit 5b71a6c

Browse files
committed
#349: no IllegalStateException when method is removed from Sub-Class and Super-Class
1 parent dd0a642 commit 5b71a6c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

japicmp/src/main/java/japicmp/compat/CompatibilityChanges.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,23 @@ public Integer callback(JApiClass superclass, Map<String, JApiClass> classMap, J
382382
}
383383
if (isNotPrivate(method) && method.getChangeStatus() == JApiChangeStatus.REMOVED) {
384384
List<Integer> returnValues = new ArrayList<>();
385-
forAllSuperclasses(jApiClass, classMap, returnValues, new OnSuperclassCallback<Integer>() {
386-
@Override
387-
public Integer callback(JApiClass superclass, Map<String, JApiClass> classMap, JApiChangeStatus changeStatusOfSuperclass) {
388-
for (JApiMethod superMethod : superclass.getMethods()) {
389-
if (areMatching(superMethod, method)) {
390-
if (method.getFinalModifier().getOldModifier().get() == FinalModifier.NON_FINAL
391-
&& superMethod.getFinalModifier().getNewModifier().get() == FinalModifier.FINAL) {
392-
return 1;
393-
}
385+
forAllSuperclasses(jApiClass, classMap, returnValues, (superclass, classMap1, changeStatusOfSuperclass) -> {
386+
for (JApiMethod superMethod : superclass.getMethods()) {
387+
if (areMatching(superMethod, method)) {
388+
if (method.getFinalModifier().getOldModifier().isPresent()
389+
&& method.getFinalModifier().getOldModifier().get() == FinalModifier.NON_FINAL
390+
&& superMethod.getFinalModifier().getNewModifier().isPresent()
391+
&& superMethod.getFinalModifier().getNewModifier().get() == FinalModifier.FINAL) {
392+
addCompatibilityChange(superMethod, JApiCompatibilityChange.METHOD_NOW_FINAL);
393+
return 1;
394394
}
395395
}
396-
return 0;
397396
}
397+
return 0;
398398
});
399399
if (returnValues.stream().anyMatch(value -> value == 1)) {
400400
addCompatibilityChange(method, JApiCompatibilityChange.METHOD_NOW_FINAL);
401+
addCompatibilityChange(method, JApiCompatibilityChange.METHOD_MOVED_TO_SUPERCLASS);
401402
}
402403
}
403404
// section 13.4.18 of "Java Language Specification" SE7

0 commit comments

Comments
 (0)