Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thomann2005-11-03 12:23:12 -0500
committerOlivier Thomann2005-11-03 12:23:12 -0500
commitd1a13dde33fb1b56c7d2cf613823953f5fe74535 (patch)
tree4311bf3e30e30e7a43310b894778045b46de3a15
parent93cca5f59c41b44fd213f223616400d580e272c4 (diff)
downloadeclipse.jdt.core-d1a13dde33fb1b56c7d2cf613823953f5fe74535.tar.gz
eclipse.jdt.core-d1a13dde33fb1b56c7d2cf613823953f5fe74535.tar.xz
eclipse.jdt.core-d1a13dde33fb1b56c7d2cf613823953f5fe74535.zip
3.0 maintenance - Fix for 114855
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java230
-rw-r--r--org.eclipse.jdt.core/buildnotes_jdt-core.html6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java72
3 files changed, 290 insertions, 18 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java
index eed66eab4f..f1cda394fd 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java
@@ -28,7 +28,7 @@ public static Test suite() {
TestSuite ts;
//some of the tests depend on the order of this suite.
ts = new TestSuite();
- ts.addTest(new TryStatementTest("test221"));
+ ts.addTest(new TryStatementTest("test026"));
return new RegressionTestSetup(ts, COMPLIANCE_1_4);
}
return setupSuite(testClass());
@@ -830,7 +830,233 @@ public void test025() {
},
"SUCCESS");
}
-
+/*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=114855
+ */
+public void test026() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X\n" +
+ "{\n" +
+ " static int except_count;\n" +
+ "\n" +
+ " static boolean test_result = true;\n" +
+ " \n" +
+ " static Throwable all_except[] =\n" +
+ " {\n" +
+ " new AbstractMethodError(), // 0\n" +
+ " new ArithmeticException(), // 1\n" +
+ " new ArrayIndexOutOfBoundsException(), // 2\n" +
+ " new ArrayStoreException(), // 3\n" +
+ " new ClassCastException(), // 4\n" +
+ " new ClassCircularityError(), // 5\n" +
+ " new ClassFormatError(), // 6\n" +
+ " new ClassNotFoundException(), // 7\n" +
+ " new CloneNotSupportedException(), // 8\n" +
+ " new Error(), // 9\n" +
+ " new Exception(), // 10\n" +
+ " new IllegalAccessError(), // 11\n" +
+ " new IllegalAccessException(), // 12\n" +
+ " new IllegalArgumentException(), // 13\n" +
+ " new IllegalMonitorStateException(), // 14\n" +
+ " new IllegalThreadStateException(), // 15\n" +
+ " new IncompatibleClassChangeError(), // 16\n" +
+ " new IndexOutOfBoundsException(), // 17\n" +
+ " new InstantiationError(), // 18\n" +
+ " new InstantiationException(), // 19\n" +
+ " new InternalError(), // 20\n" +
+ " new InterruptedException(), // 21\n" +
+ " new LinkageError(), // 22\n" +
+ " new NegativeArraySizeException(), // 23\n" +
+ " new NoClassDefFoundError(), // 24\n" +
+ " new NoSuchFieldError(), // 25\n" +
+ " new NoSuchMethodError(), // 26\n" +
+ " new NoSuchMethodException(), // 27\n" +
+ " new NullPointerException(), // 28\n" +
+ " new NumberFormatException(), // 29\n" +
+ " new OutOfMemoryError(), // 30\n" +
+ " new StackOverflowError(), // 31\n" +
+ " new RuntimeException(), // 32\n" +
+ " new SecurityException(), // 33\n" +
+ " new StringIndexOutOfBoundsException(), // 34\n" +
+ " new ThreadDeath(), // 35\n" +
+ " new UnknownError(), // 36\n" +
+ " new UnsatisfiedLinkError(), // 37\n" +
+ " new VerifyError(), // 38\n" +
+ " };\n" +
+ "\n" +
+ " private static void check_except(int i)\n" +
+ " throws Throwable\n" +
+ " {\n" +
+ " if (except_count != i)\n" +
+ " {\n" +
+ " System.out.println(\"Error \"+except_count+\" != \"+i+\";\");\n" +
+ " test_result=false;\n" +
+ " }\n" +
+ " throw all_except[++except_count];\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) throws Throwable\n" +
+ " {\n" +
+ " try {\n" +
+ " except_count = 0;\n" +
+ " throw all_except[except_count];\n" +
+ " } catch (AbstractMethodError e0) {\n" +
+ " try {\n" +
+ " check_except(0);\n" +
+ " } catch (ArithmeticException e1) {\n" +
+ " try {\n" +
+ " check_except(1);\n" +
+ " } catch (ArrayIndexOutOfBoundsException e2) {\n" +
+ " try {\n" +
+ " check_except(2);\n" +
+ " } catch (ArrayStoreException e3) {\n" +
+ " try {\n" +
+ " check_except(3);\n" +
+ " } catch (ClassCastException e4) {\n" +
+ " try {\n" +
+ " check_except(4);\n" +
+ " } catch (ClassCircularityError e5) {\n" +
+ " try {\n" +
+ " check_except(5);\n" +
+ " } catch (ClassFormatError e6) {\n" +
+ " try {\n" +
+ " check_except(6);\n" +
+ " } catch (ClassNotFoundException e7) {\n" +
+ " try {\n" +
+ " check_except(7);\n" +
+ " } catch (CloneNotSupportedException e8) {\n" +
+ " try {\n" +
+ " check_except(8);\n" +
+ " } catch (Error e9) {\n" +
+ " try {\n" +
+ " check_except(9);\n" +
+ " } catch (Exception e10) {\n" +
+ " try {\n" +
+ " check_except(10);\n" +
+ " } catch (IllegalAccessError e11) {\n" +
+ " try {\n" +
+ " check_except(11);\n" +
+ " } catch (IllegalAccessException e12) {\n" +
+ " try {\n" +
+ " check_except(12);\n" +
+ " } catch (IllegalArgumentException e13) {\n" +
+ " try {\n" +
+ " check_except(13);\n" +
+ " } catch (IllegalMonitorStateException e14) {\n" +
+ " try {\n" +
+ " check_except(14);\n" +
+ " } catch (IllegalThreadStateException e15) {\n" +
+ " try {\n" +
+ " check_except(15);\n" +
+ " } catch (IncompatibleClassChangeError e16) {\n" +
+ " try {\n" +
+ " check_except(16);\n" +
+ " } catch (IndexOutOfBoundsException e17) {\n" +
+ " try {\n" +
+ " check_except(17);\n" +
+ " } catch (InstantiationError e18) {\n" +
+ " try {\n" +
+ " check_except(18);\n" +
+ " } catch (InstantiationException e19) {\n" +
+ " try {\n" +
+ " check_except(19);\n" +
+ " } catch (InternalError e20) {\n" +
+ " try {\n" +
+ " check_except(20);\n" +
+ " } catch (InterruptedException \n" +
+ "e21) {\n" +
+ " try {\n" +
+ " check_except(21);\n" +
+ " } catch (LinkageError e22) {\n" +
+ " try {\n" +
+ " check_except(22);\n" +
+ " } catch \n" +
+ "(NegativeArraySizeException e23) {\n" +
+ " try {\n" +
+ " check_except(23);\n" +
+ " } catch \n" +
+ "(NoClassDefFoundError e24) {\n" +
+ " try {\n" +
+ " check_except(24);\n" +
+ " } catch (NoSuchFieldError \n" +
+ "e25) {\n" +
+ " try {\n" +
+ " check_except(25);\n" +
+ " } catch \n" +
+ "(NoSuchMethodError e26) {\n" +
+ " try {\n" +
+ " check_except(26);\n" +
+ " } catch \n" +
+ "(NoSuchMethodException e27) {\n" +
+ " try {\n" +
+ " check_except(27);\n" +
+ " } catch \n" +
+ "(NullPointerException e28) {\n" +
+ " try {\n" +
+ " check_except\n" +
+ "(28);\n" +
+ " } catch \n" +
+ "(NumberFormatException e29) {\n" +
+ " try {\n" +
+ " check_except\n" +
+ "(29);\n" +
+ " } catch \n" +
+ "(OutOfMemoryError e30) {\n" +
+ " try {\n" +
+ " check_except\n" +
+ "(30);\n" +
+ " } catch \n" +
+ "(StackOverflowError e31) {\n" +
+ " try {\n" +
+ " \n" +
+ "check_except(31);\n" +
+ " } catch \n" +
+ "(RuntimeException e32) {\n" +
+ " try {\n" +
+ " \n" +
+ "check_except(32);\n" +
+ " } catch \n" +
+ "(SecurityException e33) {\n" +
+ " try {\n" +
+ " \n" +
+ "check_except(33);\n" +
+ " } catch \n" +
+ "(StringIndexOutOfBoundsException e34) {\n" +
+ " try {\n" +
+ " \n" +
+ "check_except(34);\n" +
+ " } \n" +
+ "catch (ThreadDeath e35) {\n" +
+ " try \n" +
+ "{\n" +
+ " \n" +
+ "check_except(35);\n" +
+ " } \n" +
+ "catch (UnknownError e36) {\n" +
+ " \n" +
+ "try {\n" +
+ " \n" +
+ "check_except(36);\n" +
+ " } \n" +
+ "catch (UnsatisfiedLinkError e37) {\n" +
+ " \n" +
+ "try {\n" +
+ " \n" +
+ " check_except(37);\n" +
+ " \n" +
+ "} catch (VerifyError e38) {\n" +
+ " \n" +
+ " ++except_count;\n" +
+ " \n" +
+ "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n" +
+ " System.out.print(test_result & (except_count == all_except.length));\n" +
+ " }\n" +
+ "}",
+ },
+ "true");
+}
public static Class testClass() {
return TryStatementTest.class;
}
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index a6214be8a8..e002b389b9 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -39,7 +39,7 @@
<p><hr><h1>
Eclipse Platform Build Notes&nbsp;<br>
Java Development Tooling Core</h1>
-Eclipse SDK 3.0.3 Build - 3rd August 2005 - 3.0.3 RELEASE (R3_0_3)
+Eclipse SDK 3.0.3 Build - 3rd Novembre 2005 - 3.0.3 RELEASE (R3_0_3)
<br>Project org.eclipse.jdt.core v_454_R30x
(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_455_R30x">cvs</a>).
<h2>
@@ -51,7 +51,9 @@ What's new in this drop</h2>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=88351">88351</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=114855">114855</a>
+[compiler] OutOfMemoryError compiling deeply nested try-catch
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=88351">88351</a>
Compiler dependency problem in 2.1.3 & the latest 3.0.2 build
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
index 8c29bcef2b..82fd470063 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
+import java.util.Arrays;
+
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
@@ -36,26 +38,68 @@ public Label(CodeStream codeStream) {
/**
* Add a forward refrence for the array.
*/
-void addForwardReference(int iPos) {
- int length;
- if (forwardReferenceCount >= (length = forwardReferences.length))
- System.arraycopy(forwardReferences, 0, (forwardReferences = new int[2*length]), 0, length);
- forwardReferences[forwardReferenceCount++] = iPos;
+void addForwardReference(int pos) {
+ final int count = this.forwardReferenceCount;
+ if (count >= 1) {
+ int previousValue = this.forwardReferences[count - 1];
+ if (previousValue < pos) {
+ int length;
+ if (count >= (length = this.forwardReferences.length))
+ System.arraycopy(this.forwardReferences, 0, (this.forwardReferences = new int[2*length]), 0, length);
+ this.forwardReferences[this.forwardReferenceCount++] = pos;
+ } else if (previousValue > pos) {
+ int[] refs = this.forwardReferences;
+ // check for duplicates
+ for (int i = 0, max = this.forwardReferenceCount; i < max; i++) {
+ if (refs[i] == pos) return; // already recorded
+ }
+ int length;
+ if (count >= (length = refs.length))
+ System.arraycopy(refs, 0, (this.forwardReferences = new int[2*length]), 0, length);
+ this.forwardReferences[this.forwardReferenceCount++] = pos;
+ Arrays.sort(this.forwardReferences, 0, this.forwardReferenceCount);
+ }
+ } else {
+ int length;
+ if (count >= (length = this.forwardReferences.length))
+ System.arraycopy(this.forwardReferences, 0, (this.forwardReferences = new int[2*length]), 0, length);
+ this.forwardReferences[this.forwardReferenceCount++] = pos;
+ }
}
/**
* Add a forward refrence for the array.
*/
public void appendForwardReferencesFrom(Label otherLabel) {
- int otherCount = otherLabel.forwardReferenceCount;
+ final int otherCount = otherLabel.forwardReferenceCount;
if (otherCount == 0) return;
- int length = forwardReferences.length;
- int neededSpace = otherCount + forwardReferenceCount;
- if (neededSpace >= length){
- System.arraycopy(forwardReferences, 0, (forwardReferences = new int[neededSpace]), 0, forwardReferenceCount);
+ // need to merge the two sorted arrays of forward references
+ int[] mergedForwardReferences = new int[this.forwardReferenceCount + otherCount];
+ int indexInMerge = 0;
+ int j = 0;
+ int i = 0;
+ int max = this.forwardReferenceCount;
+ int max2 = otherLabel.forwardReferenceCount;
+ loop1 : for (; i < max; i++) {
+ final int value1 = this.forwardReferences[i];
+ for (; j < max2; j++) {
+ final int value2 = otherLabel.forwardReferences[j];
+ if (value1 < value2) {
+ mergedForwardReferences[indexInMerge++] = value1;
+ continue loop1;
+ } else if (value1 == value2) {
+ mergedForwardReferences[indexInMerge++] = value1;
+ j++;
+ continue loop1;
+ } else {
+ mergedForwardReferences[indexInMerge++] = value2;
+ }
+ }
+ }
+ for (; j < max2; j++) {
+ mergedForwardReferences[indexInMerge++] = otherLabel.forwardReferences[j];
}
- // append other forward references at the end, so they will get updated as well
- System.arraycopy(otherLabel.forwardReferences, 0, forwardReferences, forwardReferenceCount, otherCount);
- forwardReferenceCount = neededSpace;
+ this.forwardReferences = mergedForwardReferences;
+ this.forwardReferenceCount = indexInMerge;
}
/*
* Put down a reference to the array at the location in the codestream.
@@ -157,7 +201,7 @@ public void place() { // Currently lacking wide support.
codeStream.classFileOffset -= 3;
forwardReferenceCount--;
// also update the PCs in the related debug attributes
- /** OLD CODE
+ /* OLD CODE
int index = codeStream.pcToSourceMapSize - 1;
while ((index >= 0) && (codeStream.pcToSourceMap[index][1] == oldPosition)) {
codeStream.pcToSourceMap[index--][1] = position;

Back to the top