Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not remap inner class names #30

Merged
merged 1 commit into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions jarjar/src/main/java/com/eed3si9n/jarjar/PackageRemapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ public Object mapValue(Object value) {
}
}

@Override
public String mapInnerClassName(
final String name, final String ownerName, final String innerName) {
// The default method would try to be smart and find the inner class name
// by looking at the $ sign. As the documentation calls out, this works in java
// but not necessarily in other languages, including scala, where $ has multiple applications.
// Since we actually don't care about remapping class names, only packages, we can ignore this
return innerName;
}

private String replaceHelper(String value) {
for (Wildcard wildcard : wildcards) {
String test = wildcard.replace(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public void testMapValue() {
assertEquals("foo/example.package-info", remapper.mapValue("org/example.package-info"));
}

@Test
public void testUnchangedInnerClassNames() {
String outer = "scala.collection.immutable.IntMap";
String inner = "Nil$";
assertEquals(inner, remapper.mapInnerClassName(outer + "$" + inner, outer, inner));
}

private void assertUnchangedValue(String value) {
assertEquals(value, remapper.mapValue(value));
}
Expand Down