Skip to content

Commit

Permalink
fixes #2
Browse files Browse the repository at this point in the history
were using ILOAD for loading an array onto the stack - ouch!
  • Loading branch information
Eric Bodden committed Apr 21, 2015
1 parent 212eecf commit d64267a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.ARETURN;
import static org.objectweb.asm.Opcodes.ILOAD;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;

import java.lang.reflect.Array;
Expand All @@ -38,7 +37,7 @@ protected MethodVisitor getMethodVisitor(MethodVisitor parent) {
public void visitInsn(int opcode) {
if (opcode == ARETURN) {
mv.visitVarInsn(ALOAD, 0); // Load Class instance
mv.visitVarInsn(ILOAD, 1); // Load dimension
mv.visitVarInsn(loadDimensionOpcode(), 1); // Load dimension
mv.visitMethodInsn(INVOKESTATIC, "de/bodden/tamiflex/playout/rt/ReflLogger", methodName(), methodSignature());
}
super.visitInsn(opcode);
Expand All @@ -50,4 +49,7 @@ public void visitInsn(int opcode) {
protected abstract String methodName();

protected abstract String methodSignature();

protected abstract int loadDimensionOpcode();

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
******************************************************************************/
package de.bodden.tamiflex.playout.transformation.array;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.Method;

public class ArrayMultiNewInstanceTransformation extends AbstractArrayTransformation {
Expand All @@ -37,4 +38,10 @@ protected String methodName() {
protected String methodSignature() {
return "(Ljava/lang/Class;[I)V";
}

@Override
protected int loadDimensionOpcode() {
return Opcodes.ALOAD;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
******************************************************************************/
package de.bodden.tamiflex.playout.transformation.array;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.Method;

public class ArrayNewInstanceTransformation extends AbstractArrayTransformation {
Expand All @@ -27,4 +28,9 @@ protected String methodName() {
protected String methodSignature() {
return "(Ljava/lang/Class;I)V";
}

@Override
protected int loadDimensionOpcode() {
return Opcodes.ILOAD;
}
}

0 comments on commit d64267a

Please sign in to comment.