From 7f910289b51191deeb2a0aadc5e20a96cc12b725 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:49:40 -0500 Subject: [PATCH] Add test for Expression Optimization Issue --- .../java/decompiler/SingleClassesTest.java | 2 + testData/results/pkg/TestLVTReassignment.dec | 50 +++++++++++++++++++ .../src/java8/pkg/TestLVTReassignment.java | 17 +++++++ 3 files changed, 69 insertions(+) create mode 100644 testData/results/pkg/TestLVTReassignment.dec create mode 100644 testData/src/java8/pkg/TestLVTReassignment.java diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java index 2efcad46b..75b0ca697 100644 --- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -711,6 +711,8 @@ private void registerDefault() { // TODO: broken stack processing, deleted ternary! register(JAVA_17, "TestPatternMatchingLoops"); register(JAVA_8, "TestBoxingSuperclass"); + // TODO: shouldBeOne is completely deleted + register(JAVA_8, "TestLVTReassignment"); } private void registerEntireClassPath() { diff --git a/testData/results/pkg/TestLVTReassignment.dec b/testData/results/pkg/TestLVTReassignment.dec new file mode 100644 index 000000000..5682c6642 --- /dev/null +++ b/testData/results/pkg/TestLVTReassignment.dec @@ -0,0 +1,50 @@ +package pkg; + +public class TestLVTReassignment { + public void test() { + double one = 1.0;// 5 + one = 0.0;// 7 + if (one > 1.0) {// 8 + } + + this.blackhole(one);// 6 11 + }// 12 + + void blackhole(double value) { + }// 16 +} + +class 'pkg/TestLVTReassignment' { + method 'test ()V' { + 0 4 + 1 4 + 2 9 + 4 5 + 5 5 + 6 6 + 7 6 + 8 6 + 9 6 + a 6 + b 6 + c 9 + d 9 + e 9 + f 9 + 10 9 + 11 10 + } + + method 'blackhole (D)V' { + 0 13 + } +} + +Lines mapping: +5 <-> 5 +6 <-> 10 +7 <-> 6 +8 <-> 7 +11 <-> 10 +12 <-> 11 +16 <-> 14 diff --git a/testData/src/java8/pkg/TestLVTReassignment.java b/testData/src/java8/pkg/TestLVTReassignment.java new file mode 100644 index 000000000..9623b090d --- /dev/null +++ b/testData/src/java8/pkg/TestLVTReassignment.java @@ -0,0 +1,17 @@ +package pkg; + +public class TestLVTReassignment { + public void test() { + double one = 1; + double shouldBeOne = one; + one = 0; + if (one > 1) { + } + + blackhole(shouldBeOne); + } + + void blackhole(double value) { + + } +}