Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipe Mulet2005-11-25 17:47:41 +0000
committerPhilipe Mulet2005-11-25 17:47:41 +0000
commitc84496f37e5dff715764911530c1fceaa60b14ee (patch)
treefddac3ebb3c7a090682b9e99182a6947ea4f2034
parent26e0b0c271d5031424823a1070ef180ba24218bf (diff)
downloadeclipse.jdt.core-c84496f37e5dff715764911530c1fceaa60b14ee.tar.gz
eclipse.jdt.core-c84496f37e5dff715764911530c1fceaa60b14ee.tar.xz
eclipse.jdt.core-c84496f37e5dff715764911530c1fceaa60b14ee.zip
117451,117120
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java1166
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java686
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java62
-rw-r--r--org.eclipse.jdt.core/buildnotes_jdt-core.html6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java455
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java418
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java24
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java17
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java2
10 files changed, 2053 insertions, 786 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java
index 3ec01c183c..be5366857d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java
@@ -10,6 +10,13 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.jdt.core.ToolFactory;
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -414,6 +421,1165 @@ public void test017() {
},
"SUCCESS");
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120
+public void test018() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0++) || true) != ((true && true) && (!(false || true)))));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "true");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 3, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 getstatic X.f0 : float [26]\n" +
+ " 10 fconst_1\n" +
+ " 11 fadd\n" +
+ " 12 putstatic X.f0 : float [26]\n" +
+ " 15 iconst_1\n" +
+ " 16 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" +
+ " 19 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 16, line: 8]\n" +
+ " [pc: 19, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 20] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 20] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test019() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0++) || false) != true));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "false");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 5, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 lload_1 [l11]\n" +
+ " 8 l2f\n" +
+ " 9 getstatic X.f0 : float [26]\n" +
+ " 12 dup\n" +
+ " 13 fconst_1\n" +
+ " 14 fadd\n" +
+ " 15 putstatic X.f0 : float [26]\n" +
+ " 18 fcmpg\n" +
+ " 19 ifge 26\n" +
+ " 22 iconst_0\n" +
+ " 23 goto 27\n" +
+ " 26 iconst_1\n" +
+ " 27 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" +
+ " 30 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 27, line: 8]\n" +
+ " [pc: 30, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 31] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 31] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test020() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0) | true) != false));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "true");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 iconst_1\n" +
+ " 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" +
+ " 11 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 8, line: 8]\n" +
+ " [pc: 11, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 12] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test021() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0) && false) != true));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "true");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 iconst_1\n" +
+ " 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" +
+ " 11 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 8, line: 8]\n" +
+ " [pc: 11, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 12] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test022() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0) & false) != true));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "true");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 iconst_1\n" +
+ " 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" +
+ " 11 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 8, line: 8]\n" +
+ " [pc: 11, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 12] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120
+public void test023() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0++) || true) == ((true && true) && (!(false || true)))));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "false");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 3, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 getstatic X.f0 : float [26]\n" +
+ " 10 fconst_1\n" +
+ " 11 fadd\n" +
+ " 12 putstatic X.f0 : float [26]\n" +
+ " 15 iconst_0\n" +
+ " 16 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" +
+ " 19 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 16, line: 8]\n" +
+ " [pc: 19, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 20] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 20] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test024() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0++) || false) == true));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "true");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 5, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 lload_1 [l11]\n" +
+ " 8 l2f\n" +
+ " 9 getstatic X.f0 : float [26]\n" +
+ " 12 dup\n" +
+ " 13 fconst_1\n" +
+ " 14 fadd\n" +
+ " 15 putstatic X.f0 : float [26]\n" +
+ " 18 fcmpg\n" +
+ " 19 ifge 26\n" +
+ " 22 iconst_1\n" +
+ " 23 goto 27\n" +
+ " 26 iconst_0\n" +
+ " 27 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" +
+ " 30 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 27, line: 8]\n" +
+ " [pc: 30, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 31] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 31] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test025() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0) | true) == false));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "false");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 iconst_0\n" +
+ " 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" +
+ " 11 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 8, line: 8]\n" +
+ " [pc: 11, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 12] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test026() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0) && false) == true));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "false");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 iconst_0\n" +
+ " 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" +
+ " 11 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 8, line: 8]\n" +
+ " [pc: 11, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 12] local: l11 index: 1 type: long\n" +
+ "}";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test027() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0) & false) == true));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "false");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 iconst_0\n" +
+ " 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" +
+ " 11 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 8, line: 8]\n" +
+ " [pc: 11, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 12] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test028() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0) || true) == false));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "false");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 iconst_0\n" +
+ " 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" +
+ " 11 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 8, line: 8]\n" +
+ " [pc: 11, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 12] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test029() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " System.out.println(\n" +
+ " ((foo() || bar()) || true) && false); \n" +
+ " }\n" +
+ " static boolean foo(){ \n" +
+ " System.out.print(\"foo\");\n" +
+ " return false;\n" +
+ " }\n" +
+ " static boolean bar(){\n" +
+ " System.out.print(\"bar\");\n" +
+ " return true;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "foobarfalse");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 1\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 getstatic java.lang.System.out : java.io.PrintStream [18]\n" +
+ " 3 invokestatic X.foo() : boolean [24]\n" +
+ " 6 ifne 13\n" +
+ " 9 invokestatic X.bar() : boolean [28]\n" +
+ " 12 pop\n" +
+ " 13 iconst_0\n" +
+ " 14 invokevirtual java.io.PrintStream.println(boolean) : void [31]\n" +
+ " 17 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 3, line: 7]\n" +
+ " [pc: 14, line: 6]\n" +
+ " [pc: 17, line: 8]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 18] local: args index: 0 type: java.lang.String[]\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation
+public void test030() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static float f0;\n" +
+ " \n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " \n" +
+ " System.out.println(\n" +
+ " (((l11 < f0++) || true) == ((foo() || bar()) || true)));\n" +
+ " }\n" +
+ " static boolean foo() {\n" +
+ " System.out.print(\"foo\");\n" +
+ " return false;\n" +
+ " }\n" +
+ " static boolean bar() {\n" +
+ " System.out.print(\"bar\");\n" +
+ " return true;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "foobartrue");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 3, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 getstatic X.f0 : float [26]\n" +
+ " 10 fconst_1\n" +
+ " 11 fadd\n" +
+ " 12 putstatic X.f0 : float [26]\n" +
+ " 15 invokestatic X.foo() : boolean [28]\n" +
+ " 18 ifne 25\n" +
+ " 21 invokestatic X.bar() : boolean [32]\n" +
+ " 24 pop\n" +
+ " 25 iconst_1\n" +
+ " 26 invokevirtual java.io.PrintStream.println(boolean) : void [35]\n" +
+ " 29 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 8]\n" +
+ " [pc: 7, line: 9]\n" +
+ " [pc: 26, line: 8]\n" +
+ " [pc: 29, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 30] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 30] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117451
+public void test031() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public float f0;\n" +
+ "\n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " X x = new X();\n" +
+ " System.out.println(\n" +
+ " (((l11 < x.f0) || true) != false));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "true");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput = this.complianceLevel.equals(COMPLIANCE_1_3)
+ ? " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 4\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 new X [1]\n" +
+ " 7 dup\n" +
+ " 8 invokespecial X() [20]\n" +
+ " 11 astore_3 [x]\n" +
+ " 12 getstatic java.lang.System.out : java.io.PrintStream [21]\n" +
+ " 15 aload_3 [x]\n" +
+ " 16 invokevirtual java.lang.Object.getClass() : java.lang.Class [27]\n" +
+ " 19 pop\n" +
+ " 20 iconst_1\n" +
+ " 21 invokevirtual java.io.PrintStream.println(boolean) : void [31]\n" +
+ " 24 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 7]\n" +
+ " [pc: 12, line: 8]\n" +
+ " [pc: 15, line: 9]\n" +
+ " [pc: 21, line: 8]\n" +
+ " [pc: 24, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 25] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 25] local: l11 index: 1 type: long\n" +
+ " [pc: 12, pc: 25] local: x index: 3 type: X\n"
+
+ : " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 4\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 new X [1]\n" +
+ " 7 dup\n" +
+ " 8 invokespecial X() [20]\n" +
+ " 11 astore_3 [x]\n" +
+ " 12 getstatic java.lang.System.out : java.io.PrintStream [21]\n" +
+ " 15 aload_3 [x]\n" +
+ " 16 getfield X.f0 : float [27]\n" +
+ " 19 pop\n" +
+ " 20 iconst_1\n" +
+ " 21 invokevirtual java.io.PrintStream.println(boolean) : void [29]\n" +
+ " 24 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 7]\n" +
+ " [pc: 12, line: 8]\n" +
+ " [pc: 15, line: 9]\n" +
+ " [pc: 21, line: 8]\n" +
+ " [pc: 24, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 25] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 25] local: l11 index: 1 type: long\n" +
+ " [pc: 12, pc: 25] local: x index: 3 type: X\n";
+
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117451 - variation
+public void test032() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static float f0;\n" +
+ "\n" +
+ " public static void main(String[] args)\n" +
+ " {\n" +
+ " long l11 = -26;\n" +
+ " System.out.println(\n" +
+ " (((l11 < (f0=13)) || true) != false));\n" +
+ " }\n" +
+ "}\n",
+ },
+ "true");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 ldc2_w <Long -26> [18]\n" +
+ " 3 lstore_1 [l11]\n" +
+ " 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 7 ldc <Float 13.0> [26]\n" +
+ " 9 putstatic X.f0 : float [27]\n" +
+ " 12 iconst_1\n" +
+ " 13 invokevirtual java.io.PrintStream.println(boolean) : void [29]\n" +
+ " 16 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 4, line: 7]\n" +
+ " [pc: 7, line: 8]\n" +
+ " [pc: 13, line: 7]\n" +
+ " [pc: 16, line: 9]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 17] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 17] local: l11 index: 1 type: long\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+
+public void test033() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " boolean b = true;\n" +
+ " System.out.print(b ^ b);\n" +
+ " System.out.println(b ^ true);\n" +
+ " } \n" +
+ "}\n",
+ },
+ "falsefalse");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #15 ([Ljava/lang/String;)V\n" +
+ " // Stack: 3, Locals: 2\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 iconst_1\n" +
+ " 1 istore_1 [b]\n" +
+ " 2 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 5 iload_1 [b]\n" +
+ " 6 iload_1 [b]\n" +
+ " 7 ixor\n" +
+ " 8 invokevirtual java.io.PrintStream.print(boolean) : void [22]\n" +
+ " 11 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 14 iload_1 [b]\n" +
+ " 15 iconst_1\n" +
+ " 16 ixor\n" +
+ " 17 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" +
+ " 20 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 3]\n" +
+ " [pc: 2, line: 4]\n" +
+ " [pc: 11, line: 5]\n" +
+ " [pc: 20, line: 6]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 21] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 2, pc: 21] local: b index: 1 type: boolean\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+public void test034() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " boolean b = true;\n" +
+ " if ((b ^ true) || b) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " } \n" +
+ "}\n",
+ },
+ "SUCCESS");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #15 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 2\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 iconst_1\n" +
+ " 1 istore_1 [b]\n" +
+ " 2 iload_1 [b]\n" +
+ " 3 ifeq 10\n" +
+ " 6 iload_1 [b]\n" +
+ " 7 ifeq 18\n" +
+ " 10 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 13 ldc <String \"SUCCESS\"> [22]\n" +
+ " 15 invokevirtual java.io.PrintStream.println(java.lang.String) : void [24]\n" +
+ " 18 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 3]\n" +
+ " [pc: 2, line: 4]\n" +
+ " [pc: 10, line: 5]\n" +
+ " [pc: 18, line: 7]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 19] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 2, pc: 19] local: b index: 1 type: boolean\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117451 - variation
+public void test035() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static float f0;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println((X.f0 > 0 || true) == false);\n" +
+ " } \n" +
+ "}\n",
+ },
+ "false");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #17 ([Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 1\n" +
+ " public static void main(java.lang.String[] args);\n" +
+ " 0 getstatic java.lang.System.out : java.io.PrintStream [18]\n" +
+ " 3 iconst_0\n" +
+ " 4 invokevirtual java.io.PrintStream.println(boolean) : void [24]\n" +
+ " 7 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 4]\n" +
+ " [pc: 7, line: 5]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 8] local: args index: 0 type: java.lang.String[]\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117451 - variation
+public void test036() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " float f0;\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().foo();\n" +
+ " }\n" +
+ " void foo() {\n" +
+ " System.out.println((this.f0 > 0 || true) == false);\n" +
+ " } \n" +
+ "}\n",
+ },
+ "false");
+ // ensure optimized boolean codegen sequence
+ String expectedOutput =
+ " // Method descriptor #8 ()V\n" +
+ " // Stack: 2, Locals: 1\n" +
+ " void foo();\n" +
+ " 0 getstatic java.lang.System.out : java.io.PrintStream [24]\n" +
+ " 3 iconst_0\n" +
+ " 4 invokevirtual java.io.PrintStream.println(boolean) : void [30]\n" +
+ " 7 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 7]\n" +
+ " [pc: 7, line: 8]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 8] local: this index: 0 type: X\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+
public static Class testClass() {
return BooleanTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
index ff042cef3c..1580da86e7 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
@@ -19,8 +19,6 @@ import junit.framework.TestSuite;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class ConstantTest extends AbstractRegressionTest {
@@ -691,244 +689,110 @@ public void test014() {
"");
// ensure boolean codegen got optimized (optimizedBooleanConstant)
String expectedOutput =
- CompilerOptions.versionToJdkLevel(getCompilerOptions().get(CompilerOptions.OPTION_Compliance)) < ClassFileConstants.JDK1_4
- ? " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 2, Locals: 4\n" +
- " void foo1(X x);\n" +
- " 0 iconst_0\n" +
- " 1 dup\n" +
- " 2 istore_2 [bb]\n" +
- " 3 ifeq 8\n" +
- " 6 iconst_0\n" +
- " 7 istore_3\n" +
- " 8 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 9]\n" +
- " [pc: 6, line: 10]\n" +
- " [pc: 8, line: 12]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 9] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 9] local: x index: 1 type: X\n" +
- " [pc: 3, pc: 9] local: bb index: 2 type: boolean\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo2(X x);\n" +
- " 0 iconst_0\n" +
- " 1 ifeq 4\n" +
- " 4 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 14]\n" +
- " [pc: 4, line: 17]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo3(X x);\n" +
- " 0 iconst_0\n" +
- " 1 ifne 0\n" +
- " 4 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 19]\n" +
- " [pc: 4, line: 22]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 3\n" +
- " void foo4(X x);\n" +
- " 0 iconst_0\n" +
- " 1 istore_2 [b]\n" +
- " 2 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 24]\n" +
- " [pc: 2, line: 25]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 3] local: x index: 1 type: X\n" +
- " [pc: 2, pc: 3] local: b index: 2 type: boolean\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo5();\n" +
- " 0 aload_0 [this]\n" +
- " 1 pop\n" +
- " 2 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 27]\n" +
- " [pc: 2, line: 30]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo6();\n" +
- " 0 aload_0 [this]\n" +
- " 1 pop\n" +
- " 2 iconst_0\n" +
- " 3 ifeq 6\n" +
- " 6 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 32]\n" +
- " [pc: 6, line: 35]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 7] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo7();\n" +
- " 0 aload_0 [this]\n" +
- " 1 pop\n" +
- " 2 iconst_0\n" +
- " 3 ifne 0\n" +
- " 6 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 37]\n" +
- " [pc: 6, line: 40]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 7] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo8();\n" +
- " 0 aload_0 [this]\n" +
- " 1 pop\n" +
- " 2 aload_0 [this]\n" +
- " 3 pop\n" +
- " 4 iconst_0\n" +
- " 5 istore_1 [b]\n" +
- " 6 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 42]\n" +
- " [pc: 6, line: 43]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 7] local: this index: 0 type: X\n" +
- " [pc: 6, pc: 7] local: b index: 1 type: boolean\n" +
- "}"
- : " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 2, Locals: 4\n" +
- " void foo1(X x);\n" +
- " 0 iconst_0\n" +
- " 1 dup\n" +
- " 2 istore_2 [bb]\n" +
- " 3 ifeq 8\n" +
- " 6 iconst_0\n" +
- " 7 istore_3\n" +
- " 8 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 9]\n" +
- " [pc: 6, line: 10]\n" +
- " [pc: 8, line: 12]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 9] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 9] local: x index: 1 type: X\n" +
- " [pc: 3, pc: 9] local: bb index: 2 type: boolean\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo2(X x);\n" +
- " 0 iconst_0\n" +
- " 1 ifeq 4\n" +
- " 4 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 14]\n" +
- " [pc: 4, line: 17]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo3(X x);\n" +
- " 0 iconst_0\n" +
- " 1 ifne 0\n" +
- " 4 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 19]\n" +
- " [pc: 4, line: 22]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 3\n" +
- " void foo4(X x);\n" +
- " 0 iconst_0\n" +
- " 1 istore_2 [b]\n" +
- " 2 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 24]\n" +
- " [pc: 2, line: 25]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 3] local: x index: 1 type: X\n" +
- " [pc: 2, pc: 3] local: b index: 2 type: boolean\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo5();\n" +
- " 0 aload_0 [this]\n" +
- " 1 getfield X.fx : X [28]\n" +
- " 4 pop\n" +
- " 5 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 27]\n" +
- " [pc: 5, line: 30]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 6] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo6();\n" +
- " 0 aload_0 [this]\n" +
- " 1 getfield X.fx : X [28]\n" +
- " 4 pop\n" +
- " 5 iconst_0\n" +
- " 6 ifeq 9\n" +
- " 9 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 32]\n" +
- " [pc: 9, line: 35]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 10] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo7();\n" +
- " 0 aload_0 [this]\n" +
- " 1 getfield X.fx : X [28]\n" +
- " 4 pop\n" +
- " 5 iconst_0\n" +
- " 6 ifne 0\n" +
- " 9 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 37]\n" +
- " [pc: 9, line: 40]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 10] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo8();\n" +
- " 0 aload_0 [this]\n" +
- " 1 getfield X.fx : X [28]\n" +
- " 4 pop\n" +
- " 5 aload_0 [this]\n" +
- " 6 getfield X.fx : X [28]\n" +
- " 9 pop\n" +
- " 10 iconst_0\n" +
- " 11 istore_1 [b]\n" +
- " 12 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 42]\n" +
- " [pc: 12, line: 43]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 13] local: this index: 0 type: X\n" +
- " [pc: 12, pc: 13] local: b index: 1 type: boolean\n" +
- "}";
+ " // Method descriptor #20 (LX;)V\n" +
+ " // Stack: 2, Locals: 4\n" +
+ " void foo1(X x);\n" +
+ " 0 iconst_0\n" +
+ " 1 dup\n" +
+ " 2 istore_2 [bb]\n" +
+ " 3 ifeq 8\n" +
+ " 6 iconst_0\n" +
+ " 7 istore_3\n" +
+ " 8 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 9]\n" +
+ " [pc: 6, line: 10]\n" +
+ " [pc: 8, line: 12]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 9] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 9] local: x index: 1 type: X\n" +
+ " [pc: 3, pc: 9] local: bb index: 2 type: boolean\n" +
+ " \n" +
+ " // Method descriptor #20 (LX;)V\n" +
+ " // Stack: 1, Locals: 2\n" +
+ " void foo2(X x);\n" +
+ " 0 iconst_0\n" +
+ " 1 ifeq 4\n" +
+ " 4 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 14]\n" +
+ " [pc: 4, line: 17]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
+ " \n" +
+ " // Method descriptor #20 (LX;)V\n" +
+ " // Stack: 1, Locals: 2\n" +
+ " void foo3(X x);\n" +
+ " 0 iconst_0\n" +
+ " 1 ifne 0\n" +
+ " 4 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 19]\n" +
+ " [pc: 4, line: 22]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
+ " \n" +
+ " // Method descriptor #20 (LX;)V\n" +
+ " // Stack: 1, Locals: 3\n" +
+ " void foo4(X x);\n" +
+ " 0 iconst_0\n" +
+ " 1 istore_2 [b]\n" +
+ " 2 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 24]\n" +
+ " [pc: 2, line: 25]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 3] local: x index: 1 type: X\n" +
+ " [pc: 2, pc: 3] local: b index: 2 type: boolean\n" +
+ " \n" +
+ " // Method descriptor #12 ()V\n" +
+ " // Stack: 0, Locals: 1\n" +
+ " void foo5();\n" +
+ " 0 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 30]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 1] local: this index: 0 type: X\n" +
+ " \n" +
+ " // Method descriptor #12 ()V\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " void foo6();\n" +
+ " 0 iconst_0\n" +
+ " 1 ifeq 4\n" +
+ " 4 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 32]\n" +
+ " [pc: 4, line: 35]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
+ " \n" +
+ " // Method descriptor #12 ()V\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " void foo7();\n" +
+ " 0 iconst_0\n" +
+ " 1 ifne 0\n" +
+ " 4 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 37]\n" +
+ " [pc: 4, line: 40]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
+ " \n" +
+ " // Method descriptor #12 ()V\n" +
+ " // Stack: 1, Locals: 2\n" +
+ " void foo8();\n" +
+ " 0 iconst_0\n" +
+ " 1 istore_1 [b]\n" +
+ " 2 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 42]\n" +
+ " [pc: 2, line: 43]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
+ " [pc: 2, pc: 3] local: b index: 1 type: boolean\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -1002,244 +866,110 @@ public void test015() {
"");
// ensure boolean codegen got optimized (optimizedBooleanConstant)
String expectedOutput =
- CompilerOptions.versionToJdkLevel(getCompilerOptions().get(CompilerOptions.OPTION_Compliance)) < ClassFileConstants.JDK1_4
- ? " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 2, Locals: 4\n" +
- " void foo1(X x);\n" +
- " 0 iconst_0\n" +
- " 1 dup\n" +
- " 2 istore_2 [bb]\n" +
- " 3 ifeq 8\n" +
- " 6 iconst_0\n" +
- " 7 istore_3\n" +
- " 8 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 9]\n" +
- " [pc: 6, line: 10]\n" +
- " [pc: 8, line: 12]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 9] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 9] local: x index: 1 type: X\n" +
- " [pc: 3, pc: 9] local: bb index: 2 type: boolean\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo2(X x);\n" +
- " 0 iconst_0\n" +
- " 1 ifeq 4\n" +
- " 4 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 14]\n" +
- " [pc: 4, line: 17]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo3(X x);\n" +
- " 0 iconst_0\n" +
- " 1 ifne 0\n" +
- " 4 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 19]\n" +
- " [pc: 4, line: 22]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 3\n" +
- " void foo4(X x);\n" +
- " 0 iconst_0\n" +
- " 1 istore_2 [b]\n" +
- " 2 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 24]\n" +
- " [pc: 2, line: 25]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 3] local: x index: 1 type: X\n" +
- " [pc: 2, pc: 3] local: b index: 2 type: boolean\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo5();\n" +
- " 0 aload_0 [this]\n" +
- " 1 pop\n" +
- " 2 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 27]\n" +
- " [pc: 2, line: 30]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo6();\n" +
- " 0 aload_0 [this]\n" +
- " 1 pop\n" +
- " 2 iconst_0\n" +
- " 3 ifeq 6\n" +
- " 6 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 32]\n" +
- " [pc: 6, line: 35]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 7] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo7();\n" +
- " 0 aload_0 [this]\n" +
- " 1 pop\n" +
- " 2 iconst_0\n" +
- " 3 ifne 0\n" +
- " 6 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 37]\n" +
- " [pc: 6, line: 40]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 7] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo8();\n" +
- " 0 aload_0 [this]\n" +
- " 1 pop\n" +
- " 2 aload_0 [this]\n" +
- " 3 pop\n" +
- " 4 iconst_0\n" +
- " 5 istore_1 [b]\n" +
- " 6 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 42]\n" +
- " [pc: 6, line: 43]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 7] local: this index: 0 type: X\n" +
- " [pc: 6, pc: 7] local: b index: 1 type: boolean\n" +
- "}"
- : " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 2, Locals: 4\n" +
- " void foo1(X x);\n" +
- " 0 iconst_0\n" +
- " 1 dup\n" +
- " 2 istore_2 [bb]\n" +
- " 3 ifeq 8\n" +
- " 6 iconst_0\n" +
- " 7 istore_3\n" +
- " 8 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 9]\n" +
- " [pc: 6, line: 10]\n" +
- " [pc: 8, line: 12]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 9] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 9] local: x index: 1 type: X\n" +
- " [pc: 3, pc: 9] local: bb index: 2 type: boolean\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo2(X x);\n" +
- " 0 iconst_0\n" +
- " 1 ifeq 4\n" +
- " 4 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 14]\n" +
- " [pc: 4, line: 17]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo3(X x);\n" +
- " 0 iconst_0\n" +
- " 1 ifne 0\n" +
- " 4 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 19]\n" +
- " [pc: 4, line: 22]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
- " \n" +
- " // Method descriptor #20 (LX;)V\n" +
- " // Stack: 1, Locals: 3\n" +
- " void foo4(X x);\n" +
- " 0 iconst_0\n" +
- " 1 istore_2 [b]\n" +
- " 2 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 24]\n" +
- " [pc: 2, line: 25]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
- " [pc: 0, pc: 3] local: x index: 1 type: X\n" +
- " [pc: 2, pc: 3] local: b index: 2 type: boolean\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo5();\n" +
- " 0 aload_0 [this]\n" +
- " 1 getfield X.fx : X [28]\n" +
- " 4 pop\n" +
- " 5 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 27]\n" +
- " [pc: 5, line: 30]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 6] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo6();\n" +
- " 0 aload_0 [this]\n" +
- " 1 getfield X.fx : X [28]\n" +
- " 4 pop\n" +
- " 5 iconst_0\n" +
- " 6 ifeq 9\n" +
- " 9 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 32]\n" +
- " [pc: 9, line: 35]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 10] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 1\n" +
- " void foo7();\n" +
- " 0 aload_0 [this]\n" +
- " 1 getfield X.fx : X [28]\n" +
- " 4 pop\n" +
- " 5 iconst_0\n" +
- " 6 ifne 0\n" +
- " 9 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 37]\n" +
- " [pc: 9, line: 40]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 10] local: this index: 0 type: X\n" +
- " \n" +
- " // Method descriptor #12 ()V\n" +
- " // Stack: 1, Locals: 2\n" +
- " void foo8();\n" +
- " 0 aload_0 [this]\n" +
- " 1 getfield X.fx : X [28]\n" +
- " 4 pop\n" +
- " 5 aload_0 [this]\n" +
- " 6 getfield X.fx : X [28]\n" +
- " 9 pop\n" +
- " 10 iconst_0\n" +
- " 11 istore_1 [b]\n" +
- " 12 return\n" +
- " Line numbers:\n" +
- " [pc: 0, line: 42]\n" +
- " [pc: 12, line: 43]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 13] local: this index: 0 type: X\n" +
- " [pc: 12, pc: 13] local: b index: 1 type: boolean\n" +
- "}";
+ " // Method descriptor #20 (LX;)V\n" +
+ " // Stack: 2, Locals: 4\n" +
+ " void foo1(X x);\n" +
+ " 0 iconst_0\n" +
+ " 1 dup\n" +
+ " 2 istore_2 [bb]\n" +
+ " 3 ifeq 8\n" +
+ " 6 iconst_0\n" +
+ " 7 istore_3\n" +
+ " 8 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 9]\n" +
+ " [pc: 6, line: 10]\n" +
+ " [pc: 8, line: 12]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 9] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 9] local: x index: 1 type: X\n" +
+ " [pc: 3, pc: 9] local: bb index: 2 type: boolean\n" +
+ " \n" +
+ " // Method descriptor #20 (LX;)V\n" +
+ " // Stack: 1, Locals: 2\n" +
+ " void foo2(X x);\n" +
+ " 0 iconst_0\n" +
+ " 1 ifeq 4\n" +
+ " 4 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 14]\n" +
+ " [pc: 4, line: 17]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
+ " \n" +
+ " // Method descriptor #20 (LX;)V\n" +
+ " // Stack: 1, Locals: 2\n" +
+ " void foo3(X x);\n" +
+ " 0 iconst_0\n" +
+ " 1 ifne 0\n" +
+ " 4 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 19]\n" +
+ " [pc: 4, line: 22]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 5] local: x index: 1 type: X\n" +
+ " \n" +
+ " // Method descriptor #20 (LX;)V\n" +
+ " // Stack: 1, Locals: 3\n" +
+ " void foo4(X x);\n" +
+ " 0 iconst_0\n" +
+ " 1 istore_2 [b]\n" +
+ " 2 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 24]\n" +
+ " [pc: 2, line: 25]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 3] local: x index: 1 type: X\n" +
+ " [pc: 2, pc: 3] local: b index: 2 type: boolean\n" +
+ " \n" +
+ " // Method descriptor #12 ()V\n" +
+ " // Stack: 0, Locals: 1\n" +
+ " void foo5();\n" +
+ " 0 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 30]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 1] local: this index: 0 type: X\n" +
+ " \n" +
+ " // Method descriptor #12 ()V\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " void foo6();\n" +
+ " 0 iconst_0\n" +
+ " 1 ifeq 4\n" +
+ " 4 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 32]\n" +
+ " [pc: 4, line: 35]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
+ " \n" +
+ " // Method descriptor #12 ()V\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " void foo7();\n" +
+ " 0 iconst_0\n" +
+ " 1 ifne 0\n" +
+ " 4 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 37]\n" +
+ " [pc: 4, line: 40]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: X\n" +
+ " \n" +
+ " // Method descriptor #12 ()V\n" +
+ " // Stack: 1, Locals: 2\n" +
+ " void foo8();\n" +
+ " 0 iconst_0\n" +
+ " 1 istore_1 [b]\n" +
+ " 2 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 42]\n" +
+ " [pc: 2, line: 43]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 3] local: this index: 0 type: X\n" +
+ " [pc: 2, pc: 3] local: b index: 1 type: boolean\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 380fc14a6d..2840162df7 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -14781,22 +14781,22 @@ public void test500(){
this.runConformTest(
new String[] {
"X.java",
- "class XA {}\n" +
- "interface XB {\n" +
- " XB CONST = new XB(){ public String toString() { return \"SUCCESS\"; }};\n" +
- "}\n" +
- "class XAB extends XA implements XB {}\n" +
- "\n" +
- "public class X <E extends XA&XB> {\n" +
- " E e;\n" +
- " public static void main(String[] args) {\n" +
- " System.out.print(new X<XAB>().e.CONST);\n" +
- " new X<XAB>().foo();\n" +
- " }\n" +
- " public void foo() {\n" +
- " System.out.print(this.e.CONST);\n" +
- " }\n" +
- "}\n",
+ "class XA {}\n" +
+ "interface XB {\n" +
+ " XB CONST = new XB(){ public String toString() { return \"SUCCESS\"; }};\n" +
+ "}\n" +
+ "class XAB extends XA implements XB {}\n" +
+ "\n" +
+ "public class X <E extends XA&XB> {\n" +
+ " E e;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(new X<XAB>().e.CONST);\n" +
+ " new X<XAB>().foo();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " System.out.print(this.e.CONST);\n" +
+ " }\n" +
+ "}\n",
},
"SUCCESSSUCCESS");
String expectedOutput =
@@ -14848,19 +14848,16 @@ public void test500(){
" // Stack: 2, Locals: 1\n" +
" public void foo();\n" +
" 0 getstatic java.lang.System.out : java.io.PrintStream [22]\n" +
- " 3 aload_0 [this]\n" +
- " 4 getfield X.e : XA [29]\n" +
- " 7 pop\n" +
- " 8 getstatic XB.CONST : XB [48]\n" +
- " 11 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [37]\n" +
- " 14 return\n" +
+ " 3 getstatic XB.CONST : XB [48]\n" +
+ " 6 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [37]\n" +
+ " 9 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 14]\n" +
- " [pc: 14, line: 15]\n" +
+ " [pc: 9, line: 15]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 15] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 10] local: this index: 0 type: X\n" +
" Local variable type table:\n" +
- " [pc: 0, pc: 15] local: this index: 0 type: X<E>\n" +
+ " [pc: 0, pc: 10] local: this index: 0 type: X<E>\n" +
"}";
try {
@@ -15067,21 +15064,18 @@ public void test500(){
" 5 invokespecial X$1(X) [30]\n" +
" 8 invokevirtual X$1.run() : void [33]\n" +
" 11 getstatic java.lang.System.out : java.io.PrintStream [36]\n" +
- " 14 aload_0 [this]\n" +
- " 15 getfield X.e : XA [42]\n" +
- " 18 pop\n" +
- " 19 getstatic XB.CONST : XB [44]\n" +
- " 22 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [50]\n" +
- " 25 return\n" +
+ " 14 getstatic XB.CONST : XB [42]\n" +
+ " 17 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [48]\n" +
+ " 20 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 13]\n" +
" [pc: 8, line: 17]\n" +
" [pc: 11, line: 18]\n" +
- " [pc: 25, line: 19]\n" +
+ " [pc: 20, line: 19]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 26] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 21] local: this index: 0 type: X\n" +
" Local variable type table:\n" +
- " [pc: 0, pc: 26] local: this index: 0 type: X<E>\n" +
+ " [pc: 0, pc: 21] local: this index: 0 type: X<E>\n" +
"\n" +
" Inner classes:\n" +
" [inner class info: #28 X$1, outer class info: #0\n" +
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 74ad7e8266..2215c64f4c 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -102,7 +102,11 @@ searching for type references (see bug <a href="http://bugs.eclipse.org/bugs/sho
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=36032">36032</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=117451">117451</a>
+[compiler] Codegen could better optimize field access when value not required
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=117120">117120</a>
+[compiler] VerifyError: Expecting to find integer on stack
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=36032">36032</a>
[plan] JavaProject.findType() fails to find second type in source file
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=117183">117183</a>
[javadoc][assist] No completion in text when cursor location is followed by a '.'
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index c82b7d56e8..1289c09417 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -25,7 +25,7 @@ public abstract class ASTNode implements BaseTypes, TypeConstants, TypeIds {
public final static int Bit3 = 0x4; // return type (operator) | name reference kind (name ref) | implicit this (this ref)
public final static int Bit4 = 0x8; // return type (operator) | first assignment to local (local decl) | undocumented empty block (block, type and method decl)
public final static int Bit5 = 0x10; // value for return (expression) | has all method bodies (unit) | supertype ref (type ref)
- public final static int Bit6 = 0x20; // depth (name ref, msg) | only value required (binary expression) | ignore need cast check (cast expression)
+ public final static int Bit6 = 0x20; // depth (name ref, msg) | ignore need cast check (cast expression)
public final static int Bit7 = 0x40; // depth (name ref, msg) | operator (operator) | need runtime checkcast (cast expression) | label used (labelStatement)
public final static int Bit8 = 0x80; // depth (name ref, msg) | operator (operator) | unsafe cast (cast expression)
public final static int Bit9 = 0x100; // depth (name ref, msg) | operator (operator) | is local type (type decl)
@@ -88,7 +88,6 @@ public abstract class ASTNode implements BaseTypes, TypeConstants, TypeIds {
// for binary expressions
public static final int IsReturnedValue = Bit5;
- public static final int OnlyValueRequired = Bit6;
// for cast expressions
public static final int UnnecessaryCast = Bit15;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
index 99e5a4bfc7..8b0ea975b3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
@@ -86,14 +86,12 @@ public class BinaryExpression extends OperatorExpression {
boolean valueRequired) {
int pc = codeStream.position;
- Label falseLabel, endLabel;
if (constant != Constant.NotAConstant) {
if (valueRequired)
codeStream.generateConstant(constant, implicitConversion);
codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
- bits |= OnlyValueRequired;
switch ((bits & OperatorMASK) >> OperatorSHIFT) {
case PLUS :
switch (bits & ReturnTypeIDMASK) {
@@ -295,33 +293,8 @@ public class BinaryExpression extends OperatorExpression {
}
break;
case T_boolean : // logical and
- generateOptimizedLogicalAnd(
- currentScope,
- codeStream,
- null,
- (falseLabel = new Label(codeStream)),
- valueRequired);
- /* improving code gen for such a case: boolean b = i < 0 && false;
- * since the label has never been used, we have the inlined value on the stack. */
- if (falseLabel.hasForwardReferences()) {
- if (valueRequired) {
- codeStream.iconst_1();
- if ((bits & IsReturnedValue) != 0) {
- codeStream.generateImplicitConversion(this.implicitConversion);
- codeStream.generateReturnBytecode(this);
- falseLabel.place();
- codeStream.iconst_0();
- } else {
- codeStream.goto_(endLabel = new Label(codeStream));
- codeStream.decrStackSize(1);
- falseLabel.place();
- codeStream.iconst_0();
- endLabel.place();
- }
- } else {
- falseLabel.place();
- }
- }
+ generateLogicalAnd(currentScope, codeStream, valueRequired);
+ break;
}
break;
case OR :
@@ -367,33 +340,8 @@ public class BinaryExpression extends OperatorExpression {
}
break;
case T_boolean : // logical or
- generateOptimizedLogicalOr(
- currentScope,
- codeStream,
- null,
- (falseLabel = new Label(codeStream)),
- valueRequired);
- /* improving code gen for such a case: boolean b = i < 0 || true;
- * since the label has never been used, we have the inlined value on the stack. */
- if (falseLabel.hasForwardReferences()) {
- if (valueRequired) {
- codeStream.iconst_1();
- if ((bits & IsReturnedValue) != 0) {
- codeStream.generateImplicitConversion(this.implicitConversion);
- codeStream.generateReturnBytecode(this);
- falseLabel.place();
- codeStream.iconst_0();
- } else {
- codeStream.goto_(endLabel = new Label(codeStream));
- codeStream.decrStackSize(1);
- falseLabel.place();
- codeStream.iconst_0();
- endLabel.place();
- }
- } else {
- falseLabel.place();
- }
- }
+ generateLogicalOr(currentScope, codeStream, valueRequired);
+ break;
}
break;
case XOR :
@@ -439,33 +387,8 @@ public class BinaryExpression extends OperatorExpression {
}
break;
case T_boolean :
- generateOptimizedLogicalXor(
- currentScope,
- codeStream,
- null,
- (falseLabel = new Label(codeStream)),
- valueRequired);
- /* improving code gen for such a case: boolean b = i < 0 ^ bool;
- * since the label has never been used, we have the inlined value on the stack. */
- if (falseLabel.hasForwardReferences()) {
- if (valueRequired) {
- codeStream.iconst_1();
- if ((bits & IsReturnedValue) != 0) {
- codeStream.generateImplicitConversion(this.implicitConversion);
- codeStream.generateReturnBytecode(this);
- falseLabel.place();
- codeStream.iconst_0();
- } else {
- codeStream.goto_(endLabel = new Label(codeStream));
- codeStream.decrStackSize(1);
- falseLabel.place();
- codeStream.iconst_0();
- endLabel.place();
- }
- } else {
- falseLabel.place();
- }
- }
+ generateLogicalXor(currentScope, codeStream, valueRequired);
+ break;
}
break;
case LEFT_SHIFT :
@@ -514,6 +437,7 @@ public class BinaryExpression extends OperatorExpression {
}
break;
case GREATER :
+ Label falseLabel, endLabel;
generateOptimizedGreaterThan(
currentScope,
codeStream,
@@ -1152,6 +1076,167 @@ public class BinaryExpression extends OperatorExpression {
/**
* Boolean generation for &
*/
+ public void generateLogicalAnd(
+ BlockScope currentScope,
+ CodeStream codeStream,
+ boolean valueRequired) {
+
+ Constant condConst;
+ if ((left.implicitConversion & COMPILE_TYPE_MASK) == T_boolean) {
+ if ((condConst = left.optimizedBooleanConstant()) != Constant.NotAConstant) {
+ if (condConst.booleanValue() == true) {
+ // <something equivalent to true> & x
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, valueRequired);
+ } else {
+ // <something equivalent to false> & x
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, false);
+ if (valueRequired) {
+ codeStream.iconst_0();
+ }
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ }
+ return;
+ }
+ if ((condConst = right.optimizedBooleanConstant()) != Constant.NotAConstant) {
+ if (condConst.booleanValue() == true) {
+ // x & <something equivalent to true>
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, false);
+ } else {
+ // x & <something equivalent to false>
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, false);
+ if (valueRequired) {
+ codeStream.iconst_0();
+ }
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ }
+ return;
+ }
+ }
+ // default case
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ codeStream.iand();
+ }
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ }
+
+ /**
+ * Boolean generation for |
+ */
+ public void generateLogicalOr(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+
+ Constant condConst;
+ if ((left.implicitConversion & COMPILE_TYPE_MASK) == T_boolean) {
+ if ((condConst = left.optimizedBooleanConstant()) != Constant.NotAConstant) {
+ if (condConst.booleanValue() == true) {
+ // <something equivalent to true> | x
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, false);
+ if (valueRequired) {
+ codeStream.iconst_1();
+ }
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ } else {
+ // <something equivalent to false> | x
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, valueRequired);
+ }
+ return;
+ }
+ if ((condConst = right.optimizedBooleanConstant()) != Constant.NotAConstant) {
+ if (condConst.booleanValue() == true) {
+ // x | <something equivalent to true>
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, false);
+ if (valueRequired) {
+ codeStream.iconst_1();
+ }
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ } else {
+ // x | <something equivalent to false>
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, false);
+ }
+ return;
+ }
+ }
+ // default case
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ codeStream.ior();
+ }
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ }
+
+ /**
+ * Boolean generation for ^
+ */
+ public void generateLogicalXor(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+
+ Constant condConst;
+ if ((left.implicitConversion & COMPILE_TYPE_MASK) == T_boolean) {
+ if ((condConst = left.optimizedBooleanConstant()) != Constant.NotAConstant) {
+ if (condConst.booleanValue() == true) {
+ // <something equivalent to true> ^ x
+ left.generateCode(currentScope, codeStream, false);
+ if (valueRequired) {
+ codeStream.iconst_1();
+ }
+ right.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ codeStream.ixor(); // negate
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ }
+ } else {
+ // <something equivalent to false> ^ x
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, valueRequired);
+ }
+ return;
+ }
+ if ((condConst = right.optimizedBooleanConstant()) != Constant.NotAConstant) {
+ if (condConst.booleanValue() == true) {
+ // x ^ <something equivalent to true>
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, false);
+ if (valueRequired) {
+ codeStream.iconst_1();
+ codeStream.ixor(); // negate
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ }
+ } else {
+ // x ^ <something equivalent to false>
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, false);
+ }
+ return;
+ }
+ }
+ // default case
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ codeStream.ixor();
+ }
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
+ }
+
+ /**
+ * Boolean generation for &
+ */
public void generateOptimizedLogicalAnd(
BlockScope currentScope,
CodeStream codeStream,
@@ -1170,16 +1255,12 @@ public class BinaryExpression extends OperatorExpression {
trueLabel,
falseLabel,
false);
- if ((bits & OnlyValueRequired) != 0) {
- right.generateCode(currentScope, codeStream, valueRequired);
- } else {
- right.generateOptimizedBoolean(
- currentScope,
- codeStream,
- trueLabel,
- falseLabel,
- valueRequired);
- }
+ right.generateOptimizedBoolean(
+ currentScope,
+ codeStream,
+ trueLabel,
+ falseLabel,
+ valueRequired);
} else {
// <something equivalent to false> & x
left.generateOptimizedBoolean(
@@ -1188,22 +1269,16 @@ public class BinaryExpression extends OperatorExpression {
trueLabel,
falseLabel,
false);
- Label internalTrueLabel = new Label(codeStream);
right.generateOptimizedBoolean(
currentScope,
codeStream,
trueLabel,
falseLabel,
false);
- internalTrueLabel.place();
if (valueRequired) {
- if ((bits & OnlyValueRequired) != 0) {
- codeStream.iconst_0();
- } else {
- if (falseLabel != null) {
- // implicit falling through the TRUE case
- codeStream.goto_(falseLabel);
- }
+ if (falseLabel != null) {
+ // implicit falling through the TRUE case
+ codeStream.goto_(falseLabel);
}
}
// reposition the endPC
@@ -1214,16 +1289,12 @@ public class BinaryExpression extends OperatorExpression {
if ((condConst = right.optimizedBooleanConstant()) != Constant.NotAConstant) {
if (condConst.booleanValue() == true) {
// x & <something equivalent to true>
- if ((bits & OnlyValueRequired) != 0) {
- left.generateCode(currentScope, codeStream, valueRequired);
- } else {
- left.generateOptimizedBoolean(
- currentScope,
- codeStream,
- trueLabel,
- falseLabel,
- valueRequired);
- }
+ left.generateOptimizedBoolean(
+ currentScope,
+ codeStream,
+ trueLabel,
+ falseLabel,
+ valueRequired);
right.generateOptimizedBoolean(
currentScope,
codeStream,
@@ -1247,13 +1318,9 @@ public class BinaryExpression extends OperatorExpression {
falseLabel,
false);
if (valueRequired) {
- if ((bits & OnlyValueRequired) != 0) {
- codeStream.iconst_0();
- } else {
- if (falseLabel != null) {
- // implicit falling through the TRUE case
- codeStream.goto_(falseLabel);
- }
+ if (falseLabel != null) {
+ // implicit falling through the TRUE case
+ codeStream.goto_(falseLabel);
}
}
// reposition the endPC
@@ -1267,19 +1334,17 @@ public class BinaryExpression extends OperatorExpression {
right.generateCode(currentScope, codeStream, valueRequired);
if (valueRequired) {
codeStream.iand();
- if ((bits & OnlyValueRequired) == 0) {
- if (falseLabel == null) {
- if (trueLabel != null) {
- // implicit falling through the FALSE case
- codeStream.ifne(trueLabel);
- }
+ if (falseLabel == null) {
+ if (trueLabel != null) {
+ // implicit falling through the FALSE case
+ codeStream.ifne(trueLabel);
+ }
+ } else {
+ // implicit falling through the TRUE case
+ if (trueLabel == null) {
+ codeStream.ifeq(falseLabel);
} else {
- // implicit falling through the TRUE case
- if (trueLabel == null) {
- codeStream.ifeq(falseLabel);
- } else {
- // no implicit fall through TRUE/FALSE --> should never occur
- }
+ // no implicit fall through TRUE/FALSE --> should never occur
}
}
}
@@ -1317,12 +1382,8 @@ public class BinaryExpression extends OperatorExpression {
false);
internalFalseLabel.place();
if (valueRequired) {
- if ((bits & OnlyValueRequired) != 0) {
- codeStream.iconst_1();
- } else {
- if (trueLabel != null) {
- codeStream.goto_(trueLabel);
- }
+ if (trueLabel != null) {
+ codeStream.goto_(trueLabel);
}
}
// reposition the endPC
@@ -1335,16 +1396,12 @@ public class BinaryExpression extends OperatorExpression {
trueLabel,
falseLabel,
false);
- if ((bits & OnlyValueRequired) != 0) {
- right.generateCode(currentScope, codeStream, valueRequired);
- } else {
- right.generateOptimizedBoolean(
- currentScope,
- codeStream,
- trueLabel,
- falseLabel,
- valueRequired);
- }
+ right.generateOptimizedBoolean(
+ currentScope,
+ codeStream,
+ trueLabel,
+ falseLabel,
+ valueRequired);
}
return;
}
@@ -1366,28 +1423,20 @@ public class BinaryExpression extends OperatorExpression {
falseLabel,
false);
if (valueRequired) {
- if ((bits & OnlyValueRequired) != 0) {
- codeStream.iconst_1();
- } else {
- if (trueLabel != null) {
- codeStream.goto_(trueLabel);
- }
+ if (trueLabel != null) {
+ codeStream.goto_(trueLabel);
}
}
// reposition the endPC
codeStream.updateLastRecordedEndPC(currentScope, codeStream.position);
} else {
// x | <something equivalent to false>
- if ((bits & OnlyValueRequired) != 0) {
- left.generateCode(currentScope, codeStream, valueRequired);
- } else {
- left.generateOptimizedBoolean(
- currentScope,
- codeStream,
- trueLabel,
- falseLabel,
- valueRequired);
- }
+ left.generateOptimizedBoolean(
+ currentScope,
+ codeStream,
+ trueLabel,
+ falseLabel,
+ valueRequired);
right.generateOptimizedBoolean(
currentScope,
codeStream,
@@ -1403,19 +1452,17 @@ public class BinaryExpression extends OperatorExpression {
right.generateCode(currentScope, codeStream, valueRequired);
if (valueRequired) {
codeStream.ior();
- if ((bits & OnlyValueRequired) == 0) {
- if (falseLabel == null) {
- if (trueLabel != null) {
- // implicit falling through the FALSE case
- codeStream.ifne(trueLabel);
- }
+ if (falseLabel == null) {
+ if (trueLabel != null) {
+ // implicit falling through the FALSE case
+ codeStream.ifne(trueLabel);
+ }
+ } else {
+ // implicit falling through the TRUE case
+ if (trueLabel == null) {
+ codeStream.ifeq(falseLabel);
} else {
- // implicit falling through the TRUE case
- if (trueLabel == null) {
- codeStream.ifeq(falseLabel);
- } else {
- // no implicit fall through TRUE/FALSE --> should never occur
- }
+ // no implicit fall through TRUE/FALSE --> should never occur
}
}
}
@@ -1447,7 +1494,7 @@ public class BinaryExpression extends OperatorExpression {
right.generateOptimizedBoolean(
currentScope,
codeStream,
- falseLabel,
+ falseLabel, // negating
trueLabel,
valueRequired);
} else {
@@ -1458,16 +1505,12 @@ public class BinaryExpression extends OperatorExpression {
trueLabel,
falseLabel,
false);
- if ((bits & OnlyValueRequired) != 0) {
- right.generateCode(currentScope, codeStream, valueRequired);
- } else {
- right.generateOptimizedBoolean(
- currentScope,
- codeStream,
- trueLabel,
- falseLabel,
- valueRequired);
- }
+ right.generateOptimizedBoolean(
+ currentScope,
+ codeStream,
+ trueLabel,
+ falseLabel,
+ valueRequired);
}
return;
}
@@ -1477,7 +1520,7 @@ public class BinaryExpression extends OperatorExpression {
left.generateOptimizedBoolean(
currentScope,
codeStream,
- falseLabel,
+ falseLabel, // negating
trueLabel,
valueRequired);
right.generateOptimizedBoolean(
@@ -1488,16 +1531,12 @@ public class BinaryExpression extends OperatorExpression {
false);
} else {
// x ^ <something equivalent to false>
- if ((bits & OnlyValueRequired) != 0) {
- left.generateCode(currentScope, codeStream, valueRequired);
- } else {
- left.generateOptimizedBoolean(
- currentScope,
- codeStream,
- trueLabel,
- falseLabel,
- valueRequired);
- }
+ left.generateOptimizedBoolean(
+ currentScope,
+ codeStream,
+ trueLabel,
+ falseLabel,
+ valueRequired);
right.generateOptimizedBoolean(
currentScope,
codeStream,
@@ -1513,19 +1552,17 @@ public class BinaryExpression extends OperatorExpression {
right.generateCode(currentScope, codeStream, valueRequired);
if (valueRequired) {
codeStream.ixor();
- if ((bits & OnlyValueRequired) == 0) {
- if (falseLabel == null) {
- if (trueLabel != null) {
- // implicit falling through the FALSE case
- codeStream.ifne(trueLabel);
- }
+ if (falseLabel == null) {
+ if (trueLabel != null) {
+ // implicit falling through the FALSE case
+ codeStream.ifne(trueLabel);
+ }
+ } else {
+ // implicit falling through the TRUE case
+ if (trueLabel == null) {
+ codeStream.ifeq(falseLabel);
} else {
- // implicit falling through the TRUE case
- if (trueLabel == null) {
- codeStream.ifeq(falseLabel);
- } else {
- // no implicit fall through TRUE/FALSE --> should never occur
- }
+ // no implicit fall through TRUE/FALSE --> should never occur
}
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
index bed3bae56a..552ab46faa 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
@@ -126,45 +126,23 @@ public class EqualExpression extends BinaryExpression {
*/
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+ int pc = codeStream.position;
if (constant != Constant.NotAConstant) {
- int pc = codeStream.position;
if (valueRequired)
codeStream.generateConstant(constant, implicitConversion);
codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
- Label falseLabel;
- bits |= OnlyValueRequired;
- generateOptimizedBoolean(
- currentScope,
- codeStream,
- null,
- falseLabel = new Label(codeStream),
- valueRequired);
- if (falseLabel.hasForwardReferences()) {
- if (valueRequired){
- // comparison is TRUE
- codeStream.iconst_1();
- if ((bits & IsReturnedValue) != 0){
- codeStream.generateImplicitConversion(this.implicitConversion);
- codeStream.generateReturnBytecode(this);
- // comparison is FALSE
- falseLabel.place();
- codeStream.iconst_0();
- } else {
- Label endLabel = new Label(codeStream);
- codeStream.goto_(endLabel);
- codeStream.decrStackSize(1);
- // comparison is FALSE
- falseLabel.place();
- codeStream.iconst_0();
- endLabel.place();
- }
- codeStream.generateImplicitConversion(implicitConversion);
- } else {
- falseLabel.place();
- }
+
+ if ((left.implicitConversion & COMPILE_TYPE_MASK) /*compile-time*/ == T_boolean) {
+ generateBooleanEqual(currentScope, codeStream, valueRequired);
+ } else {
+ generateNonBooleanEqual(currentScope, codeStream, valueRequired);
}
+ if (valueRequired) {
+ codeStream.generateImplicitConversion(implicitConversion);
+ }
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
}
/**
* Boolean operator code generation
@@ -190,6 +168,155 @@ public class EqualExpression extends BinaryExpression {
}
}
}
+
+ /**
+ * Boolean generation for == with boolean operands
+ *
+ * Note this code does not optimize conditional constants !!!!
+ */
+ public void generateBooleanEqual(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+
+ // optimized cases: <something equivalent to true> == x, <something equivalent to false> == x,
+ // optimized cases: <something equivalent to false> != x, <something equivalent to true> != x,
+ boolean isEqualOperator = ((this.bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL;
+ Constant cst = left.optimizedBooleanConstant();
+ if (cst != Constant.NotAConstant) {
+ Constant rightCst = right.optimizedBooleanConstant();
+ if (rightCst != Constant.NotAConstant) {
+ // <something equivalent to true> == <something equivalent to true>, <something equivalent to false> != <something equivalent to true>
+ // <something equivalent to true> == <something equivalent to false>, <something equivalent to false> != <something equivalent to false>
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, false);
+ if (valueRequired) {
+ boolean leftBool = cst.booleanValue();
+ boolean rightBool = rightCst.booleanValue();
+ if (isEqualOperator) {
+ if (leftBool == rightBool) {
+ codeStream.iconst_1();
+ } else {
+ codeStream.iconst_0();
+ }
+ } else {
+ if (leftBool != rightBool) {
+ codeStream.iconst_1();
+ } else {
+ codeStream.iconst_0();
+ }
+ }
+ }
+ } else if (cst.booleanValue() == isEqualOperator) {
+ // <something equivalent to true> == x, <something equivalent to false> != x
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, valueRequired);
+ } else {
+ // <something equivalent to false> == x, <something equivalent to true> != x
+ if (valueRequired) {
+ Label falseLabel = new Label(codeStream);
+ left.generateCode(currentScope, codeStream, false);
+ right.generateOptimizedBoolean(currentScope, codeStream, null, falseLabel, valueRequired);
+ // comparison is TRUE
+ codeStream.iconst_0();
+ if ((bits & IsReturnedValue) != 0){
+ codeStream.generateImplicitConversion(this.implicitConversion);
+ codeStream.generateReturnBytecode(this);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_1();
+ } else {
+ Label endLabel = new Label(codeStream);
+ codeStream.goto_(endLabel);
+ codeStream.decrStackSize(1);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_1();
+ endLabel.place();
+ }
+ } else {
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, false);
+ }
+// left.generateCode(currentScope, codeStream, false);
+// right.generateCode(currentScope, codeStream, valueRequired);
+// if (valueRequired) {
+// codeStream.iconst_1();
+// codeStream.ixor(); // negate
+// }
+ }
+ return;
+ }
+ cst = right.optimizedBooleanConstant();
+ if (cst != Constant.NotAConstant) {
+ if (cst.booleanValue() == isEqualOperator) {
+ // x == <something equivalent to true>, x != <something equivalent to false>
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, false);
+ } else {
+ // x == <something equivalent to false>, x != <something equivalent to true>
+ if (valueRequired) {
+ Label falseLabel = new Label(codeStream);
+ left.generateOptimizedBoolean(currentScope, codeStream, null, falseLabel, valueRequired);
+ right.generateCode(currentScope, codeStream, false);
+ // comparison is TRUE
+ codeStream.iconst_0();
+ if ((bits & IsReturnedValue) != 0){
+ codeStream.generateImplicitConversion(this.implicitConversion);
+ codeStream.generateReturnBytecode(this);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_1();
+ } else {
+ Label endLabel = new Label(codeStream);
+ codeStream.goto_(endLabel);
+ codeStream.decrStackSize(1);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_1();
+ endLabel.place();
+ }
+ } else {
+ left.generateCode(currentScope, codeStream, false);
+ right.generateCode(currentScope, codeStream, false);
+ }
+// left.generateCode(currentScope, codeStream, valueRequired);
+// right.generateCode(currentScope, codeStream, false);
+// if (valueRequired) {
+// codeStream.iconst_1();
+// codeStream.ixor(); // negate
+// }
+ }
+ return;
+ }
+ // default case
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, valueRequired);
+
+ if (valueRequired) {
+ if (isEqualOperator) {
+ Label falseLabel;
+ codeStream.if_icmpne(falseLabel = new Label(codeStream));
+ // comparison is TRUE
+ codeStream.iconst_1();
+ if ((bits & IsReturnedValue) != 0){
+ codeStream.generateImplicitConversion(this.implicitConversion);
+ codeStream.generateReturnBytecode(this);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ } else {
+ Label endLabel = new Label(codeStream);
+ codeStream.goto_(endLabel);
+ codeStream.decrStackSize(1);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ endLabel.place();
+ }
+ } else {
+ codeStream.ixor();
+ }
+ }
+ }
+
/**
* Boolean generation for == with boolean operands
*
@@ -233,6 +360,215 @@ public class EqualExpression extends BinaryExpression {
* Boolean generation for == with non-boolean operands
*
*/
+ public void generateNonBooleanEqual(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+
+ boolean isEqualOperator = ((this.bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL;
+ if (((left.implicitConversion & IMPLICIT_CONVERSION_MASK) >> 4) == T_int) {
+ Constant cst;
+ if ((cst = left.constant) != Constant.NotAConstant && cst.intValue() == 0) {
+ // optimized case: 0 == x, 0 != x
+ right.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ Label falseLabel = new Label(codeStream);
+ if (isEqualOperator) {
+ codeStream.ifne(falseLabel);
+ } else {
+ codeStream.ifeq(falseLabel);
+ }
+ // comparison is TRUE
+ codeStream.iconst_1();
+ if ((bits & IsReturnedValue) != 0){
+ codeStream.generateImplicitConversion(this.implicitConversion);
+ codeStream.generateReturnBytecode(this);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ } else {
+ Label endLabel = new Label(codeStream);
+ codeStream.goto_(endLabel);
+ codeStream.decrStackSize(1);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ endLabel.place();
+ }
+ }
+ return;
+ }
+ if ((cst = right.constant) != Constant.NotAConstant && cst.intValue() == 0) {
+ // optimized case: x == 0, x != 0
+ left.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ Label falseLabel = new Label(codeStream);
+ if (isEqualOperator) {
+ codeStream.ifne(falseLabel);
+ } else {
+ codeStream.ifeq(falseLabel);
+ }
+ // comparison is TRUE
+ codeStream.iconst_1();
+ if ((bits & IsReturnedValue) != 0){
+ codeStream.generateImplicitConversion(this.implicitConversion);
+ codeStream.generateReturnBytecode(this);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ } else {
+ Label endLabel = new Label(codeStream);
+ codeStream.goto_(endLabel);
+ codeStream.decrStackSize(1);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ endLabel.place();
+ }
+ }
+ return;
+ }
+ }
+
+ // null cases
+ if (right instanceof NullLiteral) {
+ if (left instanceof NullLiteral) {
+ // null == null, null != null
+ if (valueRequired) {
+ if (isEqualOperator) {
+ codeStream.iconst_1();
+ } else {
+ codeStream.iconst_0();
+ }
+ }
+ } else {
+ // x == null, x != null
+ left.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ Label falseLabel = new Label(codeStream);
+ if (isEqualOperator) {
+ codeStream.ifnonnull(falseLabel);
+ } else {
+ codeStream.ifnull(falseLabel);
+ }
+ // comparison is TRUE
+ codeStream.iconst_1();
+ if ((bits & IsReturnedValue) != 0){
+ codeStream.generateImplicitConversion(this.implicitConversion);
+ codeStream.generateReturnBytecode(this);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ } else {
+ Label endLabel = new Label(codeStream);
+ codeStream.goto_(endLabel);
+ codeStream.decrStackSize(1);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ endLabel.place();
+ }
+ }
+ }
+ return;
+ } else if (left instanceof NullLiteral) {
+ // null = x, null != x
+ right.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ Label falseLabel = new Label(codeStream);
+ if (isEqualOperator) {
+ codeStream.ifnonnull(falseLabel);
+ } else {
+ codeStream.ifnull(falseLabel);
+ }
+ // comparison is TRUE
+ codeStream.iconst_1();
+ if ((bits & IsReturnedValue) != 0){
+ codeStream.generateImplicitConversion(this.implicitConversion);
+ codeStream.generateReturnBytecode(this);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ } else {
+ Label endLabel = new Label(codeStream);
+ codeStream.goto_(endLabel);
+ codeStream.decrStackSize(1);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ endLabel.place();
+ }
+ }
+ return;
+ }
+
+ // default case
+ left.generateCode(currentScope, codeStream, valueRequired);
+ right.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ Label falseLabel = new Label(codeStream);
+ if (isEqualOperator) {
+ switch ((left.implicitConversion & IMPLICIT_CONVERSION_MASK) >> 4) { // operand runtime type
+ case T_int :
+ codeStream.if_icmpne(falseLabel);
+ break;
+ case T_float :
+ codeStream.fcmpl();
+ codeStream.ifne(falseLabel);
+ break;
+ case T_long :
+ codeStream.lcmp();
+ codeStream.ifne(falseLabel);
+ break;
+ case T_double :
+ codeStream.dcmpl();
+ codeStream.ifne(falseLabel);
+ break;
+ default :
+ codeStream.if_acmpne(falseLabel);
+ }
+ } else {
+ switch ((left.implicitConversion & IMPLICIT_CONVERSION_MASK) >> 4) { // operand runtime type
+ case T_int :
+ codeStream.if_icmpeq(falseLabel);
+ break;
+ case T_float :
+ codeStream.fcmpl();
+ codeStream.ifeq(falseLabel);
+ break;
+ case T_long :
+ codeStream.lcmp();
+ codeStream.ifeq(falseLabel);
+ break;
+ case T_double :
+ codeStream.dcmpl();
+ codeStream.ifeq(falseLabel);
+ break;
+ default :
+ codeStream.if_acmpeq(falseLabel);
+ }
+ }
+ // comparison is TRUE
+ codeStream.iconst_1();
+ if ((bits & IsReturnedValue) != 0){
+ codeStream.generateImplicitConversion(this.implicitConversion);
+ codeStream.generateReturnBytecode(this);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ } else {
+ Label endLabel = new Label(codeStream);
+ codeStream.goto_(endLabel);
+ codeStream.decrStackSize(1);
+ // comparison is FALSE
+ falseLabel.place();
+ codeStream.iconst_0();
+ endLabel.place();
+ }
+ }
+ }
+
+ /**
+ * Boolean generation for == with non-boolean operands
+ *
+ */
public void generateOptimizedNonBooleanEqual(BlockScope currentScope, CodeStream codeStream, Label trueLabel, Label falseLabel, boolean valueRequired) {
int pc = codeStream.position;
@@ -290,19 +626,11 @@ public class EqualExpression extends BinaryExpression {
if (left instanceof NullLiteral) {
// null == null
if (valueRequired) {
- if ((bits & OnlyValueRequired) != 0) {
- if (((bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL) {
- codeStream.iconst_1();
- } else {
- codeStream.iconst_0();
- }
- } else {
- if (falseLabel == null) {
- // implicit falling through the FALSE case
- if (trueLabel != null) {
- codeStream.goto_(trueLabel);
- }
- }
+ if (falseLabel == null) {
+ // implicit falling through the FALSE case
+ if (trueLabel != null) {
+ codeStream.goto_(trueLabel);
+ }
}
}
} else {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
index d3b76f7847..f2202fd554 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
@@ -166,19 +166,22 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean
}
} else {
boolean isStatic = this.codegenBinding.isStatic();
+ boolean isThisReceiver = this.receiver instanceof ThisReference;
Constant fieldConstant = this.codegenBinding.constant();
if (fieldConstant != Constant.NotAConstant) {
- receiver.generateCode(currentScope, codeStream, !isStatic);
- if (!isStatic){
- codeStream.invokeObjectGetClass();
- codeStream.pop();
+ if (!isThisReceiver) {
+ receiver.generateCode(currentScope, codeStream, !isStatic);
+ if (!isStatic){
+ codeStream.invokeObjectGetClass();
+ codeStream.pop();
+ }
}
if (valueRequired) {
codeStream.generateConstant(fieldConstant, implicitConversion);
}
} else {
- receiver.generateCode(currentScope, codeStream, !isStatic);
- if (valueRequired || currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
+ if (valueRequired || (!isThisReceiver && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4)) {
+ receiver.generateCode(currentScope, codeStream, !isStatic);
if (this.codegenBinding.declaringClass == null) { // array length
codeStream.arraylength();
if (valueRequired) {
@@ -213,9 +216,12 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean
}
}
} else {
- if (!isStatic){
- if (!(this.receiver instanceof ThisReference)) codeStream.invokeObjectGetClass(); // perform null check
- codeStream.pop();
+ if (!isThisReceiver) {
+ receiver.generateCode(currentScope, codeStream, !isStatic);
+ if (!isStatic){
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
}
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
index a7759fa362..0ab5cafba5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
@@ -220,7 +220,7 @@ public class QualifiedNameReference extends NameReference {
boolean complyTo14 = currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4;
switch (bits & RestrictiveFlagMASK) {
case Binding.FIELD : // reading a field
- if (needValue || complyTo14) {
+ if (needValue) {
manageSyntheticAccessIfNecessary(currentScope, (FieldBinding) binding, this.actualReceiverType, 0, flowInfo);
}
if (this.indexOfFirstFieldBinding == 1) { // was an implicit reference to the first field binding
@@ -261,12 +261,12 @@ public class QualifiedNameReference extends NameReference {
}
if (needValue) {
manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
- // only for first binding
+ // only for first binding (if value needed only)
}
if (otherBindings != null) {
for (int i = 0; i < otherBindingsCount; i++) {
needValue = i < otherBindingsCount-1 ? !otherBindings[i+1].isStatic() : valueRequired;
- if (needValue || complyTo14) {
+ if (needValue || (i > 0 && complyTo14)) {
TypeBinding lastReceiverType = getGenericCast(i);
if (lastReceiverType == null) {
if (i == 0) {
@@ -376,7 +376,10 @@ public class QualifiedNameReference extends NameReference {
codeStream.generateConstant(fieldConstant, implicitConversion);
}
} else {
- if (valueRequired || currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
+ boolean isFirst = lastFieldBinding == this.binding
+ && (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType())
+ && this.otherBindings == null; // could be dup: next.next.next
+ if (valueRequired || (!isFirst && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4)) {
if (lastFieldBinding.declaringClass == null) { // array length
codeStream.arraylength();
if (valueRequired) {
@@ -558,7 +561,7 @@ public class QualifiedNameReference extends NameReference {
if (lastFieldBinding.constant() != Constant.NotAConstant) {
break;
}
- if ((needValue || complyTo14) && !lastFieldBinding.isStatic()) {
+ if (needValue && !lastFieldBinding.isStatic()) {
int pc = codeStream.position;
if ((bits & DepthMASK) != 0) {
ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
@@ -600,7 +603,7 @@ public class QualifiedNameReference extends NameReference {
needValue = !nextField.isStatic();
Constant fieldConstant = lastFieldBinding.constant();
if (fieldConstant != Constant.NotAConstant) {
- if (lastFieldBinding != this.codegenBinding && !lastFieldBinding.isStatic()) {
+ if (i > 0 && !lastFieldBinding.isStatic()) {
codeStream.invokeObjectGetClass(); // perform null check
codeStream.pop();
}
@@ -608,7 +611,7 @@ public class QualifiedNameReference extends NameReference {
codeStream.generateConstant(fieldConstant, 0);
}
} else {
- if (needValue || complyTo14) {
+ if (needValue || (i > 0 && complyTo14)) {
MethodBinding accessor = syntheticReadAccessors == null ? null : syntheticReadAccessors[i];
if (accessor == null) {
if (lastFieldBinding.isStatic()) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
index 854054e174..3f4f6f73e5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
@@ -342,7 +342,7 @@ public class SingleNameReference extends NameReference implements OperatorIds {
codeStream.generateConstant(fieldConstant, implicitConversion);
}
} else {
- if (valueRequired || currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) {
+ if (valueRequired) {
boolean isStatic = fieldBinding.isStatic();
if (!isStatic) {
if ((bits & DepthMASK) != 0) {

Back to the top