in tools/javac/ApiComparator.java [161:198]
public static Node compare(Api.Type a, Api.Type b) {
Node node = new Node(a, b);
if (node.diff == Diff.ADDED) {
node.compatibility = Compatibility.MINOR;
} else if (node.diff == Diff.REMOVED) {
node.compatibility = Compatibility.MAJOR;
node.messages.add(Message.BREAKING_CHANGES);
} else {
node.child = compare(a.types, b.types, ApiComparator::compare, node.child);
node.child = compare(a.methods, b.methods, ApiComparator::compare, node.child);
node.child = compare(a.fields, b.fields, ApiComparator::compare, node.child);
// Breaking changes
node.check(a.kind != b.kind, "changed kind");
node.check(!b.supertypes.containsAll(a.supertypes), "contracted supertype set");
node.check(!Arrays.equals(a.typeParameters, b.typeParameters), "changed type parameters");
node.check(a.usage.inheritableByBackend && !b.usage.inheritableByBackend, "prohibited inheritance by backend");
node.check(a.usage.inheritableByClient && !b.usage.inheritableByClient, "prohibited inheritance by client");
if (node.diff != Diff.NONE) {
node.compatibility = Compatibility.MAJOR;
node.messages.add(Message.BREAKING_CHANGES);
return node;
}
if (compareModifiers(node, a.modifiers, b.modifiers)) return node;
// Compatible changes
node.check(a.supertypes.size() != b.supertypes.size(), "expanded supertype set");
node.check(a.deprecation != b.deprecation, "changed deprecation state");
node.check(!a.usage.inheritableByBackend && b.usage.inheritableByBackend, "allowed inheritance by backend");
node.check(!a.usage.inheritableByClient && b.usage.inheritableByClient, "allowed inheritance by client");
if (node.diff != Diff.NONE) {
node.compatibility = Compatibility.MINOR;
return node;
}
}
return node;
}