diff options
13 files changed, 63 insertions, 6 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 123a28e6b..42c78aaad 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -161,6 +161,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { World world = weaver.getWorld(); world.setMessageHandler(weaverOption.messageHandler); world.setXlazyTjp(weaverOption.lazyTjp); + world.setXHasMemberSupportEnabled(weaverOption.hasMember); weaver.setReweavableMode(weaverOption.reWeavable, false); world.setXnoInline(weaverOption.noInline); world.setBehaveInJava5Way(weaverOption.java5);//TODO should be autodetected ? diff --git a/loadtime/src/org/aspectj/weaver/loadtime/Options.java b/loadtime/src/org/aspectj/weaver/loadtime/Options.java index 7385fd482..adc16835f 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/Options.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/Options.java @@ -37,6 +37,7 @@ public class Options { private final static String OPTION_verbose = "-verbose"; private final static String OPTION_reweavable = "-Xreweavable"; private final static String OPTION_noinline = "-Xnoinline"; + private final static String OPTION_hasMember = "-XhasMember"; private final static String OPTION_showWeaveInfo = "-showWeaveInfo"; private final static String OPTIONVALUED_messageHandler = "-XmessageHandlerClass:"; private static final String OPTIONVALUED_Xlintfile = "-Xlintfile:"; @@ -93,6 +94,8 @@ public class Options { weaverOption.reWeavable = true; } else if (arg.equalsIgnoreCase(OPTION_showWeaveInfo)) { weaverOption.showWeaveInfo = true; + } else if (arg.equalsIgnoreCase(OPTION_hasMember)) { + weaverOption.hasMember = true; } else if (arg.equalsIgnoreCase(OPTION_verbose)) { weaverOption.verbose = true; } else if (arg.startsWith(OPTIONVALUED_messageHandler)) { @@ -134,6 +137,7 @@ public class Options { public static class WeaverOption { boolean java5; boolean lazyTjp; + boolean hasMember; boolean noWarn; boolean proceedOnError; boolean verbose; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java index 2de67f693..fd542eae3 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -529,7 +529,9 @@ public class BuildArgParser extends Main { } } else if (arg.equals("-XnoInline")) { buildConfig.setXnoInline(true); - } else if (arg.startsWith("-showWeaveInfo")) { + } else if (arg.equals("-XhasMember")) { + buildConfig.setXHasMemberSupport(true); + } else if (arg.startsWith("-showWeaveInfo")) { buildConfig.setShowWeavingInformation(true); } else if (arg.equals("-Xlintfile")) { if (args.size() > nextArgIndex) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties index a696691cf..ce6874f42 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties @@ -127,7 +127,9 @@ xoption.usage = {0} non-standard options:\n\ \t-Xreweavable:compress as above, but also compress the reweaving information\n\ \t-XserializableAspects allows aspects to implement serializable\n\ \t-XnoWeave compile classes but do not weave. Deprecated, use\n\ -\t reweavable instead.\n +\t reweavable instead.\n\ +\t-XhasMember allow hasmethod() and hasfield type patterns in\n\ +\t declare parents and declare @type\n ## options not documented above (per ..ajdt.ajc.BuildArgParser.java): # -XincrementalFile, -XjavadocsInModel diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java index f9fa4787f..26cc3fe25 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java @@ -477,6 +477,14 @@ public class AjBuildConfig { options.xReweavable = b; } + public void setXHasMemberSupport(boolean enabled) { + options.xHasMember = enabled; + } + + public boolean isXHasMemberEnabled() { + return options.xHasMember; + } + public boolean isXreweavable() { return options.xReweavable; } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 1289922d5..d88b97f17 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -536,6 +536,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc bcelWorld.setBehaveInJava5Way(buildConfig.getBehaveInJava5Way()); bcelWorld.setXnoInline(buildConfig.isXnoInline()); bcelWorld.setXlazyTjp(buildConfig.isXlazyTjp()); + bcelWorld.setXHasMemberSupportEnabled(buildConfig.isXHasMemberEnabled()); BcelWeaver bcelWeaver = new BcelWeaver(bcelWorld); state.setWorld(bcelWorld); state.setWeaver(bcelWeaver); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java index 3fc7138d5..8c13e00b1 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java @@ -42,6 +42,7 @@ public class AjCompilerOptions extends CompilerOptions { public static final String OPTION_XNoInline = "org.aspectj.ajdt.core.compiler.weaver.XNoInline"; public static final String OPTION_XReweavable = "org.aspectj.ajdt.core.compiler.weaver.XReweavable"; public static final String OPTION_XReweavableCompress = "org.aspectj.ajdt.core.compiler.weaver.XReweavableCompress"; + public static final String OPTION_XHasMember = "org.aspectj.ajdt.core.compiler.weaver.XHasMember"; // these next four not exposed by IDEs public static final String OPTION_XDevNoAtAspectJProcessing = "org.aspectj.ajdt.core.compiler.ast.NoAtAspectJProcessing"; @@ -66,6 +67,7 @@ public class AjCompilerOptions extends CompilerOptions { public boolean xNoInline = false; public boolean xReweavable = false; public boolean xReweavableCompress = false; + public boolean xHasMember = false; public boolean showWeavingInformation = false; // If true - autoboxing behaves differently ... @@ -119,6 +121,7 @@ public class AjCompilerOptions extends CompilerOptions { map.put(OPTION_XNoInline,this.xNoInline ? ENABLED : DISABLED); map.put(OPTION_XReweavable,this.xReweavable ? ENABLED : DISABLED); map.put(OPTION_XReweavableCompress,this.xReweavableCompress ? ENABLED : DISABLED); + map.put(OPTION_XHasMember, this.xHasMember ? ENABLED : DISABLED); map.put(OPTION_GenerateModel,this.generateModel ? ENABLED : DISABLED); map.put(OPTION_GenerateJavaDocsInModel,this.generateJavaDocsInModel ? ENABLED : DISABLED); @@ -186,6 +189,13 @@ public class AjCompilerOptions extends CompilerOptions { this.xReweavableCompress = false; } } + if ((optionValue = optionsMap.get(OPTION_XHasMember)) != null) { + if (ENABLED.equals(optionValue)) { + this.xHasMember = true; + } else if (DISABLED.equals(optionValue)) { + this.xHasMember = false; + } + } if ((optionValue = optionsMap.get(OPTION_GenerateModel)) != null) { if (ENABLED.equals(optionValue)) { @@ -244,6 +254,7 @@ public class AjCompilerOptions extends CompilerOptions { buf.append("\n\t- lazy thisJoinPoint (X option): ").append(this.xLazyThisJoinPoint ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- generate reweavable class files (X option): ").append(this.xReweavable ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- compress reweavable class files (X option): ").append(this.xReweavableCompress ? ENABLED : DISABLED); //$NON-NLS-1$ + buf.append("\n\t- has member support (X option): ").append(this.xHasMember ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- generate AJDE model: ").append(this.generateModel ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- generate Javadocs in AJDE model: ").append(this.generateJavaDocsInModel ? ENABLED : DISABLED); //$NON-NLS-1$ diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java index 5ee6e0138..8198012b0 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java @@ -158,6 +158,7 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto myBcelWorld.setBehaveInJava5Way(options.behaveInJava5Way); myBcelWorld.setXnoInline(options.xNoInline); myBcelWorld.setXlazyTjp(options.xLazyThisJoinPoint); + myBcelWorld.setXHasMemberSupportEnabled(options.xHasMember); setLintProperties(myBcelWorld,options); myWeaver = new BcelWeaver(myBcelWorld); myWeaver.setReweavableMode(options.xReweavable,options.xReweavableCompress); diff --git a/weaver/src/org/aspectj/weaver/WeaverMessages.java b/weaver/src/org/aspectj/weaver/WeaverMessages.java index 4bee39a7d..689e2c7d8 100644 --- a/weaver/src/org/aspectj/weaver/WeaverMessages.java +++ b/weaver/src/org/aspectj/weaver/WeaverMessages.java @@ -145,6 +145,8 @@ public class WeaverMessages { public static final String CALL_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES="noParameterizedDeclaringTypesInCall"; public static final String CANT_REFERENCE_POINTCUT_IN_RAW_TYPE="noRawTypePointcutReferences"; + public static final String HAS_MEMBER_NOT_ENABLED="hasMemberNotEnabled"; + public static String format(String key) { return bundle.getString(key); } diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index 50f0469cc..1eb94be61 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -66,6 +66,9 @@ public abstract class World implements Dump.INode { /** XlazyTjp option setting passed down to weaver */ private boolean XlazyTjp; + /** XhasMember option setting passed down to weaver */ + private boolean XhasMember = false; + /** When behaving in a Java 5 way autoboxing is considered */ private boolean behaveInJava5Way = false; @@ -573,6 +576,14 @@ public abstract class World implements Dump.INode { public void setXlazyTjp(boolean b) { XlazyTjp = b; } + + public boolean isHasMemberSupportEnabled() { + return XhasMember; + } + + public void setXHasMemberSupportEnabled(boolean b) { + XhasMember = b; + } public void setBehaveInJava5Way(boolean b) { behaveInJava5Way = b; diff --git a/weaver/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java index ef1d9274d..b756a6008 100644 --- a/weaver/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java @@ -17,12 +17,16 @@ import java.lang.reflect.Modifier; import java.util.Iterator; import java.util.List; import java.util.Map; + +import org.aspectj.bridge.IMessage; +import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.Member; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; +import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; /** @@ -109,6 +113,15 @@ public class HasMemberTypePattern extends TypePattern { return ret; } + public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) { + // check that hasmember type patterns are allowed! + if (!scope.getWorld().isHasMemberSupportEnabled()) { + String msg = WeaverMessages.format(WeaverMessages.HAS_MEMBER_NOT_ENABLED,this.toString()); + scope.message(IMessage.ERROR, this, msg); + } + return this; + } + public boolean equals(Object obj) { if (!(obj instanceof HasMemberTypePattern)) return false; if (this == obj) return true; diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java index 63dcd0095..8bd7ccb4b 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java @@ -29,7 +29,6 @@ public class PatternParser { private ITokenSource tokenSource; private ISourceContext sourceContext; - private static final boolean HASMEMBER_PATTERNS_ENABLED = false; /** not thread-safe, but this class is not intended to be... */ private boolean allowHasTypePatterns = false; @@ -158,7 +157,7 @@ public class PatternParser { } public DeclareAnnotation parseDeclareAtType() { - if (HASMEMBER_PATTERNS_ENABLED) allowHasTypePatterns = true; + allowHasTypePatterns = true; TypePattern p = parseTypePattern(); allowHasTypePatterns = false; return new DeclareAnnotation(DeclareAnnotation.AT_TYPE,p); @@ -196,7 +195,7 @@ public class PatternParser { * String[] typeParameters = maybeParseSimpleTypeVariableList(); */ eat(":"); - if (HASMEMBER_PATTERNS_ENABLED) allowHasTypePatterns = true; + allowHasTypePatterns = true; TypePattern p = parseTypePattern(false); allowHasTypePatterns = false; IToken t = tokenSource.next(); diff --git a/weaver/src/org/aspectj/weaver/weaver-messages.properties b/weaver/src/org/aspectj/weaver/weaver-messages.properties index af95e1e38..7d8ab738e 100644 --- a/weaver/src/org/aspectj/weaver/weaver-messages.properties +++ b/weaver/src/org/aspectj/weaver/weaver-messages.properties @@ -154,4 +154,6 @@ noGenericThrowables=invalid throws pattern: a generic class may not be a direct noParameterizedDeclaringTypesWithinCode=can't use parameterized type patterns for the declaring type of a withincode pointcut expression (use the raw type instead) noParameterizedDeclaringTypesInExecution=can't use parameterized type patterns for the declaring type of an execution pointcut expression (use the raw type instead) noParameterizedDeclaringTypesInCall=can't use parameterized type patterns for the declaring type of a call pointcut expression (use the raw type instead) -noRawTypePointcutReferences=cannot use a raw type reference to refer to a pointcut in a generic type (use a parameterized reference instead)
\ No newline at end of file +noRawTypePointcutReferences=cannot use a raw type reference to refer to a pointcut in a generic type (use a parameterized reference instead) + +hasMemberNotEnabled=the type pattern {0} can only be used when the -XhasMember option is set
\ No newline at end of file |