summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-11-04 09:05:41 +0000
committeracolyer <acolyer>2005-11-04 09:05:41 +0000
commita87f82dcb4a8f162a02992d89a78ec43b677fef5 (patch)
treefa191b7f418ad95dda87b3aead56f10a76c7045c
parentc4ce2448ee0ad553d6768a22e82bba7f437a93fa (diff)
downloadaspectj-a87f82dcb4a8f162a02992d89a78ec43b677fef5.tar.gz
aspectj-a87f82dcb4a8f162a02992d89a78ec43b677fef5.zip
fix for 103741 - use of java 5 specific language features now policed at < 1.5 source level
-rw-r--r--weaver/src/org/aspectj/weaver/WeaverMessages.java13
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java7
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java12
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java7
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java7
-rw-r--r--weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java4
-rw-r--r--weaver/src/org/aspectj/weaver/weaver-messages.properties13
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java1
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java1
13 files changed, 83 insertions, 1 deletions
diff --git a/weaver/src/org/aspectj/weaver/WeaverMessages.java b/weaver/src/org/aspectj/weaver/WeaverMessages.java
index e97867c41..8b0ecf8d4 100644
--- a/weaver/src/org/aspectj/weaver/WeaverMessages.java
+++ b/weaver/src/org/aspectj/weaver/WeaverMessages.java
@@ -142,6 +142,19 @@ public class WeaverMessages {
public static final String INCORRECT_TARGET_FOR_DECLARE_ANNOTATION = "incorrectTargetForDeclareAnnotation";
public static final String NO_MATCH_BECAUSE_SOURCE_RETENTION = "noMatchBecauseSourceRetention";
+ // < Java5 messages
+ public static final String ATANNOTATION_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atannotationNeedsJava5";
+ public static final String ATWITHIN_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atwithinNeedsJava5";
+ public static final String ATWITHINCODE_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atwithincodeNeedsJava5";
+ public static final String ATTHIS_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atthisNeedsJava5";
+ public static final String ATTARGET_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "attargetNeedsJava5";
+ public static final String ATARGS_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atargsNeedsJava5";
+ public static final String DECLARE_ATTYPE_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "declareAtTypeNeedsJava5";
+ public static final String DECLARE_ATMETHOD_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "declareAtMethodNeedsJava5";
+ public static final String DECLARE_ATFIELD_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "declareAtFieldNeedsJava5";
+ public static final String DECLARE_ATCONS_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "declareAtConsNeedsJava5";
+ public static final String ANNOTATIONS_NEED_JAVA5 = "annotationsRequireJava5";
+
// Generics
public static final String CANT_DECP_MULTIPLE_PARAMETERIZATIONS="cantDecpMultipleParameterizations";
public static final String HANDLER_PCD_DOESNT_SUPPORT_PARAMETERS="noParameterizedTypePatternInHandler";
diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
index 32fd6c0a1..3cf61459a 100644
--- a/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.AnnotatedElement;
@@ -34,6 +35,7 @@ import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.ShadowMunger;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
+import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
import org.aspectj.weaver.ast.Var;
@@ -161,6 +163,11 @@ public class AnnotationPointcut extends NameBindingPointcut {
* @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings)
*/
protected void resolveBindings(IScope scope, Bindings bindings) {
+ if (!scope.getWorld().isInJava5Mode()) {
+ scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.ATANNOTATION_ONLY_SUPPORTED_AT_JAVA5_LEVEL),
+ getSourceLocation()));
+ return;
+ }
annotationTypePattern = (ExactAnnotationTypePattern) annotationTypePattern.resolveBindings(scope,bindings,true);
// must be either a Var, or an annotation type pattern
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
index c2e7d7931..f289c585d 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java
@@ -20,6 +20,7 @@ import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;
+import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.IntMap;
@@ -86,6 +87,11 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut {
* @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings)
*/
protected void resolveBindings(IScope scope, Bindings bindings) {
+ if (!scope.getWorld().isInJava5Mode()) {
+ scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.ATARGS_ONLY_SUPPORTED_AT_JAVA5_LEVEL),
+ getSourceLocation()));
+ return;
+ }
arguments.resolveBindings(scope, bindings, true);
if (arguments.ellipsisCount > 1) {
scope.message(IMessage.ERROR, this,
diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java b/weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java
index 2c504f747..51563fce2 100644
--- a/weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java
+++ b/weaver/src/org/aspectj/weaver/patterns/DeclareAnnotation.java
@@ -17,12 +17,14 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
+import org.aspectj.bridge.MessageUtil;
import org.aspectj.weaver.AnnotationX;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
+import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.World;
public class DeclareAnnotation extends Declare {
@@ -106,6 +108,16 @@ public class DeclareAnnotation extends Declare {
}
public void resolve(IScope scope) {
+ if (!scope.getWorld().isInJava5Mode()) {
+ String msg = null;
+ if (kind == AT_TYPE) { msg = WeaverMessages.DECLARE_ATTYPE_ONLY_SUPPORTED_AT_JAVA5_LEVEL; }
+ else if (kind == AT_METHOD) { msg = WeaverMessages.DECLARE_ATMETHOD_ONLY_SUPPORTED_AT_JAVA5_LEVEL;}
+ else if (kind == AT_FIELD) { msg = WeaverMessages.DECLARE_ATFIELD_ONLY_SUPPORTED_AT_JAVA5_LEVEL;}
+ else if (kind == AT_CONSTRUCTOR) { msg = WeaverMessages.DECLARE_ATCONS_ONLY_SUPPORTED_AT_JAVA5_LEVEL;}
+ scope.message(MessageUtil.error(WeaverMessages.format(msg),
+ getSourceLocation()));
+ return;
+ }
if (typePattern != null) {
typePattern = typePattern.resolveBindings(scope,Bindings.NONE,false,false);
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
index 2a0f0ef4e..72c262c64 100644
--- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java
@@ -118,6 +118,12 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut {
* @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings)
*/
protected void resolveBindings(IScope scope, Bindings bindings) {
+ if (!scope.getWorld().isInJava5Mode()) {
+ scope.message(MessageUtil.error(WeaverMessages.format(
+ isThis ? WeaverMessages.ATTHIS_ONLY_SUPPORTED_AT_JAVA5_LEVEL : WeaverMessages.ATTARGET_ONLY_SUPPORTED_AT_JAVA5_LEVEL),
+ getSourceLocation()));
+ return;
+ }
annotationTypePattern = (ExactAnnotationTypePattern) annotationTypePattern.resolveBindings(scope,bindings,true);
// must be either a Var, or an annotation type pattern
// if annotationType does not have runtime retention, this is an error
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
index f4b19f720..3b317cbf7 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
@@ -80,7 +80,12 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
public AnnotationTypePattern resolveBindings(IScope scope, Bindings bindings,
boolean allowBinding)
{
- if (resolved) return this;
+ if (!scope.getWorld().isInJava5Mode()) {
+ scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.ANNOTATIONS_NEED_JAVA5),
+ getSourceLocation()));
+ return this;
+ }
+ if (resolved) return this;
this.typePattern = typePattern.resolveBindings(scope,bindings,false,false);
resolved = true;
if (typePattern instanceof ExactTypePattern) {
diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
index 886faf6db..fc87efde1 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java
@@ -20,6 +20,7 @@ import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;
+import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.ISourceContext;
@@ -101,6 +102,11 @@ public class WithinAnnotationPointcut extends NameBindingPointcut {
* @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings)
*/
protected void resolveBindings(IScope scope, Bindings bindings) {
+ if (!scope.getWorld().isInJava5Mode()) {
+ scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.ATWITHIN_ONLY_SUPPORTED_AT_JAVA5_LEVEL),
+ getSourceLocation()));
+ return;
+ }
annotationTypePattern = (ExactAnnotationTypePattern) annotationTypePattern.resolveBindings(scope,bindings,true);
// must be either a Var, or an annotation type pattern
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java
index d61d13e79..7a4bc988f 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.AnnotatedElement;
import org.aspectj.weaver.BCException;
@@ -31,6 +32,7 @@ import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.ShadowMunger;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
+import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
import org.aspectj.weaver.ast.Var;
@@ -112,6 +114,11 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut {
* @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings)
*/
protected void resolveBindings(IScope scope, Bindings bindings) {
+ if (!scope.getWorld().isInJava5Mode()) {
+ scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.ATWITHINCODE_ONLY_SUPPORTED_AT_JAVA5_LEVEL),
+ getSourceLocation()));
+ return;
+ }
annotationTypePattern = (ExactAnnotationTypePattern) annotationTypePattern.resolveBindings(scope,bindings,true);
// must be either a Var, or an annotation type pattern
}
diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java
index 0846b7a93..1019ca617 100644
--- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java
+++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java
@@ -35,6 +35,7 @@ import org.aspectj.bridge.MessageUtil;
import org.aspectj.bridge.MessageWriter;
import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.util.FileUtil;
+import org.aspectj.util.LangUtil;
import org.aspectj.weaver.IClassFileProvider;
import org.aspectj.weaver.IWeaveRequestor;
import org.aspectj.weaver.bcel.BcelWeaver;
@@ -144,6 +145,9 @@ public class WeavingAdaptor {
bcelWorld = new BcelWorld(classPath,messageHandler,null);
bcelWorld.setXnoInline(false);
bcelWorld.getLint().loadDefaultProperties();
+ if (LangUtil.is15VMOrGreater()) {
+ bcelWorld.setBehaveInJava5Way(true);
+ }
weaver = new BcelWeaver(bcelWorld);
registerAspectLibraries(aspectPath);
diff --git a/weaver/src/org/aspectj/weaver/weaver-messages.properties b/weaver/src/org/aspectj/weaver/weaver-messages.properties
index 734b7221d..c274d8f13 100644
--- a/weaver/src/org/aspectj/weaver/weaver-messages.properties
+++ b/weaver/src/org/aspectj/weaver/weaver-messages.properties
@@ -172,6 +172,19 @@ noRawTypePointcutReferences=cannot use a raw type reference to refer to a pointc
hasMemberNotEnabled=the type pattern {0} can only be used when the -XhasMember option is set
+# Java5 features used in pre-Java 5 environment
+atannotationNeedsJava5=the @annotation pointcut expression is only supported at Java 5 compliance level or above
+atwithinNeedsJava5=the @within pointcut expression is only supported at Java 5 compliance level or above
+atwithincodeNeedsJava5=the @withincode pointcut expression is only supported at Java 5 compliance level or above
+atthisNeedsJava5=the @this pointcut expression is only supported at Java 5 compliance level or above
+attargetNeedsJava5=the @target pointcut expression is only supported at Java 5 compliance level or above
+atargsNeedsJava5=the @args pointcut expression is only supported at Java 5 compliance level or above
+declareAtTypeNeedsJava5=declare @type is only supported at Java 5 compliance level or above
+declareAtMethodNeedsJava5=declare @method is only supported at Java 5 compliance level or above
+declareAtFieldNeedsJava5=declare @field is only supported at Java 5 compliance level or above
+declareAtConsNeedsJava5=declare @constructor is only supported at Java 5 compliance level or above
+annotationsRequireJava5=annotation type patterns are only supported at Java 5 compliance level or above
+
# @AspectJ
returningFormalNotDeclaredInAdvice=the last parameter of this advice must be named ''{0}'' to bind the returning value
thrownFormalNotDeclaredInAdvice=the last parameter of this advice must be named ''{0}'' and be of a subtype of Throwable \ No newline at end of file
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
index bdf27dff3..892bbe638 100644
--- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
@@ -65,6 +65,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
private ResolvedType loadType(String name) {
if (world == null) {
world = new BcelWorld(BcweaverTests.TESTDATA_PATH + "/testcode.jar");
+ world.setBehaveInJava5Way(true);
}
return world.resolve(name);
}
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
index d681b638f..3551775f4 100644
--- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
@@ -324,6 +324,7 @@ public class AnnotationPatternTestCase extends TestCase {
public TestScope makeSimpleScope() {
BcelWorld bWorld = new BcelWorld(BcweaverTests.TESTDATA_PATH + "/testcode.jar"); // testcode contains Foo/Boo/Goo/etc
+ bWorld.setBehaveInJava5Way(true);
return new TestScope(new String[] {"int", "java.lang.String","Foo","Boo","Goo"},
new String[] {"a", "b","foo","boo","goo"},
bWorld);
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
index 60e1e2d32..a018e338c 100644
--- a/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
@@ -677,6 +677,7 @@ public class ParserTestCase extends TestCase {
public TestScope makeSimpleScope() {
+ world.setBehaveInJava5Way(true);
TestScope s = new TestScope(new String[] {"int", "java.lang.String"}, new String[] {"a", "b"}, world);
s.setImportedPrefixes(new String[]{"p."});
return s;