Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAyushman Jain2011-11-23 06:59:06 +0000
committerAyushman Jain2011-11-23 06:59:06 +0000
commite75d2e1dc6c4d6085a257406c7d26d4fde4b3631 (patch)
tree770c075904613b34e24d0e89547c6943c27fdc95
parentcc817186788a86e60b58427a9b7e989e5093af0a (diff)
downloadeclipse.jdt.core-e75d2e1dc6c4d6085a257406c7d26d4fde4b3631.tar.gz
eclipse.jdt.core-e75d2e1dc6c4d6085a257406c7d26d4fde4b3631.tar.xz
eclipse.jdt.core-e75d2e1dc6c4d6085a257406c7d26d4fde4b3631.zip
R3_7_maintenance - fixed bug 326591: VerifyError: Inconsistent stackmap
frames
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java84
-rw-r--r--org.eclipse.jdt.core/buildnotes_jdt-core.html4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java11
3 files changed, 97 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
index afc568e8dc..f6543aa96f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
@@ -7005,4 +7005,88 @@ public class StackMapAttributeTest extends AbstractRegressionTest {
assertEquals("Wrong contents", expectedOutput, actualOutput);
}
}
+
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=362591
+ public void test055() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " testError(3, 4, \"d\");\n" +
+ " }\n" +
+ " public static void testError(Number n0, Number n1, String refValue) {\n" +
+ " Number result = refValue.equals(\"ttt\") ? n0 : (n1 == null ? null : n1.intValue());\n" +
+ " System.out.println(String.valueOf(result));\n" +
+ " }\n" +
+ "}",
+ },
+ "4");
+
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator +"X.class"));
+ String actualOutput =
+ disassembler.disassemble(
+ classFileBytes,
+ "\n",
+ ClassFileBytesDisassembler.DETAILED);
+
+ String expectedOutput =
+ " // Method descriptor #27 (Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/String;)V\n" +
+ " // Stack: 2, Locals: 4\n" +
+ " public static void testError(java.lang.Number n0, java.lang.Number n1, java.lang.String refValue);\n" +
+ " 0 aload_2 [refValue]\n" +
+ " 1 ldc <String \"ttt\"> [30]\n" +
+ " 3 invokevirtual java.lang.String.equals(java.lang.Object) : boolean [32]\n" +
+ " 6 ifeq 13\n" +
+ " 9 aload_0 [n0]\n" +
+ " 10 goto 28\n" +
+ " 13 aload_1 [n1]\n" +
+ " 14 ifnonnull 21\n" +
+ " 17 aconst_null\n" +
+ " 18 goto 28\n" +
+ " 21 aload_1 [n1]\n" +
+ " 22 invokevirtual java.lang.Number.intValue() : int [38]\n" +
+ " 25 invokestatic java.lang.Integer.valueOf(int) : java.lang.Integer [16]\n" +
+ " 28 astore_3 [result]\n" +
+ " 29 getstatic java.lang.System.out : java.io.PrintStream [44]\n" +
+ " 32 aload_3 [result]\n" +
+ " 33 invokestatic java.lang.String.valueOf(java.lang.Object) : java.lang.String [50]\n" +
+ " 36 invokevirtual java.io.PrintStream.println(java.lang.String) : void [53]\n" +
+ " 39 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 6]\n" +
+ " [pc: 29, line: 7]\n" +
+ " [pc: 39, line: 8]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 40] local: n0 index: 0 type: java.lang.Number\n" +
+ " [pc: 0, pc: 40] local: n1 index: 1 type: java.lang.Number\n" +
+ " [pc: 0, pc: 40] local: refValue index: 2 type: java.lang.String\n" +
+ " [pc: 29, pc: 40] local: result index: 3 type: java.lang.Number\n" +
+ " Stack map table: number of frames 3\n" +
+ " [pc: 13, same]\n" +
+ " [pc: 21, same]\n" +
+ " [pc: 28, same_locals_1_stack_item, stack: {java.lang.Number}]\n";
+
+ int index = actualOutput.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(actualOutput, 2));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, actualOutput);
+ }
+ }
+
+ public void test055a() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " Object o = args != null ? args : (args == null ? null : args.length);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "");
+ }
}
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index efca9eb1bc..81ef06b583 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -51,7 +51,9 @@ Eclipse SDK 3.7.2 - %date% - 3.7.2
<h2>What's new in this drop</h2>
<h3>Problem Reports Fixed</h3>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=343060">343060</a>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=362591">362591</a>
+VerifyError: Inconsistent stackmap frames
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=343060">343060</a>
Method.getMethods() returns different methods (compared to standard compiler) for public/non-public inheritance hierarchies
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=361441">361441</a>
Error in JDT Core during AST creation
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java
index 14b8845037..e61cde3c50 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java
@@ -248,8 +248,17 @@ private void addStackDepthMarker(int pc, int delta, TypeBinding typeBinding) {
this.stackDepthMarkers.add(new StackDepthMarker(pc, delta, typeBinding));
} else {
int size = this.stackDepthMarkers.size();
- if (size == 0 || ((StackDepthMarker) this.stackDepthMarkers.get(size - 1)).pc != this.position) {
+ if (size == 0) {
this.stackDepthMarkers.add(new StackDepthMarker(pc, delta, typeBinding));
+ } else {
+ StackDepthMarker stackDepthMarker = (StackDepthMarker) this.stackDepthMarkers.get(size - 1);
+ if (stackDepthMarker.pc != this.position) {
+ this.stackDepthMarkers.add(new StackDepthMarker(pc, delta, typeBinding));
+ } else {
+ // We replace the recorded stack depth marker with a new value that contains the given typeBinding
+ // This case can happen when multiple conditional expression are nested see bug 362591
+ this.stackDepthMarkers.set(size - 1, new StackDepthMarker(pc, delta, typeBinding));
+ }
}
}
}

Back to the top