Skip to content

Commit 6015659

Browse files
committed
Force exceptions to use / instead of . Aparently FF decompiles them correctly, but it causes duplications later down the line.
1 parent d6a5f4d commit 6015659

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/main/java/de/oceanlabs/mcp/mcinjector/GenerateMapClassAdapter.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
3939
{
4040
return super.visitMethod(access, name, desc, signature, exceptions);
4141
}
42-
42+
4343
log.log(Level.FINE, " Name: " + name + " Desc: " + desc + " Sig: " + signature);
4444
String clsSig = this.className + "." + name + desc;
45-
45+
4646

4747
// abstract and native methods don't have a Code attribute
4848
//if ((access & Opcodes.ACC_ABSTRACT) != 0 || (access & Opcodes.ACC_NATIVE) != 0)
4949
//{
5050
// return super.visitMethod(access, name, desc, signature, exceptions);
5151
//}
52-
52+
5353
List<String> names = new ArrayList<String>();
5454
List<Type> types = new ArrayList<Type>();
5555
int idx = 0;
56-
56+
5757
if ((access & Opcodes.ACC_STATIC) == 0)
5858
{
5959
idx = 1;
@@ -62,7 +62,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
6262
}
6363

6464
types.addAll(Arrays.asList(Type.getArgumentTypes(desc)));
65-
65+
6666
//Skip anything with no params
6767
if (types.size() == 0)
6868
{
@@ -79,15 +79,15 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
7979
generateUnique(idx, clsSig, name, names, types);
8080
}
8181

82-
if (names.size() > idx)
82+
if (names.size() > idx)
8383
{
8484
mci.setParams(clsSig, StringUtil.joinString(names.subList(idx, names.size()), ","));
8585
}
8686
else
8787
{
8888
mci.setParams(clsSig, "");
8989
}
90-
90+
9191
return super.visitMethod(access, name, desc, signature, exceptions);
9292
}
9393

@@ -112,7 +112,7 @@ private void generateUnique(int idx, String clsSig, String methodName, List<Stri
112112
for (int x = idx, y = x; x < types.size(); x++, y++)
113113
{
114114
String desc = types.get(x).getDescriptor();
115-
String name = String.format("p_%s_%d_", funcId, y);
115+
String name = String.format("p_%s_%d_", funcId, y);
116116
names.add(name);
117117
log.fine(" Naming argument " + x + " (" + y + ") -> " + name + " " + desc);
118118
if (desc.equals("J") || desc.equals("D")) y++;

src/main/java/de/oceanlabs/mcp/mcinjector/MCInjectorImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,9 @@ public List<String> getExceptions(String signature)
352352
String curMap = this.mappings.getProperty(signature);
353353
if (curMap == null) return new ArrayList<String>();
354354
List<String> splitMap = StringUtil.splitString(curMap, "|", -1);
355-
if (splitMap.get(0).equals("")) return new ArrayList<String>();
356-
return StringUtil.splitString(splitMap.get(0), ",");
355+
String exceptions = splitMap.get(0).replace('.', '/'); //Just in case the map is messed up, classes can not have .'s
356+
if (exceptions.equals("")) return new ArrayList<String>();
357+
return StringUtil.splitString(exceptions, ",");
357358
}
358359

359360
public List<String> getParams(String signature)

0 commit comments

Comments
 (0)