Fix static member overrides in populateInherited{Field,Method}Sets

A static member should not override an equivalent member in a superclass
or superinterface. This commit makes us skip the union() calls for
static methods, such that the two disjoint sets are not incorrectly
joined together.

Signed-off-by: Graham <gpe@openrs2.dev>
remotes/1711806393567316936/master
Graham 4 years ago
parent 8cac7a48b5
commit 5103eb15a4
  1. 33
      asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt

@ -5,6 +5,7 @@ import dev.openrs2.asm.MemberRef
import dev.openrs2.asm.toBinaryClassName
import dev.openrs2.common.collect.DisjointSet
import dev.openrs2.common.collect.ForestDisjointSet
import org.objectweb.asm.Opcodes
import org.objectweb.asm.commons.Remapper
import org.objectweb.asm.tree.AbstractInsnNode
import org.objectweb.asm.tree.ClassNode
@ -120,21 +121,33 @@ class ClassPath(
if (superClass != null) {
val fields = populateInheritedFieldSets(ancestorCache, disjointSet, superClass)
for (field in fields) {
val access = clazz.getFieldAccess(field)
if (access != null && access and Opcodes.ACC_STATIC != 0) {
continue
}
val partition1 = disjointSet.add(MemberRef(clazz.name, field))
val partition2 = disjointSet.add(MemberRef(superClass.name, field))
disjointSet.union(partition1, partition2)
ancestorsBuilder.add(field)
}
ancestorsBuilder.addAll(fields)
}
for (superInterface in clazz.superInterfaces) {
val fields = populateInheritedFieldSets(ancestorCache, disjointSet, superInterface)
for (field in fields) {
val access = clazz.getFieldAccess(field)
if (access != null && access and Opcodes.ACC_STATIC != 0) {
continue
}
val partition1 = disjointSet.add(MemberRef(clazz.name, field))
val partition2 = disjointSet.add(MemberRef(superInterface.name, field))
disjointSet.union(partition1, partition2)
ancestorsBuilder.add(field)
}
ancestorsBuilder.addAll(fields)
}
for (field in clazz.fields) {
@ -175,21 +188,33 @@ class ClassPath(
if (superClass != null) {
val methods = populateInheritedMethodSets(ancestorCache, disjointSet, superClass)
for (method in methods) {
val access = clazz.getMethodAccess(method)
if (access != null && access and Opcodes.ACC_STATIC != 0) {
continue
}
val partition1 = disjointSet.add(MemberRef(clazz.name, method))
val partition2 = disjointSet.add(MemberRef(superClass.name, method))
disjointSet.union(partition1, partition2)
ancestorsBuilder.add(method)
}
ancestorsBuilder.addAll(methods)
}
for (superInterface in clazz.superInterfaces) {
val methods = populateInheritedMethodSets(ancestorCache, disjointSet, superInterface)
for (method in methods) {
val access = clazz.getMethodAccess(method)
if (access != null && access and Opcodes.ACC_STATIC != 0) {
continue
}
val partition1 = disjointSet.add(MemberRef(clazz.name, method))
val partition2 = disjointSet.add(MemberRef(superInterface.name, method))
disjointSet.union(partition1, partition2)
ancestorsBuilder.add(method)
}
ancestorsBuilder.addAll(methods)
}
for (method in clazz.methods) {

Loading…
Cancel
Save