Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-09-22 14:39:46 +0000
committerStephan Herrmann2012-09-22 14:39:46 +0000
commit47700cc09e0d3152088b67bbb6920af31adc19d2 (patch)
tree978e7076c3ca6b895e6680f066c8605a34816ff3
parent33b594be315d2d641dd3d95841d974a64eb782a9 (diff)
downloadorg.eclipse.objectteams-47700cc09e0d3152088b67bbb6920af31adc19d2.tar.gz
org.eclipse.objectteams-47700cc09e0d3152088b67bbb6920af31adc19d2.tar.xz
org.eclipse.objectteams-47700cc09e0d3152088b67bbb6920af31adc19d2.zip
Bug 354480 - VerifyError due to bogus lowering in inferred
callout-to-field
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/InsertTypeAdjustmentsVisitor.java13
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java60
2 files changed, 72 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/InsertTypeAdjustmentsVisitor.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/InsertTypeAdjustmentsVisitor.java
index 9ebfbc774..10333153c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/InsertTypeAdjustmentsVisitor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/InsertTypeAdjustmentsVisitor.java
@@ -43,6 +43,7 @@ import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
@@ -141,11 +142,21 @@ public class InsertTypeAdjustmentsVisitor extends ASTVisitor {
@Override
public void endVisit(FieldReference fieldReference, BlockScope scope) {
// e.g., someArray.length has NO declaring class, so be careful
- if (fieldReference.binding.declaringClass != null)
+ if (fieldReference.binding.declaringClass != null) {
+ MethodBinding[] syntheticAccessors = fieldReference.syntheticAccessors;
+ if (syntheticAccessors != null) {
+ for (int i = 0; i < syntheticAccessors.length; i++) {
+ MethodBinding accessor = syntheticAccessors[i];
+ if (accessor instanceof SyntheticMethodBinding
+ && ((SyntheticMethodBinding)accessor).purpose == SyntheticMethodBinding.InferredCalloutToField)
+ return; // already redirecting to base, prevent double-lowering
+ }
+ }
fieldReference.receiver = maybeWrap(
scope,
fieldReference.receiver,
fieldReference.binding.declaringClass);
+ }
}
public void endVisit(AllocationExpression alloc, BlockScope scope) {
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java
index 42b446d24..8e9e2ed15 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java
@@ -19,6 +19,7 @@ import java.util.Map;
import junit.framework.Test;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.objectteams.otdt.tests.otjld.AbstractOTJLDTest;
@@ -3703,4 +3704,63 @@ public class CalloutToField extends AbstractOTJLDTest {
"Incompatible types: can\'t convert java.lang.Object[] to java.lang.String[] (OTJLD 3.5(b)).\n" +
"----------\n");
}
+
+ // Bug 354480 - VerifyError due to bogus lowering in inferred callout-to-field
+ public void testBug354480() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS, JavaCore.ENABLED);
+ runConformTest(
+ new String[] {
+ "Main.java",
+ "import b.Return;\n" +
+ "import b.Scope;\n" +
+ "import t.Team1;\n" +
+ "public class Main {\n" +
+ " public static void main(String[] args) {\n" +
+ " new Team1().activate();\n" +
+ " new Return().analyse(new Scope());\n" +
+ " }\n" +
+ "}\n",
+ "b/Expr.java",
+ "package b;\n" +
+ "public class Expr {\n" +
+ " public void analyse(Scope scope) {\n" +
+ " System.out.print(\"OK\");\n" +
+ " }\n" +
+ "}\n",
+ "b/Scope.java",
+ "package b;\n" +
+ "public class Scope {}\n",
+ "b/Return.java",
+ "package b;\n" +
+ "public class Return {\n" +
+ " public Expr expr = new Expr();\n" +
+ " public void analyse(Scope scope) {\n" +
+ " }\n" +
+ "}\n",
+ "t/Team1.java",
+ "package t;\n" +
+ "import b.Expr;\n" +
+ "import base b.Return;\n" +
+ "import base b.Scope;\n" +
+ "\n" +
+ "public team class Team1 {\n" +
+ " protected class Scope playedBy Scope {}\n" +
+ " protected class Return playedBy Return {\n" +
+ " Expr getExpr() -> get Expr expr;\n" +
+ " void analyse(Scope scope) <- replace void analyse(Scope scope);\n" +
+ " @SuppressWarnings({\"inferredcallout\", \"basecall\"})\n" +
+ " callin void analyse(Scope scope) {\n" +
+ " this.expr.analyse(scope);\n" + // expr via c-t-f, scope needs lowering
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "OK",
+ null/*classLibraries*/,
+ false/*shouldFlushOutputDirectory*/,
+ null/*vmArguments*/,
+ options,
+ null/*no custom requestor*/);
+ }
}

Back to the top