Skip to content

Commit

Permalink
修复getSimpleName的remap返回结果错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Luohuayu committed Oct 23, 2021
1 parent 496b12f commit dcb9e41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/main/java/catserver/server/remapper/RemapUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,21 @@ public static boolean isNeedRemapClass(Class<?> clazz, boolean checkSuperClass)
classNeedRemap.put(className, false);
return false;
}

public static String fixSimpleName(String originSimpleName, String remappedSimpleName) {
if (remappedSimpleName.contains("$")) {
String[] originSplit = originSimpleName.split("\\$");
String[] remappedSplit = remappedSimpleName.split("\\$");
int length = remappedSplit.length - originSplit.length;
if (length > 0) {
StringBuilder sb = new StringBuilder();
while (length > 0) {
sb.append(remappedSplit[length - 1]);
if (--length > 0) sb.append("$");
}
return sb.toString();
}
}
return remappedSimpleName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static String getSimpleName(Class<?> inst) {
String cache = simpleNameGetNameCache.get(inst);
if (cache != null) return cache;
String[] name = RemapUtils.reverseMapExternal(inst).split("\\.");
String retn = name[name.length - 1];
String retn = RemapUtils.fixSimpleName(name[name.length - 1], inst.getSimpleName());
simpleNameGetNameCache.put(inst, retn);
return retn;
}
Expand Down

0 comments on commit dcb9e41

Please sign in to comment.