Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thomann2010-05-07 22:41:40 +0000
committerOlivier Thomann2010-05-07 22:41:40 +0000
commit44c359d4e16b0a0cefad78de7d70067feb645d08 (patch)
treea99c0540b62cfe2be32509d49ceae2ba3be72725
parent26fab1acba3d4fab5c24965c0d448282359f31a0 (diff)
downloadeclipse.jdt.core-44c359d4e16b0a0cefad78de7d70067feb645d08.tar.gz
eclipse.jdt.core-44c359d4e16b0a0cefad78de7d70067feb645d08.tar.xz
eclipse.jdt.core-44c359d4e16b0a0cefad78de7d70067feb645d08.zip
JSR_308 - Fix stack map problem with synthetic method
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java97
3 files changed, 84 insertions, 19 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
index 20957cc227..cdb82add4a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
@@ -33,7 +33,7 @@ public class EnumTest extends AbstractComparableTest {
// All specified tests which does not belong to the class are skipped...
static {
// TESTS_NAMES = new String[] { "test000" };
-// TESTS_NUMBERS = new int[] { 181 };
+// TESTS_NUMBERS = new int[] { 63 };
// TESTS_RANGE = new int[] { 21, 50 };
}
public static Test suite() {
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 8188d6e799..69349332c2 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
@@ -41058,7 +41058,7 @@ public void test1203c() {
String[] sources =
new String[] {
"X.java",
- "class X extends Y {\n" +
+ "public class X extends Y {\n" +
" public static void main(String[] args) {\n" +
" String s = \"\";\n" +
" new X().<String> a(s);\n" + // fails before 7
@@ -41140,7 +41140,7 @@ public void test1203d() {
String[] sources =
new String[] {
"X.java",
- "class X implements I {\n" +
+ "public class X implements I {\n" +
" public static void main(String[] args) {\n" +
" String s = \"\";\n" +
" new X().<String> a(s);\n" + // fails before 7
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 d8f731f82e..b58ba98568 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
@@ -1273,11 +1273,21 @@ public class ClassFile implements TypeConstants, TypeIds {
}
if (addStackMaps) {
- attributesNumber += generateStackMapTableAttribute(code_length, codeAttributeOffset, max_locals, false);
+ attributesNumber += generateStackMapTableAttribute(
+ this.codeStream.methodDeclaration.binding,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ false);
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
- attributesNumber += generateStackMapAttribute(code_length, codeAttributeOffset, max_locals, false);
+ attributesNumber += generateStackMapAttribute(
+ this.codeStream.methodDeclaration.binding,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ false);
}
this.contents[codeAttributeAttributeOffset++] = (byte) (attributesNumber >> 8);
@@ -1408,11 +1418,21 @@ public class ClassFile implements TypeConstants, TypeIds {
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
- attributesNumber += generateStackMapTableAttribute(code_length, codeAttributeOffset, max_locals, true);
+ attributesNumber += generateStackMapTableAttribute(
+ null,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ true);
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
- attributesNumber += generateStackMapAttribute(code_length, codeAttributeOffset, max_locals, true);
+ attributesNumber += generateStackMapAttribute(
+ null,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ true);
}
// update the number of attributes
@@ -1508,11 +1528,21 @@ public class ClassFile implements TypeConstants, TypeIds {
this.contentsOffset = localContentsOffset;
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
- attributesNumber += generateStackMapTableAttribute(code_length, codeAttributeOffset, max_locals, true);
+ attributesNumber += generateStackMapTableAttribute(
+ null,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ true);
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
- attributesNumber += generateStackMapAttribute(code_length, codeAttributeOffset, max_locals, true);
+ attributesNumber += generateStackMapAttribute(
+ null,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ true);
}
// update the number of attributes
@@ -1577,11 +1607,21 @@ public class ClassFile implements TypeConstants, TypeIds {
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
- attributesNumber += generateStackMapTableAttribute(code_length, codeAttributeOffset, max_locals, false);
+ attributesNumber += generateStackMapTableAttribute(
+ binding,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ false);
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
- attributesNumber += generateStackMapAttribute(code_length, codeAttributeOffset, max_locals, false);
+ attributesNumber += generateStackMapAttribute(
+ binding,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ false);
}
// then we do the local variable attribute
@@ -1663,11 +1703,21 @@ public class ClassFile implements TypeConstants, TypeIds {
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
- attributesNumber += generateStackMapTableAttribute(code_length, codeAttributeOffset, max_locals, false);
+ attributesNumber += generateStackMapTableAttribute(
+ binding,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ false);
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
- attributesNumber += generateStackMapAttribute(code_length, codeAttributeOffset, max_locals, false);
+ attributesNumber += generateStackMapAttribute(
+ binding,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ false);
}
// update the number of attributes// ensure first that there is enough space available inside the localContents array
@@ -1814,11 +1864,16 @@ public class ClassFile implements TypeConstants, TypeIds {
attributesNumber += generateLocalVariableTableAttribute(code_length, methodDeclarationIsStatic, true);
}
if (addStackMaps) {
- attributesNumber += generateStackMapTableAttribute(code_length, codeAttributeOffset, max_locals, false);
+ attributesNumber += generateStackMapTableAttribute(binding, code_length, codeAttributeOffset, max_locals, false);
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
- attributesNumber += generateStackMapAttribute(code_length, codeAttributeOffset, max_locals, false);
+ attributesNumber += generateStackMapAttribute(
+ binding,
+ code_length,
+ codeAttributeOffset,
+ max_locals,
+ false);
}
// update the number of attributes
@@ -3505,14 +3560,19 @@ public class ClassFile implements TypeConstants, TypeIds {
this.contentsOffset = localContentsOffset;
return 1;
}
- private int generateStackMapAttribute(int code_length, int codeAttributeOffset, int max_locals, boolean isClinit) {
+ private int generateStackMapAttribute(
+ MethodBinding methodBinding,
+ int code_length,
+ int codeAttributeOffset,
+ int max_locals,
+ boolean isClinit) {
int attributesNumber = 0;
int localContentsOffset = this.contentsOffset;
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
stackMapFrameCodeStream.removeFramePosition(code_length);
if (stackMapFrameCodeStream.hasFramePositions()) {
ArrayList frames = new ArrayList();
- traverse(isClinit ? null : this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, isClinit);
+ traverse(isClinit ? null : methodBinding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, isClinit);
int numberOfFrames = frames.size();
if (numberOfFrames > 1) {
int stackMapTableAttributeOffset = localContentsOffset;
@@ -3677,14 +3737,19 @@ public class ClassFile implements TypeConstants, TypeIds {
return attributesNumber;
}
- private int generateStackMapTableAttribute(int code_length, int codeAttributeOffset, int max_locals, boolean isClinit) {
+ private int generateStackMapTableAttribute(
+ MethodBinding methodBinding,
+ int code_length,
+ int codeAttributeOffset,
+ int max_locals,
+ boolean isClinit) {
int attributesNumber = 0;
int localContentsOffset = this.contentsOffset;
StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
stackMapFrameCodeStream.removeFramePosition(code_length);
if (stackMapFrameCodeStream.hasFramePositions()) {
ArrayList frames = new ArrayList();
- traverse(isClinit ? null: this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, isClinit);
+ traverse(isClinit ? null: methodBinding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, isClinit);
int numberOfFrames = frames.size();
if (numberOfFrames > 1) {
int stackMapTableAttributeOffset = localContentsOffset;

Back to the top