Skip to content

Commit cd5f231

Browse files
committed
Fix array not being resized
1 parent f7b5037 commit cd5f231

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ artifacts {
3838
}
3939

4040
dependencies {
41-
compile 'org.ow2.asm:asm:6.0'
42-
compile 'org.ow2.asm:asm-tree:6.0'
41+
compile 'org.ow2.asm:asm:6.1-beta2'
42+
compile 'org.ow2.asm:asm-tree:6.1-beta2'
4343
compile 'net.sf.jopt-simple:jopt-simple:4.5'
4444
compile 'com.google.code.gson:gson:2.2.4'
4545
}

src/main/java/de/oceanlabs/mcp/mcinjector/adaptors/ParameterAnnotationFixer.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ public class ParameterAnnotationFixer extends ClassVisitor
2222

2323
public ParameterAnnotationFixer(ClassVisitor cn, MCInjectorImpl mci)
2424
{
25-
super(Opcodes.ASM5, cn);
25+
super(Opcodes.ASM6, cn);
26+
// Extra version check, since these were added in ASM 6.1 and there
27+
// isn't a constant for it
28+
try {
29+
MethodNode.class.getField("visibleAnnotableParameterCount");
30+
MethodNode.class.getField("invisibleAnnotableParameterCount");
31+
} catch (Exception ex) {
32+
throw new IllegalArgumentException(
33+
"AnnotableParameterCount fields are not present -- wrong ASM version?",
34+
ex);
35+
}
2636
}
2737

2838
@Override
@@ -123,6 +133,16 @@ private void processConstructor(ClassNode cls, MethodNode mn, Type[] syntheticPa
123133
mn.invisibleParameterAnnotations = process(methodInfo,
124134
"RuntimeInvisibleParameterAnnotations", params.length,
125135
syntheticParams.length, mn.invisibleParameterAnnotations);
136+
// ASM uses this value, not the length of the array
137+
// Note that this was added in ASM 6.1
138+
if (mn.visibleParameterAnnotations != null)
139+
{
140+
mn.visibleAnnotableParameterCount = mn.visibleParameterAnnotations.length;
141+
}
142+
if (mn.invisibleParameterAnnotations != null)
143+
{
144+
mn.invisibleAnnotableParameterCount = mn.invisibleParameterAnnotations.length;
145+
}
126146
}
127147
else
128148
{

0 commit comments

Comments
 (0)