diff --git a/src/org/jetbrains/java/decompiler/code/CodeConstants.java b/src/org/jetbrains/java/decompiler/code/CodeConstants.java index a8f9f36..720d2a7 100644 --- a/src/org/jetbrains/java/decompiler/code/CodeConstants.java +++ b/src/org/jetbrains/java/decompiler/code/CodeConstants.java @@ -1,6 +1,4 @@ -/* - * Copyright 2000-2018 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-2019 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. package org.jetbrains.java.decompiler.code; @SuppressWarnings({"unused", "SpellCheckingInspection"}) @@ -9,12 +7,16 @@ public interface CodeConstants { // BYTECODE VERSIONS // ---------------------------------------------------------------------- - int BYTECODE_JAVA_LE_4 = 1; - int BYTECODE_JAVA_5 = 2; - int BYTECODE_JAVA_6 = 3; - int BYTECODE_JAVA_7 = 4; - int BYTECODE_JAVA_8 = 5; - int BYTECODE_JAVA_9 = 6; + int BYTECODE_JAVA_LE_4 = 48; + int BYTECODE_JAVA_5 = 49; + int BYTECODE_JAVA_6 = 50; + int BYTECODE_JAVA_7 = 51; + int BYTECODE_JAVA_8 = 52; + int BYTECODE_JAVA_9 = 53; + int BYTECODE_JAVA_10 = 54; + int BYTECODE_JAVA_11 = 55; + int BYTECODE_JAVA_12 = 56; + int BYTECODE_JAVA_13 = 57; // ---------------------------------------------------------------------- // VARIABLE TYPES diff --git a/src/org/jetbrains/java/decompiler/struct/StructClass.java b/src/org/jetbrains/java/decompiler/struct/StructClass.java index 5815c89..02bb74a 100644 --- a/src/org/jetbrains/java/decompiler/struct/StructClass.java +++ b/src/org/jetbrains/java/decompiler/struct/StructClass.java @@ -1,4 +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-2019 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. package org.jetbrains.java.decompiler.struct; import org.jetbrains.java.decompiler.code.CodeConstants; @@ -157,28 +157,16 @@ public class StructClass extends StructMember { } public boolean isVersionGE_1_5() { - return (majorVersion > 48 || (majorVersion == 48 && minorVersion > 0)); // FIXME: check second condition + return (majorVersion > CodeConstants.BYTECODE_JAVA_LE_4 || + (majorVersion == CodeConstants.BYTECODE_JAVA_LE_4 && minorVersion > 0)); // FIXME: check second condition } public boolean isVersionGE_1_7() { - return (majorVersion >= 51); + return (majorVersion >= CodeConstants.BYTECODE_JAVA_7); } public int getBytecodeVersion() { - switch (majorVersion) { - case 53: - return CodeConstants.BYTECODE_JAVA_9; - case 52: - return CodeConstants.BYTECODE_JAVA_8; - case 51: - return CodeConstants.BYTECODE_JAVA_7; - case 50: - return CodeConstants.BYTECODE_JAVA_6; - case 49: - return CodeConstants.BYTECODE_JAVA_5; - } - - return CodeConstants.BYTECODE_JAVA_LE_4; + return majorVersion < CodeConstants.BYTECODE_JAVA_LE_4 ? CodeConstants.BYTECODE_JAVA_LE_4 : majorVersion; } @Override diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java index 927e10a..1d0dc62 100644 --- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package org.jetbrains.java.decompiler; import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler; @@ -74,6 +74,7 @@ public class SingleClassesTest { "pkg/TestShadowingSuperClass"); } @Test public void testStringConcat() { doTest("pkg/TestStringConcat"); } @Test public void testJava9StringConcat() { doTest("java9/TestJava9StringConcat"); } + @Test public void testJava11StringConcat() { doTest("java11/TestJava11StringConcat"); } @Test public void testMethodReferenceSameName() { doTest("pkg/TestMethodReferenceSameName"); } @Test public void testMethodReferenceLetterClass() { doTest("pkg/TestMethodReferenceLetterClass"); } @Test public void testConstructorReference() { doTest("pkg/TestConstructorReference"); } diff --git a/testData/classes/java11/TestJava11StringConcat.class b/testData/classes/java11/TestJava11StringConcat.class new file mode 100644 index 0000000..8ec1fbd Binary files /dev/null and b/testData/classes/java11/TestJava11StringConcat.class differ diff --git a/testData/results/TestJava11StringConcat.dec b/testData/results/TestJava11StringConcat.dec new file mode 100644 index 0000000..68ab9c2 --- /dev/null +++ b/testData/results/TestJava11StringConcat.dec @@ -0,0 +1,27 @@ +package java11; + +public class TestJava11StringConcat { + public String test1(String var1, int var2) { + return var1 + var2;// 20 + } + + public String test2(String var1, int var2, Object var3) { + return "(" + var1 + "-" + var2 + "---" + var3 + ")";// 24 + } +} + +class 'java11/TestJava11StringConcat' { + method 'test1 (Ljava/lang/String;I)Ljava/lang/String;' { + 2 4 + 7 4 + } + + method 'test2 (Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;' { + 3 8 + 8 8 + } +} + +Lines mapping: +20 <-> 5 +24 <-> 9 diff --git a/testData/src/java11/TestJava11StringConcat.java b/testData/src/java11/TestJava11StringConcat.java new file mode 100644 index 0000000..3f9e040 --- /dev/null +++ b/testData/src/java11/TestJava11StringConcat.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2014 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 java11; + +public class TestJava11StringConcat { + public String test1(String prefix, int a) { + return prefix + a; + } + + public String test2(String var, int b, Object c) { + return "(" + var + "-" + b + "---" + c + ")"; + } +} \ No newline at end of file