Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2020-05-19 10:43:39 -0400
committerStephan Herrmann2020-05-19 10:43:39 -0400
commit52605209658b93177a2cd8f1de09dbb940059695 (patch)
treee3834f66ce9c4cd39f262227e78d27dd1350ba68
parent3c7c941c3c45317df1b273767698f62f60de914f (diff)
downloadeclipse.jdt.core-52605209658b93177a2cd8f1de09dbb940059695.tar.gz
eclipse.jdt.core-52605209658b93177a2cd8f1de09dbb940059695.tar.xz
eclipse.jdt.core-52605209658b93177a2cd8f1de09dbb940059695.zip
Bug 550480 - ClassFile.addFieldInfos throwsI20200520-0600
ArrayIndexOutOfBoundsException - part 2 Change-Id: I2aedda2b757e060fef815127158171efde362847
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java3
2 files changed, 22 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java
index 53c49bf32c..49a9c058dc 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/XLargeTest2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Andrey Loskutov and others.
+ * Copyright (c) 2018, 2020 Andrey Loskutov and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -404,4 +404,22 @@ public class XLargeTest2 extends AbstractRegressionTest {
"interface gwz {}\n" +
"interface gxc {}\n";
}
+ public void testBug550480() {
+ StringBuilder source = new StringBuilder();
+ source.append("package p;\n");
+ String[] names = new String[571];
+ for (int i = 0; i < 571; i++) {
+ names[i] = "I"+i;
+ source.append("interface ").append(names[i]).append(" {}\n");
+ }
+ source.append("public abstract class hft implements ");
+ source.append(String.join(", ", names));
+ source.append("\n{\n}\n");
+ runConformTest(
+ new String[] {
+ "p/hft.java",
+ source.toString()
+ });
+ }
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index 4f62474ca9..974f01248a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -5778,6 +5778,9 @@ public class ClassFile implements TypeConstants, TypeIds {
if ((binding.tagBits & TagBits.HasMissingType) != 0) {
continue;
}
+ if (this.contentsOffset + 4 >= this.contents.length) {
+ resizeContents(4); // 2 bytes this iteration plus 2 bytes after the loop
+ }
interfaceCounter++;
int interfaceIndex = this.constantPool.literalIndexForType(binding);
this.contents[this.contentsOffset++] = (byte) (interfaceIndex >> 8);

Back to the top