Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2016-10-29 19:40:48 +0000
committerStephan Herrmann2016-11-22 19:08:56 +0000
commitb3eaeb269ca3d41a67b7c157eefb21e9bb5b7e11 (patch)
tree17e86be38d814b8a25e07f731695a74b02e972ca
parent780f3409ea9ceb5e218788eeb3a54b9227a2c930 (diff)
downloadorg.eclipse.objectteams-b3eaeb269ca3d41a67b7c157eefb21e9bb5b7e11.tar.gz
org.eclipse.objectteams-b3eaeb269ca3d41a67b7c157eefb21e9bb5b7e11.tar.xz
org.eclipse.objectteams-b3eaeb269ca3d41a67b7c157eefb21e9bb5b7e11.zip
Bug 506740: compiler needs to evaluate OTSpecialAccessAttribute in order
to disambiguate access IDs
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/OTSpecialAccessAttribute.java11
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java74
2 files changed, 82 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/OTSpecialAccessAttribute.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/OTSpecialAccessAttribute.java
index 11374367d..f1d47c2ff 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/OTSpecialAccessAttribute.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/bytecode/OTSpecialAccessAttribute.java
@@ -63,7 +63,7 @@ public class OTSpecialAccessAttribute extends AbstractAttribute {
/**
* For OTREDyn, each attribute of this type maintains a set of locally unique (per team) access IDs.
* These IDs are later made unique per team-hierarchy by adding {@link #accessIdOffset}.
- * This for of ids is then stored in the attribute.
+ * This form of ids is then stored in the attribute.
* Stored ids are consumed and translated by OTREDyn to obtain those global IDs that uniquely identify the
* base feature within a generated _OT$access or _OT$accessStatic method.
*
@@ -378,12 +378,14 @@ public class OTSpecialAccessAttribute extends AbstractAttribute {
int kind = consumeByte();
switch(kind) {
case DYN_DECAPSULATION_METHOD_ACCESS:
+ this.nextAccessId++;
this._readOffset += 2; // extra id
//$FALL-THROUGH$
case DECAPSULATION_METHOD_ACCESS:
this._readOffset += 6;
break;
case DYN_CALLOUT_FIELD_ACCESS:
+ this.nextAccessId++;
this._readOffset += 2; // extra id
//$FALL-THROUGH$
case CALLOUT_FIELD_ACCESS:
@@ -403,8 +405,11 @@ public class OTSpecialAccessAttribute extends AbstractAttribute {
// don't see a need to evaluate all this:
// for (TeamFieldDesc field : _teamFields)
// field.evaluate(binding, environment);
- if (((ReferenceBinding)binding).isRole())
- ((ReferenceBinding)binding).roleModel.setSpecialAccess(this);
+ ReferenceBinding referenceBinding = (ReferenceBinding)binding;
+ if (referenceBinding.isRole())
+ referenceBinding.roleModel.setSpecialAccess(this);
+ if (referenceBinding.isTeam())
+ referenceBinding._teamModel.setSpecialAccess(this);
if (this._baseclassNames != null)
for (int i=0; i<this._baseclassNames.size(); i++) {
char[] name = this._baseclassNames.get(i);
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java
index c5be28070..6c44b8524 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java
@@ -561,4 +561,78 @@ public class InheritanceHierarchyOfTeams extends AbstractOTJLDTest {
},
"cycle");
}
+
+ public void testBug506740() {
+ runConformTest(
+ new String[] {
+ "b/Base.java",
+ "package b;\n" +
+ "public class Base {\n" +
+ " private String f1 = \"f1\";\n" +
+ " private String f2 = \"f2\";\n" +
+ " private String f3 = \"f3\";\n" +
+ " private String f4 = \"f4\";\n" +
+ " private String f5 = \"f5\";\n" +
+ "}\n",
+ "t/Team1.java",
+ "package t;\n" +
+ "public team class Team1 {\n" +
+ " @SuppressWarnings(\"decapsulation\")\n" +
+ " protected class R playedBy b.Base {\n" +
+ " protected R() { base(); }\n" +
+ " protected String getF1() -> get String f1;\n" +
+ " protected String getF2() -> get String f2;\n" +
+ " }\n" +
+ "}\n"
+ });
+ runConformTest(
+ false, // no flush
+ new String[] {
+ "t/Team2.java",
+ "package t;\n" +
+ "public team class Team2 extends Team1 {\n" +
+ " @Override\n" +
+ " @SuppressWarnings(\"decapsulation\")\n" +
+ " protected class R {\n" +
+ " protected String getF3() -> get String f3;\n" +
+ " protected String getF4() -> get String f4;\n" +
+ " }\n" +
+ " void test() {\n" +
+ " R r = new R();\n" +
+ " System.out.print(r.getF1()+r.getF2()+r.getF3()+r.getF4());\n" +
+ " }\n" +
+ " public static void main(String... args) {\n" +
+ " new Team2().test();\n" +
+ " }\n" +
+ "}\n"
+ },
+ "",
+ "f1f2f3f4",
+ "",
+ null /* javacOptions */);
+ runConformTest(
+ false, // no flush
+ new String[] {
+ "t/Team3.java",
+ "package t;\n" +
+ "public team class Team3 extends Team2 {\n" +
+ " @Override\n" +
+ " @SuppressWarnings(\"decapsulation\")\n" +
+ " protected class R {\n" +
+ " protected String getF5() -> get String f5;\n" +
+ " }\n" +
+ " void test() {\n" +
+ " R r = new R();\n" +
+ " System.out.print(r.getF1()+r.getF2()+r.getF3()+r.getF4()+r.getF5());\n" +
+ " }\n" +
+ " public static void main(String... args) {\n" +
+ " new Team3().test();\n" +
+ " }\n" +
+ "}\n"
+ },
+ "",
+ "f1f2f3f4f5",
+ "",
+ null /* javacOptions */);
+ }
}

Back to the top