From 504e4300204475cef1254de5d1308863c43b26e7 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 23 Nov 2005 12:36:28 +0000 Subject: 87525 - new error message (and testcase). Thats all I'm doing on this for 1.5.0 --- .../ajdt/internal/compiler/problem/AjProblemReporter.java | 15 +++++++++++++++ tests/bugs150/pr87525/A.java | 5 +++++ tests/bugs150/pr87525/B.java | 9 +++++++++ tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 1 + tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 6 ++++++ 5 files changed, 36 insertions(+) create mode 100644 tests/bugs150/pr87525/A.java create mode 100644 tests/bugs150/pr87525/B.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java index 5817b50ef..d33fa0ff4 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java @@ -24,6 +24,7 @@ import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration; import org.aspectj.ajdt.internal.compiler.ast.Proceed; import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; import org.aspectj.ajdt.internal.compiler.lookup.InterTypeMethodBinding; +import org.aspectj.ajdt.internal.compiler.lookup.PrivilegedFieldBinding; import org.aspectj.bridge.context.CompilationAndWeavingContext; import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; import org.aspectj.org.eclipse.jdt.core.compiler.IProblem; @@ -34,7 +35,9 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext; @@ -417,6 +420,18 @@ public class AjProblemReporter extends ProblemReporter { super.unusedPrivateMethod(methodDecl); } + public void caseExpressionMustBeConstant(Expression expression) { + if (expression instanceof QualifiedNameReference) { + QualifiedNameReference qnr = (QualifiedNameReference)expression; + if (qnr.otherBindings!=null && qnr.otherBindings.length>0 && qnr.otherBindings[0] instanceof PrivilegedFieldBinding) { + super.signalError(expression.sourceStart,expression.sourceEnd,"Fields accessible due to an aspect being privileged can not be used in switch statements"); + referenceContext.tagAsHavingErrors(); + return; + } + } + super.caseExpressionMustBeConstant(expression); + } + public void unusedArgument(LocalDeclaration localDecl) { // don't warn if this is an aj synthetic arg String argType = new String(localDecl.type.resolvedType.signature()); diff --git a/tests/bugs150/pr87525/A.java b/tests/bugs150/pr87525/A.java new file mode 100644 index 000000000..edb3b6924 --- /dev/null +++ b/tests/bugs150/pr87525/A.java @@ -0,0 +1,5 @@ +class A { + + private final static int c = 1; + +} diff --git a/tests/bugs150/pr87525/B.java b/tests/bugs150/pr87525/B.java new file mode 100644 index 000000000..5fbf93a4c --- /dev/null +++ b/tests/bugs150/pr87525/B.java @@ -0,0 +1,9 @@ +privileged aspect B { + + before(A anA):execution(* a()) && this(anA){ + switch(1){ + case anA.c: // "case expressions must be constant expressions" + } + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 683ee9e99..f6d67c689 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -49,6 +49,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testGenericITDsAndAbstractMethodError_pr102357() { runTest("generic itds and abstract method error");} */ + public void testPrivilegeProblem_pr87525() { runTest("privilege problem with switch");} public void testGenericAspects_pr115237() { runTest("aspectOf and generic aspects");} public void testClassFormatError_pr114436() { runTest("ClassFormatError binary weaving perthis");} public void testParserException_pr115788() { runTest("parser exception");} diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 39b35bb77..c517c8fc0 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -62,6 +62,12 @@ + + + + + + -- cgit v1.2.3