Skip to content
This repository was archived by the owner on Feb 17, 2022. It is now read-only.

Commit 7de6cc1

Browse files
committed
Fix bug
1 parent b249a36 commit 7de6cc1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The entry will automatically add itself to the constant pool on creation.
2222
##### Adding methods
2323
Here comes the juicy part: methods. Adding a method is slightly more complex.
2424
```java
25-
Method m = new Method(new UTF8Entry(aClass.getConstantPool(), "yourMethodName"), new UTF8Entry(aClass.getConstantPool(), "(Lsome.Type;)V"));
25+
Method m = new Method(new UTF8Entry(aClass.getConstantPool(), "yourMethodName"), new UTF8Entry(aClass.getConstantPool(), "(Lsome/Type;)V"));
2626
m.setAccessFlags(MethodAccessFlags.PUBLIC);
2727
aClass.getMethods().add(m);
2828
```

src/main/java/io/github/seggan/javaclasslib/util/JCLUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import javax.annotation.Nonnull;
66
import javax.annotation.ParametersAreNonnullByDefault;
77
import java.util.Map;
8+
import java.util.regex.Pattern;
89

910
public class JCLUtils {
1011

1112
private static final Map<Class<?>, Character> BASE_TYPES;
13+
private static final Pattern PERIOD = Pattern.compile("\\.");
1214

1315
static {
1416
ImmutableMap.Builder<Class<?>, Character> builder = ImmutableMap.builder();
@@ -49,7 +51,7 @@ public static String generateMethodSignature(Class<?> returnType, Class<?>... pa
4951
sb.append(BASE_TYPES.get(c));
5052
} else {
5153
sb.append('L');
52-
sb.append(c.getName());
54+
sb.append(PERIOD.matcher(c.getName()).replaceAll("/"));
5355
sb.append(';');
5456
}
5557
}
@@ -66,7 +68,7 @@ public static String generateMethodSignature(Class<?> returnType, Class<?>... pa
6668
sb.append(BASE_TYPES.get(c));
6769
} else {
6870
sb.append('L');
69-
sb.append(c.getName());
71+
sb.append(PERIOD.matcher(c.getName()).replaceAll("/"));
7072
sb.append(';');
7173
}
7274

0 commit comments

Comments
 (0)