Commit 4084b2db authored by Remi Forax's avatar Remi Forax

Merge branch 'fix-317805' into 'master'

Fix for #317805

Closes #317805

See merge request !90
parents be3e73d1 2530c4b4
Pipeline #583 passed with stage
in 5 minutes and 41 seconds
......@@ -802,12 +802,18 @@ public class Type {
case INTERNAL:
return opcode + (Opcodes.AALOAD - Opcodes.IALOAD);
case METHOD:
case VOID:
throw new UnsupportedOperationException();
default:
throw new AssertionError();
}
} else {
switch (sort) {
case VOID:
if (opcode != Opcodes.IRETURN) {
throw new UnsupportedOperationException();
}
return Opcodes.RETURN;
case BOOLEAN:
case BYTE:
case CHAR:
......@@ -815,14 +821,18 @@ public class Type {
case INT:
return opcode;
case FLOAT:
return opcode + (Opcodes.FLOAD - Opcodes.ILOAD);
return opcode + (Opcodes.FRETURN - Opcodes.IRETURN);
case LONG:
return opcode + (Opcodes.LLOAD - Opcodes.ILOAD);
return opcode + (Opcodes.LRETURN - Opcodes.IRETURN);
case DOUBLE:
return opcode + (Opcodes.DLOAD - Opcodes.ILOAD);
return opcode + (Opcodes.DRETURN - Opcodes.IRETURN);
case ARRAY:
case OBJECT:
case INTERNAL:
if (opcode != Opcodes.ILOAD && opcode != Opcodes.ISTORE && opcode != Opcodes.IRETURN) {
throw new UnsupportedOperationException();
}
return opcode + (Opcodes.ARETURN - Opcodes.IRETURN);
case METHOD:
throw new UnsupportedOperationException();
default:
......
......@@ -322,6 +322,23 @@ public class TypeTest implements Opcodes {
assertEquals(AALOAD, Type.getObjectType("java/lang/Object").getOpcode(IALOAD));
assertEquals(AASTORE, Type.getType("Ljava/lang/Object;").getOpcode(IASTORE));
assertEquals(AASTORE, Type.getObjectType("java/lang/Object").getOpcode(IASTORE));
assertEquals(AASTORE, Type.getType("[I").getOpcode(IASTORE));
assertEquals(RETURN, Type.VOID_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(IRETURN, Type.BOOLEAN_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(IRETURN, Type.BYTE_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(IRETURN, Type.CHAR_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(IRETURN, Type.SHORT_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(IRETURN, Type.INT_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(FRETURN, Type.FLOAT_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(LRETURN, Type.LONG_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(DRETURN, Type.DOUBLE_TYPE.getOpcode(Opcodes.IRETURN));
assertEquals(ARETURN, Type.getType("Ljava/lang/Object;").getOpcode(Opcodes.IRETURN));
assertEquals(ARETURN, Type.getObjectType("java/lang/Object").getOpcode(Opcodes.IRETURN));
assertEquals(ARETURN, Type.getType("Ljava/lang/Object;").getOpcode(Opcodes.IRETURN));
assertEquals(ARETURN, Type.getObjectType("java/lang/Object").getOpcode(Opcodes.IRETURN));
assertEquals(ARETURN, Type.getType("[I").getOpcode(Opcodes.IRETURN));
assertEquals(IADD, Type.BOOLEAN_TYPE.getOpcode(IADD));
assertEquals(IADD, Type.BYTE_TYPE.getOpcode(IADD));
assertEquals(IADD, Type.CHAR_TYPE.getOpcode(IADD));
......@@ -332,6 +349,9 @@ public class TypeTest implements Opcodes {
assertEquals(DADD, Type.DOUBLE_TYPE.getOpcode(IADD));
Class<UnsupportedOperationException> expectedException = UnsupportedOperationException.class;
assertThrows(expectedException, () -> Type.VOID_TYPE.getOpcode(IADD));
assertThrows(expectedException, () -> Type.VOID_TYPE.getOpcode(ILOAD));
assertThrows(expectedException, () -> Type.VOID_TYPE.getOpcode(IALOAD));
assertThrows(expectedException, () -> Type.getType("LI;").getOpcode(IADD));
assertThrows(expectedException, () -> Type.getType("[I").getOpcode(IADD));
assertThrows(expectedException, () -> Type.getObjectType("I").getOpcode(IADD));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment