[PATCH] Fix POP2 opcode handling bug with two category 1 values at the stack top.
This commit is contained in:
committed by
Egor Ushakov
parent
faaab500e3
commit
e7854376b8
@@ -1,18 +1,4 @@
|
|||||||
/*
|
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||||
* Copyright 2000-2017 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jetbrains.java.decompiler.modules.decompiler;
|
package org.jetbrains.java.decompiler.modules.decompiler;
|
||||||
|
|
||||||
import org.jetbrains.java.decompiler.code.CodeConstants;
|
import org.jetbrains.java.decompiler.code.CodeConstants;
|
||||||
@@ -618,8 +604,17 @@ public class ExprProcessor implements CodeConstants {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
break;
|
break;
|
||||||
case opc_pop:
|
case opc_pop:
|
||||||
case opc_pop2:
|
|
||||||
stack.pop();
|
stack.pop();
|
||||||
|
break;
|
||||||
|
case opc_pop2:
|
||||||
|
if (stack.getByOffset(-1).getExprType().stackSize == 1) {
|
||||||
|
// Since value at the top of the stack is a value of category 1 (JVMS9 2.11.1)
|
||||||
|
// we should remove one more item from the stack.
|
||||||
|
// See JVMS9 pop2 chapter.
|
||||||
|
stack.pop();
|
||||||
|
}
|
||||||
|
stack.pop();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,4 @@
|
|||||||
/*
|
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||||
* Copyright 2000-2017 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jetbrains.java.decompiler;
|
package org.jetbrains.java.decompiler;
|
||||||
|
|
||||||
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
|
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
|
||||||
@@ -111,6 +97,10 @@ public class SingleClassesTest {
|
|||||||
@Test public void testLambdaParams() { doTest("pkg/TestLambdaParams"); }
|
@Test public void testLambdaParams() { doTest("pkg/TestLambdaParams"); }
|
||||||
@Test public void testInterfaceMethods() { doTest("pkg/TestInterfaceMethods"); }
|
@Test public void testInterfaceMethods() { doTest("pkg/TestInterfaceMethods"); }
|
||||||
@Test public void testConstType() { doTest("pkg/TestConstType"); }
|
@Test public void testConstType() { doTest("pkg/TestConstType"); }
|
||||||
|
@Test public void testPop2OneDoublePop2() { doTest("pkg/TestPop2OneDoublePop2"); }
|
||||||
|
@Test public void testPop2OneLongPop2() { doTest("pkg/TestPop2OneLongPop2"); }
|
||||||
|
@Test public void testPop2TwoIntPop2() { doTest("pkg/TestPop2TwoIntPop2"); }
|
||||||
|
@Test public void testPop2TwoIntTwoPop() { doTest("pkg/TestPop2TwoIntTwoPop"); }
|
||||||
|
|
||||||
// TODO: fix all below
|
// TODO: fix all below
|
||||||
//@Test public void testPackageInfo() { doTest("pkg/package-info"); }
|
//@Test public void testPackageInfo() { doTest("pkg/package-info"); }
|
||||||
|
|||||||
BIN
testData/classes/pkg/TestPop2OneDoublePop2.class
Normal file
BIN
testData/classes/pkg/TestPop2OneDoublePop2.class
Normal file
Binary file not shown.
BIN
testData/classes/pkg/TestPop2OneLongPop2.class
Normal file
BIN
testData/classes/pkg/TestPop2OneLongPop2.class
Normal file
Binary file not shown.
BIN
testData/classes/pkg/TestPop2TwoIntPop2.class
Normal file
BIN
testData/classes/pkg/TestPop2TwoIntPop2.class
Normal file
Binary file not shown.
BIN
testData/classes/pkg/TestPop2TwoIntTwoPop.class
Normal file
BIN
testData/classes/pkg/TestPop2TwoIntTwoPop.class
Normal file
Binary file not shown.
27
testData/results/TestPop2OneDoublePop2.dec
Normal file
27
testData/results/TestPop2OneDoublePop2.dec
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package pkg;
|
||||||
|
|
||||||
|
public class TestPop2OneDoublePop2 {
|
||||||
|
public static void main(String... var0) {
|
||||||
|
double var10002 = 3.14159265358D;// 24
|
||||||
|
System.out.println(1234567890);// 22 23 26
|
||||||
|
}// 27
|
||||||
|
}
|
||||||
|
|
||||||
|
class 'pkg/TestPop2OneDoublePop2' {
|
||||||
|
method 'main ([Ljava/lang/String;)V' {
|
||||||
|
0 5
|
||||||
|
3 5
|
||||||
|
5 4
|
||||||
|
9 5
|
||||||
|
c 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Lines mapping:
|
||||||
|
22 <-> 6
|
||||||
|
23 <-> 6
|
||||||
|
24 <-> 5
|
||||||
|
26 <-> 6
|
||||||
|
27 <-> 7
|
||||||
|
Not mapped:
|
||||||
|
25
|
||||||
27
testData/results/TestPop2OneLongPop2.dec
Normal file
27
testData/results/TestPop2OneLongPop2.dec
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package pkg;
|
||||||
|
|
||||||
|
public class TestPop2OneLongPop2 {
|
||||||
|
public static void main(String... var0) {
|
||||||
|
long var10002 = -889275714L;// 24
|
||||||
|
System.out.println(1234567890);// 22 23 26
|
||||||
|
}// 27
|
||||||
|
}
|
||||||
|
|
||||||
|
class 'pkg/TestPop2OneLongPop2' {
|
||||||
|
method 'main ([Ljava/lang/String;)V' {
|
||||||
|
0 5
|
||||||
|
3 5
|
||||||
|
5 4
|
||||||
|
9 5
|
||||||
|
c 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Lines mapping:
|
||||||
|
22 <-> 6
|
||||||
|
23 <-> 6
|
||||||
|
24 <-> 5
|
||||||
|
26 <-> 6
|
||||||
|
27 <-> 7
|
||||||
|
Not mapped:
|
||||||
|
25
|
||||||
30
testData/results/TestPop2TwoIntPop2.dec
Normal file
30
testData/results/TestPop2TwoIntPop2.dec
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package pkg;
|
||||||
|
|
||||||
|
public class TestPop2TwoIntPop2 {
|
||||||
|
public static void main(String... var0) {
|
||||||
|
char var10002 = '쫾';// 24
|
||||||
|
char var10003 = '몾';// 25
|
||||||
|
System.out.println(1234567890);// 22 23 27
|
||||||
|
}// 28
|
||||||
|
}
|
||||||
|
|
||||||
|
class 'pkg/TestPop2TwoIntPop2' {
|
||||||
|
method 'main ([Ljava/lang/String;)V' {
|
||||||
|
0 6
|
||||||
|
3 6
|
||||||
|
5 4
|
||||||
|
7 5
|
||||||
|
a 6
|
||||||
|
d 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Lines mapping:
|
||||||
|
22 <-> 7
|
||||||
|
23 <-> 7
|
||||||
|
24 <-> 5
|
||||||
|
25 <-> 6
|
||||||
|
27 <-> 7
|
||||||
|
28 <-> 8
|
||||||
|
Not mapped:
|
||||||
|
26
|
||||||
31
testData/results/TestPop2TwoIntTwoPop.dec
Normal file
31
testData/results/TestPop2TwoIntTwoPop.dec
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package pkg;
|
||||||
|
|
||||||
|
public class TestPop2TwoIntTwoPop {
|
||||||
|
public static void main(String... var0) {
|
||||||
|
char var10002 = '쫾';// 24
|
||||||
|
char var10003 = '몾';// 25
|
||||||
|
System.out.println(1234567890);// 22 23 28
|
||||||
|
}// 29
|
||||||
|
}
|
||||||
|
|
||||||
|
class 'pkg/TestPop2TwoIntTwoPop' {
|
||||||
|
method 'main ([Ljava/lang/String;)V' {
|
||||||
|
0 6
|
||||||
|
3 6
|
||||||
|
5 4
|
||||||
|
7 5
|
||||||
|
b 6
|
||||||
|
e 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Lines mapping:
|
||||||
|
22 <-> 7
|
||||||
|
23 <-> 7
|
||||||
|
24 <-> 5
|
||||||
|
25 <-> 6
|
||||||
|
28 <-> 7
|
||||||
|
29 <-> 8
|
||||||
|
Not mapped:
|
||||||
|
26
|
||||||
|
27
|
||||||
30
testData/src/pkg/TestPop2OneDoublePop2.jasm
Normal file
30
testData/src/pkg/TestPop2OneDoublePop2.jasm
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* This code can be assembled with <a href="https://wiki.openjdk.java.net/display/CodeTools/asmtools">asmtools</a>
|
||||||
|
* using <code>asmtools jasm -g *.jasm</code> command line.
|
||||||
|
*/
|
||||||
|
package pkg;
|
||||||
|
|
||||||
|
super public class TestPop2OneDoublePop2
|
||||||
|
version 52:0
|
||||||
|
{
|
||||||
|
|
||||||
|
public Method "<init>":"()V"
|
||||||
|
stack 1 locals 1
|
||||||
|
{
|
||||||
|
aload_0;
|
||||||
|
invokespecial Method java/lang/Object."<init>":"()V";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static varargs Method main:"([Ljava/lang/String;)V"
|
||||||
|
stack 4 locals 1
|
||||||
|
{
|
||||||
|
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
|
||||||
|
ldc int 1234567890;
|
||||||
|
ldc2_w double 3.14159265358D;
|
||||||
|
pop2;
|
||||||
|
invokevirtual Method java/io/PrintStream.println:"(I)V";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end Class TestPop2OneDoublePop2
|
||||||
30
testData/src/pkg/TestPop2OneLongPop2.jasm
Normal file
30
testData/src/pkg/TestPop2OneLongPop2.jasm
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* This code can be assembled with <a href="https://wiki.openjdk.java.net/display/CodeTools/asmtools">asmtools</a>
|
||||||
|
* using <code>asmtools jasm -g *.jasm</code> command line.
|
||||||
|
*/
|
||||||
|
package pkg;
|
||||||
|
|
||||||
|
super public class TestPop2OneLongPop2
|
||||||
|
version 52:0
|
||||||
|
{
|
||||||
|
|
||||||
|
public Method "<init>":"()V"
|
||||||
|
stack 1 locals 1
|
||||||
|
{
|
||||||
|
aload_0;
|
||||||
|
invokespecial Method java/lang/Object."<init>":"()V";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static varargs Method main:"([Ljava/lang/String;)V"
|
||||||
|
stack 4 locals 1
|
||||||
|
{
|
||||||
|
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
|
||||||
|
ldc int 1234567890;
|
||||||
|
ldc2_w long 0xCAFEBABE;
|
||||||
|
pop2;
|
||||||
|
invokevirtual Method java/io/PrintStream.println:"(I)V";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end Class TestPop2OneLongPop2
|
||||||
31
testData/src/pkg/TestPop2TwoIntPop2.jasm
Normal file
31
testData/src/pkg/TestPop2TwoIntPop2.jasm
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* This code can be assembled with <a href="https://wiki.openjdk.java.net/display/CodeTools/asmtools">asmtools</a>
|
||||||
|
* using <code>asmtools jasm -g *.jasm</code> command line.
|
||||||
|
*/
|
||||||
|
package pkg;
|
||||||
|
|
||||||
|
super public class TestPop2TwoIntPop2
|
||||||
|
version 52:0
|
||||||
|
{
|
||||||
|
|
||||||
|
public Method "<init>":"()V"
|
||||||
|
stack 1 locals 1
|
||||||
|
{
|
||||||
|
aload_0;
|
||||||
|
invokespecial Method java/lang/Object."<init>":"()V";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static varargs Method main:"([Ljava/lang/String;)V"
|
||||||
|
stack 4 locals 1
|
||||||
|
{
|
||||||
|
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
|
||||||
|
ldc int 1234567890;
|
||||||
|
ldc int 0xCAFE;
|
||||||
|
ldc int 0xBABE;
|
||||||
|
pop2;
|
||||||
|
invokevirtual Method java/io/PrintStream.println:"(I)V";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end Class TestPop2TwoIntPop2
|
||||||
32
testData/src/pkg/TestPop2TwoIntTwoPop.jasm
Normal file
32
testData/src/pkg/TestPop2TwoIntTwoPop.jasm
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* This code can be assembled with <a href="https://wiki.openjdk.java.net/display/CodeTools/asmtools">asmtools</a>
|
||||||
|
* using <code>asmtools jasm -g *.jasm</code> command line.
|
||||||
|
*/
|
||||||
|
package pkg;
|
||||||
|
|
||||||
|
super public class TestPop2TwoIntTwoPop
|
||||||
|
version 52:0
|
||||||
|
{
|
||||||
|
|
||||||
|
public Method "<init>":"()V"
|
||||||
|
stack 1 locals 1
|
||||||
|
{
|
||||||
|
aload_0;
|
||||||
|
invokespecial Method java/lang/Object."<init>":"()V";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static varargs Method main:"([Ljava/lang/String;)V"
|
||||||
|
stack 4 locals 1
|
||||||
|
{
|
||||||
|
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
|
||||||
|
ldc int 1234567890;
|
||||||
|
ldc int 0xCAFE;
|
||||||
|
ldc int 0xBABE;
|
||||||
|
pop;
|
||||||
|
pop;
|
||||||
|
invokevirtual Method java/io/PrintStream.println:"(I)V";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end Class TestPop2TwoIntTwoPop
|
||||||
Reference in New Issue
Block a user