Skip to content

Commit

Permalink
Fixes linkedin#124: Changed DexMaker#generateFileName() to consider t…
Browse files Browse the repository at this point in the history
…he interfaces
  • Loading branch information
tmurakami authored and drewhannay committed Nov 15, 2018
1 parent d0d5b5d commit 6cb8a28
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,30 @@ private void addMethodToDexMakerGenerator(TypeId<?> typeId, String methodName, T
}
}

public interface BlankInterfaceA {}

public interface BlankInterfaceB {}

@Test
public void testCaching_DifferentInterfaces() throws Exception {
int origSize = getDataDirectory().listFiles().length;

// Create new dexmaker generator with BlankInterfaceA.
dexMaker = new DexMaker();
TypeId interfaceA = TypeId.get(BlankInterfaceA.class);
dexMaker.declare(GENERATED, "Generated.java", PUBLIC, TypeId.OBJECT, interfaceA);
generateAndLoad();
int numFiles = getDataDirectory().listFiles().length;
assertTrue(origSize < numFiles);

// Create new dexmaker generator with BlankInterfaceB.
dexMaker = new DexMaker();
TypeId interfaceB = TypeId.get(BlankInterfaceB.class);
dexMaker.declare(GENERATED, "Generated.java", PUBLIC, TypeId.OBJECT, interfaceB);
generateAndLoad();
assertTrue(numFiles < getDataDirectory().listFiles().length);
}

@Test
public void testCaching_Constructors() throws Exception {
int origSize = getDataDirectory().listFiles().length;
Expand Down
3 changes: 2 additions & 1 deletion dexmaker/src/main/java/com/android/dx/DexMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ private String generateFileName() {
TypeDeclaration decl = getTypeDeclaration(typeId);
Set<MethodId> methodSet = decl.methods.keySet();
if (decl.supertype != null) {
checksums[i++] = 31 * decl.supertype.hashCode() + methodSet.hashCode();
int sum = 31 * decl.supertype.hashCode() + decl.interfaces.hashCode();
checksums[i++] = 31 * sum + methodSet.hashCode();
}
}
Arrays.sort(checksums);
Expand Down

0 comments on commit 6cb8a28

Please sign in to comment.