Unboxing Integer Problem #50

Open
opened 2019-06-05 10:27:06 +00:00 by pl · 4 comments
Owner

Branch: bigRefactoring
commit: 2b7aef5e87

VectorAdd.jav

public class VectorAdd {
vectorAdd(v1, v2) {
var i = 0;
var erg = new Vector<>();
while (i < v1.size()) {
erg.addElement(v1.elementAt(i) + v2.elementAt(i));
i++;
}
return erg;
}
}

liefert

java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
VectorAdd.vectorAdd(Ljava/util/Vector;Ljava/util/Vector;)Ljava/util/Vector; @49: iadd
Reason:
Type 'java/lang/Integer' (current frame, stack[2]) is not assignable to integer
Current Frame:
bci: @49
flags: { }
locals: { 'VectorAdd', 'java/util/Vector', 'java/util/Vector', 'java/lang/Integer', 'java/util/Vector' }
stack: { 'java/util/Vector', 'java/lang/Integer', 'java/lang/Integer' }
Bytecode:
0x0000000: 03b8 0012 4ebb 0014 59b7 0015 3a04 2db6
0x0000010: 0019 2bb6 001c a200 2c19 042b 2db6 0019
0x0000020: b600 20c0 000e 2c2d b600 19b6 0020 c000
0x0000030: 0e60 b600 242d b600 1904 60b8 0012 4ea7
0x0000040: ffcf 1904 b0
Stackmap Table:
append_frame(@14,Object[#14],Object[#20])
same_frame(@66)

at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at bytecode.VectorAddTest.test(VectorAddTest.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Branch: bigRefactoring commit: 2b7aef5e87b0cd8d6055a0e70feea74552858c91 VectorAdd.jav public class VectorAdd { vectorAdd(v1, v2) { var i = 0; var erg = new Vector<>(); while (i < v1.size()) { erg.addElement(v1.elementAt(i) + v2.elementAt(i)); i++; } return erg; } } liefert java.lang.VerifyError: Bad type on operand stack Exception Details: Location: VectorAdd.vectorAdd(Ljava/util/Vector;Ljava/util/Vector;)Ljava/util/Vector; @49: iadd Reason: Type 'java/lang/Integer' (current frame, stack[2]) is not assignable to integer Current Frame: bci: @49 flags: { } locals: { 'VectorAdd', 'java/util/Vector', 'java/util/Vector', 'java/lang/Integer', 'java/util/Vector' } stack: { 'java/util/Vector', 'java/lang/Integer', 'java/lang/Integer' } Bytecode: 0x0000000: 03b8 0012 4ebb 0014 59b7 0015 3a04 2db6 0x0000010: 0019 2bb6 001c a200 2c19 042b 2db6 0019 0x0000020: b600 20c0 000e 2c2d b600 19b6 0020 c000 0x0000030: 0e60 b600 242d b600 1904 60b8 0012 4ea7 0x0000040: ffcf 1904 b0 Stackmap Table: append_frame(@14,Object[#14],Object[#20]) same_frame(@66) at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) at java.lang.Class.getConstructor0(Class.java:3075) at java.lang.Class.getDeclaredConstructor(Class.java:2178) at bytecode.VectorAddTest.test(VectorAddTest.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Author
Owner

Jetzt ist der Fehler bei VectorAdd.jav doch noch aufgetreten:

java.lang.ArrayIndexOutOfBoundsException: 0
at org.objectweb.asm.Frame.merge(Frame.java:1263)
at org.objectweb.asm.Frame.merge(Frame.java:1239)
at org.objectweb.asm.MethodWriter.computeAllFrames(MethodWriter.java:1617)
at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1553)
at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:475)
at de.dhbwstuttgart.syntaxtree.Method.accept(Method.java:61)
at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:272)
at de.dhbwstuttgart.syntaxtree.ClassOrInterface.accept(ClassOrInterface.java:114)
at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:145)
at de.dhbwstuttgart.core.JavaTXCompiler.generateBytecode(JavaTXCompiler.java:665)
at bytecode.VectorAddTest.test(VectorAddTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)

Jetzt ist der Fehler bei VectorAdd.jav doch noch aufgetreten: java.lang.ArrayIndexOutOfBoundsException: 0 at org.objectweb.asm.Frame.merge(Frame.java:1263) at org.objectweb.asm.Frame.merge(Frame.java:1239) at org.objectweb.asm.MethodWriter.computeAllFrames(MethodWriter.java:1617) at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1553) at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:475) at de.dhbwstuttgart.syntaxtree.Method.accept(Method.java:61) at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:272) at de.dhbwstuttgart.syntaxtree.ClassOrInterface.accept(ClassOrInterface.java:114) at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:145) at de.dhbwstuttgart.core.JavaTXCompiler.generateBytecode(JavaTXCompiler.java:665) at bytecode.VectorAddTest.test(VectorAddTest.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)

Gefixt.

branch bytecode 2
commit 3c36c61077

Gefixt. branch bytecode 2 commit 3c36c6107797c3c14e23619b96b6b3aa18259bd7
Author
Owner

Ich bekomme leider immernoch den gleichen Fehler

Bei
Vector v1 = new Vector ();
v1.add(1);
v1.add(2);
Vector v2 = new Vector ();
v2.add(3);
v2.add(4);
VectorAdd va = new VectorAdd();
System.out.println(va.vectorAdd(v1, v2));

Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
VectorAdd.vectorAdd(Ljava/util/Vector;Ljava/util/Vector;)Ljava/util/Vector; @49: iadd
Reason:
Type 'java/lang/Integer' (current frame, stack[2]) is not assignable to integer
Current Frame:
bci: @49
flags: { }
locals: { 'VectorAdd', 'java/util/Vector', 'java/util/Vector', 'java/lang/Integer', 'java/util/Vector' }
stack: { 'java/util/Vector', 'java/lang/Integer', 'java/lang/Integer' }
Bytecode:
0000000: 03b8 0012 4ebb 0014 59b7 0015 3a04 2db6
0000010: 0019 2bb6 001c a200 2f19 042b 2db6 0019
0000020: b600 20c0 000e 2c2d b600 19b6 0020 c000
0000030: 0e60 b800 12b6 0024 2db6 0019 0460 b800
0000040: 124e a7ff cc19 04b0
Stackmap Table:
append_frame(@14,Object[#14],Object[#20])
same_frame(@69)

at Main.main(Main.java:75)
Ich bekomme leider immernoch den gleichen Fehler Bei Vector<Integer> v1 = new Vector<Integer> (); v1.add(1); v1.add(2); Vector<Integer> v2 = new Vector<Integer> (); v2.add(3); v2.add(4); VectorAdd va = new VectorAdd(); System.out.println(va.vectorAdd(v1, v2)); Exception in thread "main" java.lang.VerifyError: Bad type on operand stack Exception Details: Location: VectorAdd.vectorAdd(Ljava/util/Vector;Ljava/util/Vector;)Ljava/util/Vector; @49: iadd Reason: Type 'java/lang/Integer' (current frame, stack[2]) is not assignable to integer Current Frame: bci: @49 flags: { } locals: { 'VectorAdd', 'java/util/Vector', 'java/util/Vector', 'java/lang/Integer', 'java/util/Vector' } stack: { 'java/util/Vector', 'java/lang/Integer', 'java/lang/Integer' } Bytecode: 0000000: 03b8 0012 4ebb 0014 59b7 0015 3a04 2db6 0000010: 0019 2bb6 001c a200 2f19 042b 2db6 0019 0000020: b600 20c0 000e 2c2d b600 19b6 0020 c000 0000030: 0e60 b800 12b6 0024 2db6 0019 0460 b800 0000040: 124e a7ff cc19 04b0 Stackmap Table: append_frame(@14,Object[#14],Object[#20]) same_frame(@69) at Main.main(Main.java:75)

Gefixt.

branch bytecode2
commit c2030123d5

Gefixt. branch bytecode2 commit c2030123d5f520aa50f7ffa26639722d2929e920
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: JavaTX/JavaCompilerCore#50
No description provided.