mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
fix: rename lambda className failed
This commit is contained in:
+4
-2
@@ -51,8 +51,10 @@ public class ClassRenameVisitorWrapper implements AsmVisitorWrapper {
|
||||
new Remapper() {
|
||||
@Override
|
||||
public String map(String typeName) {
|
||||
if (typeName.startsWith(originalClassName)) {
|
||||
return typeName.replaceFirst(originalClassName, newClassName);
|
||||
if (typeName.equals(originalClassName)) {
|
||||
return newClassName;
|
||||
} else if (typeName.startsWith(originalClassName)) {
|
||||
return typeName.replace(originalClassName, newClassName);
|
||||
} else {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.reajason.javaweb.buddy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2025/9/6
|
||||
*/
|
||||
class ClassRenameVisitorWrapperTest {
|
||||
|
||||
@Test
|
||||
void testFullName() {
|
||||
String originalName = "com/apache/injector";
|
||||
String newName = "com/hello$Proxy$$Lambda$1";
|
||||
assertEquals(newName, originalName.replace(originalName, newName));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPrefix() {
|
||||
String originalName = "com/apache";
|
||||
String newName = "com/hello";
|
||||
String className = "com/apache/injector";
|
||||
assertEquals("com/hello/injector", className.replace(originalName, newName));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWrongClassName() {
|
||||
String className = "+/.0o0o00o9o";
|
||||
String originalName = className;
|
||||
String newName = "com/hello/injector";
|
||||
String expected = "com/hello/injector";
|
||||
assertEquals(expected, className.replace(originalName, newName));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user