Commit e4fc6774 authored by Skylot's avatar Skylot

fix: make correct hash calculation for GenericObject type (#705)

parent f57dfb3f
...@@ -156,7 +156,7 @@ public abstract class ArgType { ...@@ -156,7 +156,7 @@ public abstract class ArgType {
} }
private static class ObjectType extends KnownType { private static class ObjectType extends KnownType {
private final String objName; protected final String objName;
public ObjectType(String obj) { public ObjectType(String obj) {
this.objName = Utils.cleanObjectName(obj); this.objName = Utils.cleanObjectName(obj);
...@@ -269,15 +269,18 @@ public abstract class ArgType { ...@@ -269,15 +269,18 @@ public abstract class ArgType {
super(obj); super(obj);
this.outerType = null; this.outerType = null;
this.generics = generics; this.generics = generics;
this.hash = obj.hashCode() + 31 * Arrays.hashCode(generics); this.hash = calcHash();
} }
public GenericObject(GenericObject outerType, String innerName, ArgType[] generics) { public GenericObject(GenericObject outerType, String innerName, ArgType[] generics) {
super(outerType.getObject() + '$' + innerName); super(outerType.getObject() + '$' + innerName);
this.outerType = outerType; this.outerType = outerType;
this.generics = generics; this.generics = generics;
this.hash = outerType.hashCode() + 31 * innerName.hashCode() this.hash = calcHash();
+ 31 * 31 * Arrays.hashCode(generics); }
private int calcHash() {
return objName.hashCode() + 31 * Arrays.hashCode(generics);
} }
@Override @Override
......
package jadx.core.dex.instructions.args;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class ArgTypeTest {
@Test
void testEqualsOfGenericTypes() {
ArgType first = ArgType.generic("java.lang.List", ArgType.STRING);
ArgType second = ArgType.generic("Ljava/lang/List;", ArgType.STRING);
assertEquals(first, second);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment