]> source.dussan.org Git - aspectj.git/commitdiff
Moved all weaver messages into weaver-messages.properties.
authoracolyer <acolyer>
Thu, 29 Jul 2004 15:04:00 +0000 (15:04 +0000)
committeracolyer <acolyer>
Thu, 29 Jul 2004 15:04:00 +0000 (15:04 +0000)
Includes fixes for Bugzilla Bug 30439
  spurious "circular dependency" error

27 files changed:
weaver/src/org/aspectj/weaver/Advice.java
weaver/src/org/aspectj/weaver/Lint.java
weaver/src/org/aspectj/weaver/NewConstructorTypeMunger.java
weaver/src/org/aspectj/weaver/ResolvedTypeX.java
weaver/src/org/aspectj/weaver/Shadow.java
weaver/src/org/aspectj/weaver/WeaverMessages.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/WeaverStateInfo.java
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java
weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java
weaver/src/org/aspectj/weaver/patterns/DeclareParents.java
weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java
weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java
weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java
weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java
weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
weaver/src/org/aspectj/weaver/patterns/TypePattern.java
weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
weaver/src/org/aspectj/weaver/weaver-messages.properties [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/BcweaverTests.java
weaver/testsrc/org/aspectj/weaver/WeaverMessagesTestCase.java [new file with mode: 0644]

index 4e76e2e28f814be0d850d87d91e13ae6e3bd3aeb..9a6e57c10a46969139d4e197ff17aa1568c72909 100644 (file)
@@ -92,8 +92,8 @@ public abstract class Advice extends ShadowMunger {
                        if (shadow.getKind() == Shadow.ExceptionHandler) {
                                if (kind.isAfter() || kind == AdviceKind.Around) {
                                        world.showMessage(IMessage.WARNING,
-                                       "Only before advice is supported on handler join points (compiler limitation)", 
-                                       getSourceLocation(), shadow.getSourceLocation());
+                                                       WeaverMessages.format(WeaverMessages.ONLY_BEFORE_ON_HANDLER),
+                                                       getSourceLocation(), shadow.getSourceLocation());
                                        return false;
                                }
                        }
@@ -108,29 +108,27 @@ public abstract class Advice extends ShadowMunger {
                } else if (kind == AdviceKind.Around) {
                        if (shadow.getKind() == Shadow.PreInitialization) {
                                world.showMessage(IMessage.ERROR,
-                                       "around on pre-initialization not supported (compiler limitation)", 
-                                       getSourceLocation(), shadow.getSourceLocation());
+                                               WeaverMessages.format(WeaverMessages.AROUND_ON_PREINIT),
+                                                       getSourceLocation(), shadow.getSourceLocation());
                                        return false;
                                } else if (shadow.getKind() == Shadow.Initialization) {
                                        world.showMessage(IMessage.ERROR,
-                                               "around on initialization not supported (compiler limitation)", 
-                                               getSourceLocation(), shadow.getSourceLocation());
+                                                       WeaverMessages.format(WeaverMessages.AROUND_ON_INIT),
+                                                       getSourceLocation(), shadow.getSourceLocation());
                                        return false;
                                } else if (shadow.getKind() == Shadow.StaticInitialization && 
                                                        shadow.getEnclosingType().isInterface(world))
                                {
                                        world.showMessage(IMessage.ERROR,
-                                               "around on staticinitialization of interface \'" + 
-                                               shadow.getEnclosingType().getName() +
-                                               "\' not supported (compiler limitation)", 
-                                               getSourceLocation(), shadow.getSourceLocation());
+                                                       WeaverMessages.format(WeaverMessages.AROUND_ON_INTERFACE_STATICINIT,shadow.getEnclosingType().getName()),
+                                                       getSourceLocation(), shadow.getSourceLocation());
                                        return false;
                        } else {
                                //System.err.println(getSignature().getReturnType() + " from " + shadow.getReturnType());
                                if (getSignature().getReturnType() == ResolvedTypeX.VOID) {
                                        if (shadow.getReturnType() != ResolvedTypeX.VOID) {
                                                world.showMessage(IMessage.ERROR, 
-                                                       "applying to join point that doesn't return void: " + shadow,
+                                                       WeaverMessages.format(WeaverMessages.NON_VOID_RETURN,shadow),   
                                                        getSourceLocation(), shadow.getSourceLocation());
                                                return false;
                                        }
@@ -138,8 +136,8 @@ public abstract class Advice extends ShadowMunger {
                                        return true;
                                } else if(!shadow.getReturnType().isAssignableFrom(getSignature().getReturnType(), world)) {
                                        //System.err.println(this + ", " + sourceContext + ", " + start);
-                                               world.showMessage(IMessage.ERROR, 
-                                                               "incompatible return type applying to " + shadow,
+                                               world.showMessage(IMessage.ERROR,
+                                                               WeaverMessages.format(WeaverMessages.INCOMPATIBLE_RETURN_TYPE,shadow),
                                                                getSourceLocation(), shadow.getSourceLocation());
                                        return false;
                                }
index 9e02bf7ae3ffcc0790dddaac5a067cab71d89939..248ad0d579d38603284f19edc36f63a708e1882c 100644 (file)
@@ -83,22 +83,23 @@ public class Lint {
                        InputStream s = new FileInputStream(file);
                        setFromProperties(s);
                } catch (IOException ioe) {
-                       MessageUtil.error(world.getMessageHandler(), "problem loading Xlint properties file: " + 
-                                       file.getPath() + ", " + ioe.getMessage());
+                       MessageUtil.error(world.getMessageHandler(),
+                                       WeaverMessages.format(WeaverMessages.XLINT_LOAD_ERROR,file.getPath(),ioe.getMessage()));
                }
        }
 
        public void loadDefaultProperties() {
                InputStream s = getClass().getResourceAsStream("XlintDefault.properties");
                if (s == null) {
-                       MessageUtil.warn(world.getMessageHandler(), "couldn't load XlintDefault.properties");
+                       MessageUtil.warn(world.getMessageHandler(), 
+                                       WeaverMessages.format(WeaverMessages.XLINTDEFAULT_LOAD_ERROR));
                        return;
                }
                try {
                        setFromProperties(s);
                } catch (IOException ioe) {
-                       MessageUtil.error(world.getMessageHandler(), "problem loading XlintDefault.properties, " +
-                                       ioe.getMessage());
+                       MessageUtil.error(world.getMessageHandler(),
+                                       WeaverMessages.format(WeaverMessages.XLINTDEFAULT_LOAD_PROBLEM,ioe.getMessage()));
                }
 
        }
@@ -116,7 +117,8 @@ public class Lint {
                        Map.Entry entry = (Map.Entry)i.next();
                        Kind kind = (Kind)kinds.get(entry.getKey());
                        if (kind == null) {
-                               MessageUtil.error(world.getMessageHandler(), "invalid Xlint key: " + entry.getKey());
+                               MessageUtil.error(world.getMessageHandler(),
+                                               WeaverMessages.format(WeaverMessages.XLINT_KEY_ERROR,entry.getKey()));
                        } else {
                                kind.setKind(getMessageKind((String)entry.getValue()));
                        }
@@ -129,7 +131,7 @@ public class Lint {
                else if (v.equals("error")) return IMessage.ERROR;
                
                MessageUtil.error(world.getMessageHandler(), 
-                       "invalid Xlint message kind (must be one of ignore, warning, error): " + v);
+                               WeaverMessages.format(WeaverMessages.XLINT_VALUE_ERROR,v));
                return null;
        }
        
index ae62a630e8cc99ffb8b1c78992ad2d657f5ec79a..0f4ac0fb735e66d95a2849e856be8bfa6f956182 100644 (file)
@@ -79,8 +79,9 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger {
        
        public void check(World world) {
                if (getSignature().getDeclaringType().isAspect(world)) {
-                       world.showMessage(IMessage.ERROR, "can't declare constructor on an aspect",
-                                               getSignature().getSourceLocation(), null);
+                       world.showMessage(IMessage.ERROR, 
+                                       WeaverMessages.format(WeaverMessages.ITD_CONS_ON_ASPECT),
+                                       getSignature().getSourceLocation(), null);
                }
        }
 
index 2779f7cdd8a5fd4f9f25981afa6f21e2736263c0..a51736ce40a9fd3bcbfd224ecab96a16296b6758 100644 (file)
@@ -1135,9 +1135,9 @@ public abstract class ResolvedTypeX extends TypeX {
                                        } else {
                                                //XXX dual errors possible if (this instanceof BcelObjectType) return false;  //XXX ignores separate comp
                                                getWorld().getMessageHandler().handleMessage(
-                                                       MessageUtil.error("inter-type declaration from " + munger.getAspectType().getName() +
-                                                                                       " conflicts with existing member: " + existingMember,
-                                                                                       munger.getSourceLocation())
+                                                       MessageUtil.error(WeaverMessages.format(WeaverMessages.ITD_MEMBER_CONFLICT,munger.getAspectType().getName(),
+                                                                       existingMember),
+                                                       munger.getSourceLocation())
                                                );
                                        }
                                } else {
@@ -1153,9 +1153,8 @@ public abstract class ResolvedTypeX extends TypeX {
                //System.err.println("check: " + child.getDeclaringType() + " overrides " + parent.getDeclaringType());
                if (!parent.getReturnType().equals(child.getReturnType())) {
                        world.showMessage(IMessage.ERROR,
-                               "can't override " + parent +
-                               " with " + child + " return types don't match",
-                               child.getSourceLocation(), parent.getSourceLocation());
+                                       WeaverMessages.format(WeaverMessages.ITD_RETURN_TYPE_MISMATCH,parent,child),
+                                       child.getSourceLocation(), parent.getSourceLocation());
                        return false;
                }               
                if (parent.getKind() == Member.POINTCUT) {
@@ -1163,18 +1162,16 @@ public abstract class ResolvedTypeX extends TypeX {
                        TypeX[] cTypes = child.getParameterTypes();
                        if (!Arrays.equals(pTypes, cTypes)) {
                                world.showMessage(IMessage.ERROR,
-                                       "can't override " + parent +
-                                       " with " + child + " parameter types don't match",
-                                       child.getSourceLocation(), parent.getSourceLocation());
+                                               WeaverMessages.format(WeaverMessages.ITD_PARAM_TYPE_MISMATCH,parent,child),
+                                               child.getSourceLocation(), parent.getSourceLocation());
                                return false;
                        }
                }               
                //System.err.println("check: " + child.getModifiers() + " more visible " + parent.getModifiers());
                if (isMoreVisible(parent.getModifiers(), child.getModifiers())) {
                        world.showMessage(IMessage.ERROR,
-                               "can't override " + parent +
-                               " with " + child + " visibility is reduced",
-                               child.getSourceLocation(), parent.getSourceLocation());
+                                       WeaverMessages.format(WeaverMessages.ITD_VISIBILITY_REDUCTION,parent,child),
+                                       child.getSourceLocation(), parent.getSourceLocation());
                        return false;
                }
                
@@ -1193,19 +1190,20 @@ public abstract class ResolvedTypeX extends TypeX {
                                if (parentExceptions[j].isAssignableFrom(childExceptions[i])) continue outer;
                        }
                        
-                       world.showMessage(IMessage.ERROR, "overriden method doesn't throw " 
-                                       + childExceptions[i].getName(), child.getSourceLocation(), null);
+                       world.showMessage(IMessage.ERROR,
+                                       WeaverMessages.format(WeaverMessages.ITD_DOESNT_THROW,childExceptions[i].getName()),
+                                       child.getSourceLocation(), null);
                                                
                        return false;
                }
                if (parent.isStatic() && !child.isStatic()) {
                        world.showMessage(IMessage.ERROR,
-                         child.toString()+" cannot override "+parent.toString()+"; overridden method is static",
-                         child.getSourceLocation(),null);
+                                       WeaverMessages.format(WeaverMessages.ITD_OVERRIDDEN_STATIC,child,parent),
+                                       child.getSourceLocation(),null);
                } else if (child.isStatic() && !parent.isStatic()) {
                        world.showMessage(IMessage.ERROR,
-                         child.toString()+" cannot override "+parent.toString()+"; overriding method is static",
-                         child.getSourceLocation(),null);
+                                       WeaverMessages.format(WeaverMessages.ITD_OVERIDDING_STATIC,child,parent),
+                                       child.getSourceLocation(),null);
                }
                return true;
                
@@ -1252,13 +1250,9 @@ public abstract class ResolvedTypeX extends TypeX {
                
                //System.err.println("conflict at " + m2.getSourceLocation());
                getWorld().showMessage(IMessage.ERROR,
-                       "intertype declaration from "
-                               + m1.getAspectType().getName()
-                               + " conflicts with intertype declaration: "
-                               + m2.getSignature()
-                               + " from "
-                               + m2.getAspectType().getName(),
-                       m2.getSourceLocation(), getSourceLocation());
+                               WeaverMessages.format(WeaverMessages.ITD_CONFLICT,m1.getAspectType().getName(),
+                                                                       m2.getSignature(),m2.getAspectType().getName()),
+                                               m2.getSourceLocation(), getSourceLocation());
        }
        
        
@@ -1308,9 +1302,8 @@ public abstract class ResolvedTypeX extends TypeX {
                        if (inherited.isAbstract()) {
                                if (!this.isAbstract()) {
                                        getWorld().showMessage(IMessage.ERROR,
-                                               "inherited abstract " + inherited + 
-                                               " is not made concrete in " + this.getName(),
-                                               inherited.getSourceLocation(), this.getSourceLocation());
+                                                       WeaverMessages.format(WeaverMessages.POINCUT_NOT_CONCRETE,inherited,this.getName()),
+                                                       inherited.getSourceLocation(), this.getSourceLocation());
                                }
                        }
                }               
@@ -1340,8 +1333,7 @@ public abstract class ResolvedTypeX extends TypeX {
                                        } else {
                                                getWorld().showMessage(
                                                        IMessage.ERROR,
-                                                       "conflicting inherited pointcuts in "
-                                                               + this.getName() + toAdd.getSignature(),
+                                                       WeaverMessages.format(WeaverMessages.CONFLICTING_INHERITED_POINTCUTS,this.getName() + toAdd.getSignature()),
                                                        existing.getSourceLocation(),
                                                        toAdd.getSourceLocation());
                                                j.remove();
index cd21801c7b2bce8cf6b69846a57222c5d30537c5..42e2920e4cf0476ca5f00df45636df73e6946f53 100644 (file)
@@ -294,9 +294,9 @@ public abstract class Shadow {
                }
                
                if (!isDeclaredException(resolvedTypeX, getSignature())) {
-                       getIWorld().showMessage(IMessage.ERROR, "can't throw checked exception \'" + resolvedTypeX +
-                                                       "\' at this join point \'" + this +"\'", // from advice in \'" + munger. + "\'",
-                                                       getSourceLocation(), munger.getSourceLocation());
+                       getIWorld().showMessage(IMessage.ERROR,
+                                       WeaverMessages.format(WeaverMessages.CANT_THROW_CHECKED,resolvedTypeX,this), // from advice in \'" + munger. + "\'",
+                                       getSourceLocation(), munger.getSourceLocation());
                }
                
                return true;
@@ -332,7 +332,8 @@ public abstract class Shadow {
                        for (Iterator i = mungers.iterator(); i.hasNext(); ) {
                                ShadowMunger m = (ShadowMunger)i.next();
                                getIWorld().getMessageHandler().handleMessage(
-                                       MessageUtil.error("circular advice dependency at " + this, m.getSourceLocation()));
+                                       MessageUtil.error(
+                                                       WeaverMessages.format(WeaverMessages.CIRCULAR_DEPENDENCY,this), m.getSourceLocation()));
                        }
                }
                mungers = sorted;
diff --git a/weaver/src/org/aspectj/weaver/WeaverMessages.java b/weaver/src/org/aspectj/weaver/WeaverMessages.java
new file mode 100644 (file)
index 0000000..f04e6a8
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+
+public class WeaverMessages {
+       
+       private static ResourceBundle bundle = ResourceBundle.getBundle("org.aspectj.weaver.weaver-messages");
+
+       public static final String ARGS_IN_DECLARE = "argsInDeclare";
+       public static final String CFLOW_IN_DECLARE = "cflowInDeclare";
+       public static final String IF_IN_DECLARE = "ifInDeclare";
+       public static final String THIS_OR_TARGET_IN_DECLARE = "thisOrTargetInDeclare";
+       public static final String ABSTRACT_POINTCUT = "abstractPointcut";
+       public static final String POINCUT_NOT_CONCRETE = "abstractPointcutNotMadeConcrete";
+       public static final String CONFLICTING_INHERITED_POINTCUTS = "conflictingInheritedPointcuts";
+       public static final String CIRCULAR_POINTCUT = "circularPointcutDeclaration";
+       public static final String CANT_FIND_POINTCUT = "cantFindPointcut";
+       public static final String EXACT_TYPE_PATTERN_REQD = "exactTypePatternRequired";
+       public static final String CANT_BIND_TYPE = "cantBindType";
+       public static final String WILDCARD_NOT_ALLOWED = "wildcardTypePatternNotAllowed";
+       
+       public static final String DECP_OBJECT = "decpObject";
+       public static final String CANT_EXTEND_SELF="cantExtendSelf";
+       public static final String INTERFACE_CANT_EXTEND_CLASS="interfaceExtendClass";
+       public static final String DECP_HIERARCHY_ERROR = "decpHierarchy";
+       
+       public static final String MULTIPLE_MATCHES_IN_PRECEDENCE = "multipleMatchesInPrecedence";
+       public static final String TWO_STARS_IN_PRECEDENCE = "circularityInPrecedenceStar";
+       public static final String CLASSES_IN_PRECEDENCE = "nonAspectTypesInPrecedence";
+       public static final String TWO_PATTERN_MATCHES_IN_PRECEDENCE = "circularityInPrecedenceTwo";
+       
+       public static final String NOT_THROWABLE = "notThrowable";
+       
+       public static final String ITD_CONS_ON_ASPECT = "itdConsOnAspect";
+       public static final String ITD_RETURN_TYPE_MISMATCH = "returnTypeMismatch";
+       public static final String ITD_PARAM_TYPE_MISMATCH = "paramTypeMismatch";
+       public static final String ITD_VISIBILITY_REDUCTION = "visibilityReduction";
+       public static final String ITD_DOESNT_THROW = "doesntThrow";
+       public static final String ITD_OVERRIDDEN_STATIC = "overriddenStatic";
+       public static final String ITD_OVERIDDING_STATIC = "overridingStatic";
+       public static final String ITD_CONFLICT = "itdConflict";
+       public static final String ITD_MEMBER_CONFLICT = "itdMemberConflict";
+       
+       
+       public static final String NON_VOID_RETURN = "nonVoidReturn";
+       public static final String INCOMPATIBLE_RETURN_TYPE="incompatibleReturnType";
+       public static final String CANT_THROW_CHECKED = "cantThrowChecked";
+       public static final String CIRCULAR_DEPENDENCY = "circularDependency";
+       
+       public static final String MISSING_PER_CLAUSE = "missingPerClause";
+       public static final String WRONG_PER_CLAUSE = "wrongPerClause";
+       
+       public static final String ALREADY_WOVEN = "alreadyWoven";
+       public static final String REWEAVABLE_MODE = "reweavableMode";
+       public static final String PROCESSING_REWEAVABLE = "processingReweavable";
+       public static final String MISSING_REWEAVABLE_TYPE = "missingReweavableType";
+       public static final String VERIFIED_REWEAVABLE_TYPE = "verifiedReweavableType";
+       public static final String ASPECT_NEEDED = "aspectNeeded";
+       
+       public static final String CANT_FIND_TYPE = "cantFindType";
+       
+       public static final String DECP_BINARY_LIMITATION = "decpBinaryLimitation";
+       public static final String OVERWRITE_JSR45 = "overwriteJSR45";
+       public static final String IF_IN_PERCLAUSE = "ifInPerClause";
+       public static final String IF_LEXICALLY_IN_CFLOW = "ifLexicallyInCflow";
+       public static final String ONLY_BEFORE_ON_HANDLER = "onlyBeforeOnHandler";
+       public static final String AROUND_ON_PREINIT = "aroundOnPreInit";
+       public static final String AROUND_ON_INIT = "aroundOnInit";
+       public static final String AROUND_ON_INTERFACE_STATICINIT = "aroundOnInterfaceStaticInit";
+       
+       public static final String PROBLEM_GENERATING_METHOD = "problemGeneratingMethod";
+       
+       public static final String ZIPFILE_ENTRY_MISSING = "zipfileEntryMissing";
+       public static final String ZIPFILE_ENTRY_INVALID = "zipfileEntryInvalid";
+       public static final String DIRECTORY_ENTRY_MISSING = "directoryEntryMissing";
+       
+       public static final String XLINT_LOAD_ERROR = "problemLoadingXLint";
+       public static final String XLINTDEFAULT_LOAD_ERROR = "unableToLoadXLintDefault";
+       public static final String XLINTDEFAULT_LOAD_PROBLEM = "errorLoadingXLintDefault";
+       public static final String XLINT_KEY_ERROR = "invalidXLintKey";
+       public static final String XLINT_VALUE_ERROR = "invalidXLintMessageKind";
+       
+       
+       public static String format(String key) {
+               return bundle.getString(key);
+       }
+       
+       public static String format(String key, Object insert) {
+               return MessageFormat.format(bundle.getString(key),new Object[] {insert});
+       }
+
+       public static String format(String key, Object insert1, Object insert2) {
+               return MessageFormat.format(bundle.getString(key),new Object[] {insert1,insert2});
+       }
+
+       public static String format(String key, Object insert1, Object insert2, Object insert3) {
+               return MessageFormat.format(bundle.getString(key),new Object[] {insert1, insert2, insert3});
+       }
+
+}
index 127bb3ee9fe42e994f25bacb1acb6173ee3c2322..4b1a1a7b69ee503033f11e7427d994971884a837 100644 (file)
@@ -162,8 +162,8 @@ public class WeaverStateInfo {
                        Entry entry = (Entry) i.next();
                        ResolvedTypeX aspectType = world.resolve(entry.aspectType, true);
                        if (aspectType == ResolvedTypeX.MISSING) {
-                               world.showMessage(IMessage.ERROR, "aspect " + entry.aspectType + 
-                                       " is needed when using type " + onType,
+                               world.showMessage(IMessage.ERROR,
+                                       WeaverMessages.format(WeaverMessages.ASPECT_NEEDED,entry.aspectType,onType),
                                        onType.getSourceLocation(), null);
                                continue;
                        }
index 6da90ebcae09ef8152a3a0b4e2fd2ad5507dacf9..90fde53206b2fa9ea2ffc2b03dc4b72b41bb5d70 100644 (file)
@@ -82,7 +82,8 @@ public abstract class World {
             ret = resolveObjectType(ty);
             if (!allowMissing && ret == ResolvedTypeX.MISSING) {
                //Thread.currentThread().dumpStack();
-                MessageUtil.error(messageHandler, "can't find type " + ty.getName());
+                MessageUtil.error(messageHandler, 
+                               WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,ty.getName()));
                 // + " on classpath " + classPath);
             }
         }
index 2a487d008f7e0bf501ccea99aaf70c802c8e7db9..ad561a98e378e4fc0970d3d71d082b08fc313029 100644 (file)
@@ -62,6 +62,7 @@ import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.ShadowMunger;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.WeaverStateInfo;
 import org.aspectj.weaver.Shadow.Kind;
 import org.aspectj.weaver.patterns.FastMatchInfo;
@@ -288,7 +289,7 @@ class BcelClassWeaver implements IClassWeaver {
 
         if (clazz.isWoven() && !clazz.isReweavable()) {
                world.showMessage(IMessage.ERROR, 
-                               "class \'" + clazz.getType().getName() + "\' is already woven and has not been built with -Xreweavable",
+                         WeaverMessages.format(WeaverMessages.ALREADY_WOVEN,clazz.getType().getName()),
                                ty.getSourceLocation(), null);
                return false;
         }
index 465bbcb278c69d951e355cd953b05c0ec5e04dd7..6fd891ca685878e131bfaadecf44aac5fdaf5c4d 100644 (file)
@@ -54,6 +54,7 @@ import org.aspectj.weaver.ResolvedTypeMunger;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.ShadowMunger;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.WeaverStateInfo;
 import org.aspectj.weaver.patterns.DeclareParents;
 import org.aspectj.weaver.patterns.FastMatchInfo;
@@ -574,7 +575,9 @@ public class BcelWeaver implements IWeaver {
     
     public void prepareToProcessReweavableState() {
                if (inReweavableMode)
-                       world.showMessage(IMessage.INFO, "weaver operating in reweavable mode.  Need to verify any required types exist.", null, null);
+                       world.showMessage(IMessage.INFO,
+                                       WeaverMessages.format(WeaverMessages.REWEAVABLE_MODE),
+                                       null, null);
                        
        alreadyConfirmedReweavableState = new HashSet();
     }
@@ -583,7 +586,9 @@ public class BcelWeaver implements IWeaver {
                // If the class is marked reweavable, check any aspects around when it was built are in this world
                WeaverStateInfo wsi = classType.getWeaverState();               
                if (wsi!=null && wsi.isReweavable()) { // Check all necessary types are around!
-                       world.showMessage(IMessage.INFO,"processing reweavable type "+className+": "+classType.getSourceLocation().getSourceFile(),null,null);
+                       world.showMessage(IMessage.INFO,
+                                       WeaverMessages.format(WeaverMessages.PROCESSING_REWEAVABLE,className,classType.getSourceLocation().getSourceFile()),
+                                       null,null);
                        Set aspectsPreviouslyInWorld = wsi.getAspectsAffectingType();
                        if (aspectsPreviouslyInWorld!=null) {
                                for (Iterator iter = aspectsPreviouslyInWorld.iterator(); iter.hasNext();) {
@@ -592,13 +597,14 @@ public class BcelWeaver implements IWeaver {
                                                ResolvedTypeX rtx = world.resolve(TypeX.forName(requiredTypeName),true);
                                                boolean exists = rtx!=ResolvedTypeX.MISSING;
                                                if (!exists) {
-                                                       world.showMessage(IMessage.ERROR, "type " + requiredTypeName + 
-                                                               " is needed by reweavable type " + className,
-                                                               classType.getSourceLocation(), null);
+                                                       world.showMessage(IMessage.ERROR, 
+                                                                       WeaverMessages.format(WeaverMessages.MISSING_REWEAVABLE_TYPE,requiredTypeName,className),
+                                                                   classType.getSourceLocation(), null);
                                                } else {
                                                        if (!world.getMessageHandler().isIgnoring(IMessage.INFO))
-                                                         world.showMessage(IMessage.INFO,"successfully verified type "+requiredTypeName+
-                                       " exists.  Originates from "+rtx.getSourceLocation().getSourceFile(),null,null);
+                                                         world.showMessage(IMessage.INFO,
+                                                                       WeaverMessages.format(WeaverMessages.VERIFIED_REWEAVABLE_TYPE,requiredTypeName,rtx.getSourceLocation().getSourceFile()),
+                                                                       null,null);
                                                        alreadyConfirmedReweavableState.add(requiredTypeName);
                                                }
                                        }               
@@ -662,9 +668,8 @@ public class BcelWeaver implements IWeaver {
                                        ResolvedTypeX newParent = (ResolvedTypeX)j.next();
                                        if (newParent.isClass()) {
                                                world.showMessage(IMessage.ERROR,
-                                                       "can't use declare parents to change superclass of binary form \'" +
-                                                       onType.getName() + "\' (implementation limitation)",
-                                                       p.getSourceLocation(), null);
+                                                               WeaverMessages.format(WeaverMessages.DECP_BINARY_LIMITATION,onType.getName()),
+                                                               p.getSourceLocation(), null);
                                                continue;
                                        }
                                        
index ab392175885ec681d3caab0b949a92b745e02cac..acd8d9b1d2551c54dce9a3051b32c1e870f25675 100644 (file)
@@ -27,6 +27,7 @@ import java.util.zip.ZipFile;
 import org.aspectj.bridge.IMessageHandler;
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 
 
 public class ClassPathManager {
@@ -48,18 +49,18 @@ public class ClassPathManager {
                String lc = name.toLowerCase();
                if (lc.endsWith(".jar") || lc.endsWith(".zip")) {
                        if (!f.isFile()) {
-                       MessageUtil.info(handler, "zipfile classpath entry does not exist: " + name);
+                       MessageUtil.info(handler, WeaverMessages.format(WeaverMessages.ZIPFILE_ENTRY_MISSING,name));
                        return;
                        }
                        try {
                                entries.add(new ZipFileEntry(f));
                        } catch (IOException ioe) {
-                       MessageUtil.warn(handler, "zipfile classpath entry is invalid: " + name + "<" + ioe.getMessage() + ">");
+                       MessageUtil.warn(handler, WeaverMessages.format(WeaverMessages.ZIPFILE_ENTRY_INVALID,name,ioe.getMessage()));
                        return;
                        }
                } else {
                        if (!f.isDirectory()) {
-                       MessageUtil.info(handler, "directory classpath entry does not exist: " + name);
+                       MessageUtil.info(handler, WeaverMessages.format(WeaverMessages.DIRECTORY_ENTRY_MISSING,name));
                        return;
                        }
                        entries.add(new DirEntry(f));
index 67b00ebf8bc1c5f1b0523e60d6eda1e30959adf3..b25d10aa6c48580c9aabf32f29a487145c3af543 100644 (file)
@@ -58,6 +58,7 @@ import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.WeaverStateInfo;
 import org.aspectj.weaver.World;
 
@@ -398,9 +399,7 @@ public final class LazyClassGen {
                        if (hasSourceDebugExtensionAttribute(myGen)) {
                                world.showMessage(
                                        IMessage.WARNING,
-                                       "overwriting JSR45 information for "
-                                               + getFileName()
-                                               + " (compiler limitation)",
+                                       WeaverMessages.format(WeaverMessages.OVERWRITE_JSR45,getFileName()),
                                        null,
                                        null);
                        }
index f6ce64db5de7bc6053a157e9fc5adac2d165bd3f..8cc7a1665f11a030d2c3525f3526013f3ff75e97 100644 (file)
@@ -54,6 +54,7 @@ import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.Member;
 import org.aspectj.weaver.ResolvedTypeX;
+import org.aspectj.weaver.WeaverMessages;
 
 
 /** 
@@ -324,8 +325,11 @@ public final class LazyMethodGen {
                        return gen.getMethod();
        } catch (ClassGenException e) {
                enclosingClass.getBcelObjectType().getResolvedTypeX().getWorld().showMessage(
-                       IMessage.ERROR, "problem generating method " + 
-                       this.getClassName() + "." + this.getName() + ": " + e.getMessage(),
+                       IMessage.ERROR, 
+                               WeaverMessages.format(WeaverMessages.PROBLEM_GENERATING_METHOD,
+                                                             this.getClassName(),
+                                                                         this.getName(),
+                                                                         e.getMessage()),
                        this.getMemberView() == null ? null : this.getMemberView().getSourceLocation(), null);
                throw e;
        }
index 0af3ececcc97c8f7468ffafa1e2e19869692850e..6cbe6ce5654ba5698630dcb633d05977363b9773 100644 (file)
@@ -31,6 +31,7 @@ import org.aspectj.weaver.IntMap;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.ast.Literal;
 import org.aspectj.weaver.ast.Test;
 
@@ -138,8 +139,8 @@ public class ArgsPointcut extends NameBindingPointcut {
                if (isDeclare(bindings.getEnclosingAdvice())) {
                  // Enforce rule about which designators are supported in declare
                  inAspect.getWorld().showMessage(IMessage.ERROR,
-                       "args() pointcut designator cannot be used in declare statement",
-                       bindings.getEnclosingAdvice().getSourceLocation(), null);
+                               WeaverMessages.format(WeaverMessages.ARGS_IN_DECLARE),
+                               bindings.getEnclosingAdvice().getSourceLocation(), null);
                  return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                }
                TypePatternList args = arguments.resolveReferences(bindings);
index 3a00891b1b38704586b5f4fcdc97f1ae80d156d5..1db5bb695bb3e15a69b0b745e2db8693fb33fa95 100644 (file)
@@ -35,6 +35,7 @@ import org.aspectj.weaver.ResolvedPointcutDefinition;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.World;
 import org.aspectj.weaver.ast.Test;
 
@@ -131,8 +132,8 @@ public class CflowPointcut extends Pointcut {
                if (isDeclare(bindings.getEnclosingAdvice())) {
                        // Enforce rule about which designators are supported in declare
                        inAspect.getWorld().showMessage(IMessage.ERROR,
-                         "cflow"+(isBelow?"below":"")+"() pointcut designator cannot be used in declare statement",
-                         bindings.getEnclosingAdvice().getSourceLocation(), null);
+                                       WeaverMessages.format(WeaverMessages.CFLOW_IN_DECLARE,isBelow?"below":""),
+                                       bindings.getEnclosingAdvice().getSourceLocation(), null);
                        return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                }
                //make this remap from formal positions to arrayIndices
index 7a66631b00906d36f1abb079bd7d1519851bb03f..c42eed9106d9214ebe8dc919793509a9d299e14c 100644 (file)
@@ -24,6 +24,7 @@ import org.aspectj.bridge.IMessage;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.World;
 
 public class DeclareParents extends Declare {
@@ -115,8 +116,9 @@ public class DeclareParents extends Declare {
                ResolvedTypeX parentType = iType.resolve(world);
                
                if (targetType.equals(world.resolve(TypeX.OBJECT))) {
-                       world.showMessage(IMessage.ERROR, "can't change the parents of java.lang.Object",
-                                         this.getSourceLocation(), null);
+                       world.showMessage(IMessage.ERROR, 
+                                       WeaverMessages.format(WeaverMessages.DECP_OBJECT),
+                               this.getSourceLocation(), null);
                        return null;
                }
                        
@@ -124,7 +126,8 @@ public class DeclareParents extends Declare {
                                        
                if (targetType.isAssignableFrom(parentType)) {
                        world.showMessage(IMessage.ERROR,
-                               "type \'" + targetType.getName() + "\'can not extend itself", this.getSourceLocation(), null
+                                       WeaverMessages.format(WeaverMessages.CANT_EXTEND_SELF,targetType.getName()),
+                                       this.getSourceLocation(), null
                        );
                        return null;
                }
@@ -132,8 +135,8 @@ public class DeclareParents extends Declare {
                if (parentType.isClass()) {
                        if (targetType.isInterface()) {
                                world.showMessage(IMessage.ERROR, 
-                                       "interface can not extend a class", 
-                                       this.getSourceLocation(), null
+                                               WeaverMessages.format(WeaverMessages.INTERFACE_CANT_EXTEND_CLASS),
+                                               this.getSourceLocation(), null
                                );
                                return null;
                                // how to handle xcutting errors???
@@ -141,10 +144,10 @@ public class DeclareParents extends Declare {
                        
                        if (!targetType.getSuperclass().isAssignableFrom(parentType)) {
                                world.showMessage(IMessage.ERROR,
-                                                                       "can only insert a class into hierarchy, but "
-                                                                       + iType.getName() + " is not a subtype of " +
-                                                                       targetType.getSuperclass().getName(), 
-                                                                       this.getSourceLocation(), null
+                                               WeaverMessages.format(WeaverMessages.DECP_HIERARCHY_ERROR,
+                                                               iType.getName(),
+                                                               targetType.getSuperclass().getName()), 
+                                               this.getSourceLocation(), null
                                );
                                return null;
                        } else {
index d7e19035714c6651a2e7a9beda7bee1e4d59db27..19686b063197b82e5ea28235c352d1d71fffb7c8 100644 (file)
@@ -21,6 +21,7 @@ import java.util.List;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedTypeX;
+import org.aspectj.weaver.WeaverMessages;
 
 public class DeclarePrecedence extends Declare {
        private TypePatternList patterns;
@@ -74,8 +75,8 @@ public class DeclarePrecedence extends Declare {
                if (pi.isStar()) {
                        if (seenStar) {
                                scope.getWorld().showMessage(IMessage.ERROR,
-                                       "circularity in declare precedence, '*' occurs more than once",
-                                       pi.getSourceLocation(), null);                                  
+                                               WeaverMessages.format(WeaverMessages.TWO_STARS_IN_PRECEDENCE),
+                                                       pi.getSourceLocation(), null);                                  
                        }
                        seenStar = true;
                        continue;
@@ -86,8 +87,8 @@ public class DeclarePrecedence extends Declare {
                // Cannot do a dec prec specifying a non-aspect types unless suffixed with a '+'
                if (!exactType.isAspect() && !pi.isIncludeSubtypes()) {
                        scope.getWorld().showMessage(IMessage.ERROR,
-                               "Non-aspect types can only be specified in a declare precedence statement when subtypes are included.  Non-aspect type is : "+exactType.getName(),
-                               pi.getSourceLocation(),null);
+                                       WeaverMessages.format(WeaverMessages.CLASSES_IN_PRECEDENCE,exactType.getName()),
+                                               pi.getSourceLocation(),null);
                }
                
                for (int j=0; j < patterns.size(); j++) {
@@ -96,8 +97,8 @@ public class DeclarePrecedence extends Declare {
                        if (pj.isStar()) continue;
                        if (pj.matchesStatically(exactType)) {
                                scope.getWorld().showMessage(IMessage.ERROR,
-                                       "circularity in declare precedence, '" + exactType.getName() + 
-                                               "' matches two patterns", pi.getSourceLocation(), pj.getSourceLocation());
+                                               WeaverMessages.format(WeaverMessages.TWO_PATTERN_MATCHES_IN_PRECEDENCE,exactType.getName()), 
+                                                       pi.getSourceLocation(), pj.getSourceLocation());
                        }
                }
        }       
@@ -116,8 +117,8 @@ public class DeclarePrecedence extends Declare {
                                starMatch = i;
                        } else if (p.matchesStatically(a)) {
                                if (knownMatch != -1) {
-                                       a.getWorld().showMessage(IMessage.ERROR, "multiple matches for " + a + 
-                                                       ", matches both " + patterns.get(knownMatch) + " and " + p,
+                                       a.getWorld().showMessage(IMessage.ERROR,
+                                                       WeaverMessages.format(WeaverMessages.MULTIPLE_MATCHES_IN_PRECEDENCE,a,patterns.get(knownMatch),p),
                                                        patterns.get(knownMatch).getSourceLocation(), p.getSourceLocation());
                                        return -1;
                                } else {
index 99727d2854a965df20dd58079980f8600c322a6f..c2159aca40116d5ceb85896a22c91a33c11afefd 100644 (file)
@@ -21,6 +21,7 @@ import org.aspectj.bridge.IMessage;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 
 public class DeclareSoft extends Declare {
        private TypePattern exception;
@@ -87,7 +88,7 @@ public class DeclareSoft extends Declare {
        if (excType != ResolvedTypeX.MISSING) {
                if (!scope.getWorld().resolve(TypeX.THROWABLE).isAssignableFrom(excType)) {
                        scope.getWorld().showMessage(IMessage.ERROR,
-                                       excType.getName() + " is not a subtype of Throwable",
+                                       WeaverMessages.format(WeaverMessages.NOT_THROWABLE,excType.getName()),
                                        exception.getSourceLocation(), null);
                        pointcut = Pointcut.makeMatchesNothing(Pointcut.RESOLVED);
                        return;
index 43f11ec28b31d764633af63e3f68c37960fcf0b2..62f65f485aac2a2c9dd83fc19bbf38f93832726c 100644 (file)
@@ -30,6 +30,7 @@ import org.aspectj.weaver.ResolvedPointcutDefinition;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.ShadowMunger;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.ast.Expr;
 import org.aspectj.weaver.ast.Literal;
 import org.aspectj.weaver.ast.Test;
@@ -153,9 +154,9 @@ public class IfPointcut extends Pointcut {
                if (isDeclare(bindings.getEnclosingAdvice())) {
                        // Enforce rule about which designators are supported in declare
                        inAspect.getWorld().showMessage(IMessage.ERROR,
-                         "if() pointcut designator cannot be used in declare statement",
-                         bindings.getEnclosingAdvice().getSourceLocation(),
-                         null);
+                                       WeaverMessages.format(WeaverMessages.IF_IN_DECLARE),
+                                       bindings.getEnclosingAdvice().getSourceLocation(),
+                                       null);
                        return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                }
                
@@ -174,8 +175,8 @@ public class IfPointcut extends Pointcut {
                        // Assumption: if() is in a per clause if we say we are directly in advice
                        // but we have no enclosing advice.
                        inAspect.getWorld().showMessage(IMessage.ERROR,
-                               "if() pointcut designator cannot be used directly in a per clause (compiler limitation).  Create a named pointcut containing the if() and refer to it",
-                               this.getSourceLocation(),null);
+                                       WeaverMessages.format(WeaverMessages.IF_IN_PERCLAUSE),
+                                       this.getSourceLocation(),null);
                        return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                }
                
@@ -191,8 +192,8 @@ public class IfPointcut extends Pointcut {
                        ResolvedPointcutDefinition def = bindings.peekEnclosingDefinitition();
                        if (def == CflowPointcut.CFLOW_MARKER) {
                                inAspect.getWorld().showMessage(IMessage.ERROR,
-                                       "if not supported lexically within cflow (compiler limitation)",
-                                       getSourceLocation(), null);
+                                               WeaverMessages.format(WeaverMessages.IF_LEXICALLY_IN_CFLOW),
+                                               getSourceLocation(), null);
                                return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                        }
                        ret.baseArgsCount = def.getParameterTypes().length;
@@ -250,7 +251,7 @@ public class IfPointcut extends Pointcut {
                        if (isDeclare(bindings.getEnclosingAdvice())) {
                                // Enforce rule about which designators are supported in declare
                                inAspect.getWorld().showMessage(IMessage.ERROR,
-                                 "if() pointcut designator cannot be used in declare statement",
+                                 WeaverMessages.format(WeaverMessages.IF_IN_DECLARE),
                                  bindings.getEnclosingAdvice().getSourceLocation(),
                                  null);
                                return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
@@ -316,9 +317,9 @@ public class IfPointcut extends Pointcut {
                        if (isDeclare(bindings.getEnclosingAdvice())) {
                                // Enforce rule about which designators are supported in declare
                                inAspect.getWorld().showMessage(IMessage.ERROR,
-                                 "if() pointcut designator cannot be used in declare statement",
-                                 bindings.getEnclosingAdvice().getSourceLocation(),
-                                 null);
+                                               WeaverMessages.format(WeaverMessages.IF_IN_DECLARE),
+                                               bindings.getEnclosingAdvice().getSourceLocation(),
+                                               null);
                                return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                        }
                        return makeIfTruePointcut(state);
index dfd2253770fda563780d4b474ae74541d4605612..5b6acce03d0db689a99ead553d0707d30518b0d0 100644 (file)
@@ -22,6 +22,7 @@ import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.ast.Test;
 
 public class PerFromSuper extends PerClause {
@@ -52,14 +53,12 @@ public class PerFromSuper extends PerClause {
                PerClause p = lookupConcretePerClause(inAspect.getSuperclass());
                if (p == null) {
                        inAspect.getWorld().getMessageHandler().handleMessage(
-                         MessageUtil.error("expected per clause on super aspect not found on " + 
-                                                               inAspect.getSuperclass(), getSourceLocation())
+                         MessageUtil.error(WeaverMessages.format(WeaverMessages.MISSING_PER_CLAUSE,inAspect.getSuperclass()), getSourceLocation())
                        );
                }
                if (p.getKind() != kind) {
                        inAspect.getWorld().getMessageHandler().handleMessage(
-                         MessageUtil.error("wrong kind of per clause on super, expected " + 
-                                                               kind + " but found " + p.getKind(),
+                         MessageUtil.error(WeaverMessages.format(WeaverMessages.WRONG_PER_CLAUSE,kind,p.getKind()),
                                                                getSourceLocation())
                        );
                }
index af09bf906dc2fcc87660388713744f01bd2d7a20..30b0cfbf603ad7a76f61464dceb2c68f6f2634ad 100644 (file)
@@ -29,6 +29,7 @@ import org.aspectj.weaver.ResolvedPointcutDefinition;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.ast.Test;
 
 /**
@@ -218,7 +219,7 @@ public class ReferencePointcut extends Pointcut {
                if (concretizing) {
                        //Thread.currentThread().dumpStack();
                        searchStart.getWorld().getMessageHandler().handleMessage(
-                               MessageUtil.error("circular pointcut declaration involving: " + this,
+                               MessageUtil.error(WeaverMessages.format(WeaverMessages.CIRCULAR_POINTCUT,this),
                                                                        getSourceLocation()));
                        return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                }
@@ -236,7 +237,7 @@ public class ReferencePointcut extends Pointcut {
                        pointcutDec = searchStart.findPointcut(name);
                        if (pointcutDec == null) {
                                searchStart.getWorld().getMessageHandler().handleMessage(
-                                       MessageUtil.error("can't find pointcut \'" + name + "\' on " + searchStart.getName(), 
+                                       MessageUtil.error(WeaverMessages.format(WeaverMessages.CANT_FIND_POINTCUT,name,searchStart.getName()), 
                                                                        getSourceLocation())
                                );
                                return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
@@ -246,9 +247,9 @@ public class ReferencePointcut extends Pointcut {
                                //Thread.currentThread().dumpStack();
                                ShadowMunger enclosingAdvice = bindings.getEnclosingAdvice();
                                searchStart.getWorld().showMessage(IMessage.ERROR,
-                                       pointcutDec + " is abstract"
-                                       getSourceLocation(), 
-                                       (null == enclosingAdvice) ? null : enclosingAdvice.getSourceLocation());
+                                               WeaverMessages.format(WeaverMessages.ABSTRACT_POINTCUT,pointcutDec)
+                                               getSourceLocation(), 
+                                               (null == enclosingAdvice) ? null : enclosingAdvice.getSourceLocation());
                                return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                        }
                                        
index 4e8c9fc7249b95b89f2042d1d4a68a7d65739b9b..37d8ac68c91d6f1da7f21991aefb20cbae95e041 100644 (file)
@@ -25,6 +25,7 @@ import org.aspectj.weaver.IntMap;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 import org.aspectj.weaver.ast.Literal;
 import org.aspectj.weaver.ast.Test;
 import org.aspectj.weaver.ast.Var;
@@ -130,8 +131,8 @@ public class ThisOrTargetPointcut extends NameBindingPointcut {
                if (isDeclare(bindings.getEnclosingAdvice())) {
                  // Enforce rule about which designators are supported in declare
                  inAspect.getWorld().showMessage(IMessage.ERROR,
-                   (isThis?"this":"target")+"() pointcut designator cannot be used in declare statement",
-                   bindings.getEnclosingAdvice().getSourceLocation(), null);
+                               WeaverMessages.format(WeaverMessages.THIS_OR_TARGET_IN_DECLARE,isThis?"this":"target"),
+                               bindings.getEnclosingAdvice().getSourceLocation(), null);
                  return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                }
                
index ecb29ea5c63ddb0e3c668603fade66aef13cb23e..0e0496ad210c6c10c9d140dcdf6bb79cf6ba6128 100644 (file)
@@ -25,6 +25,7 @@ import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.IntMap;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 /**
  *  On creation, type pattern only contains WildTypePattern nodes, not BindingType or ExactType. 
  * 
@@ -169,7 +170,8 @@ public abstract class TypePattern extends PatternNode {
        }
        
        protected TypePattern notExactType(IScope s) {
-               s.getMessageHandler().handleMessage(MessageUtil.error("exact type pattern required", getSourceLocation()));
+               s.getMessageHandler().handleMessage(MessageUtil.error(
+                               WeaverMessages.format(WeaverMessages.EXACT_TYPE_PATTERN_REQD), getSourceLocation()));
                return NO;
        }
        
index 01324e36b8412aa011bb8b9ff396d3d5e88e958e..9e33ee393614a07b8f72ca7b56d3fce2f4e0a931 100644 (file)
@@ -27,6 +27,7 @@ import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedTypeX;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 
 //XXX need to use dim in matching
 public class WildTypePattern extends TypePattern {
@@ -348,7 +349,7 @@ public class WildTypePattern extends TypePattern {
                                if (requireExactType) {
                                        if (!allowBinding) {
                                                scope.getWorld().getMessageHandler().handleMessage(
-                                                       MessageUtil.error("can't bind type name '" + originalName + "'",
+                                                       MessageUtil.error(WeaverMessages.format(WeaverMessages.CANT_BIND_TYPE,originalName),
                                                                                        getSourceLocation()));
                                        } else if (scope.getWorld().getLint().invalidAbsoluteTypeName.isEnabled()) {
                                                scope.getWorld().getLint().invalidAbsoluteTypeName.signal(originalName, getSourceLocation());
@@ -366,7 +367,7 @@ public class WildTypePattern extends TypePattern {
                } else {
                        if (requireExactType) {
                                scope.getWorld().getMessageHandler().handleMessage(
-                                       MessageUtil.error("wildcard type pattern not allowed, must use type name",
+                                       MessageUtil.error(WeaverMessages.format(WeaverMessages.WILDCARD_NOT_ALLOWED),
                                                                                getSourceLocation()));
                                return NO;
                        }
diff --git a/weaver/src/org/aspectj/weaver/weaver-messages.properties b/weaver/src/org/aspectj/weaver/weaver-messages.properties
new file mode 100644 (file)
index 0000000..98c5c9b
--- /dev/null
@@ -0,0 +1,99 @@
+#####################################################################
+# Copyright (c) 2004 Contributors.
+# All rights reserved. 
+# This program and the accompanying materials are made available 
+# under the terms of the Common Public License v1.0 
+# which accompanies this distribution and is available at 
+# http://www.eclipse.org/legal/cpl-v10.html 
+#  
+# Contributors: 
+#     Adrian Colyer - Initial version
+#####################################################################
+
+# Messages output by the AspectJ Weaver
+
+# Pointcut related messages...
+argsInDeclare=args() pointcut designator cannot be used in declare statement
+cflowInDeclare=cflow{0}() pointcut designator cannot be used in declare statement
+ifInDeclare=if() pointcut designator cannot be used in declare statement
+thisOrTargetInDeclare={0}() pointcut designator cannot be used in declare statement
+abstractPointcut={0} is abstract
+abstractPointcutNotMadeConcrete=inherited abstract {0} is not made concrete in {1}
+conflictingInheritedPointcuts=conflicting inherited pointcuts in {0}
+circularPointcutDeclaration=circular pointcut declaration involving: {0}
+cantFindPointcut=can''t find pointcut ''{0}'' on {1}
+exactTypePatternRequired=exact type pattern required
+cantBindType=can''t bind type name ''{0}''
+wildcardTypePatternNotAllowed=wildcard type pattern not allowed, must use type name
+
+# Declare parents messages...
+decpObject=can''t change the parents of java.lang.Object
+cantExtendSelf=type ''{0}''can not extend itself
+interfaceExtendClass=interface can not extend a class
+decpHierarchy=can only insert a class into hierarchy, but {0} is not a subtype of {1}
+
+# declare precedence messages...
+multipleMatchesInPrecedence=multiple matches for {0}, matches both {1} and {2}
+circularityInPrecedenceStar=circularity in declare precedence, ''*'' occurs more than once
+nonAspectTypesInPrecedence=Non-aspect types can only be specified in a declare precedence statement when subtypes are included.  Non-aspect type is : {0}
+circularityInPrecedenceTwo=circularity in declare precedence, ''{0}'' matches two patterns
+
+# declare soft messages...
+notThrowable={0} is not a subtype of Throwable
+
+# itd messages...
+itdConsOnAspect=can''t declare constructor on an aspect
+returnTypeMismatch=can''t override {0} with {1} return types don''t match
+paramTypeMismatch=can''t override {0} with {1} parameter types don''t match
+visibilityReduction=can''t override {0} with {1} visibility is reduced
+doesntThrow=overriden method doesn't throw {0}
+overriddenStatic={0} cannot override {1}; overridden method is static
+overridingStatic={0} cannot override {1}; overriding method is static
+itdConflict=intertype declaration from {0} conflicts with intertype declaration: {1} from {2}
+itdMemberConflict=inter-type declaration from {0} conflicts with existing member: {1}
+
+# advice messages...
+nonVoidReturn=applying to join point that doesn't return void: {0}
+incompatibleReturnType=incompatible return type applying to {0}
+cantThrowChecked=can''t throw checked exception ''{0}'' at this join point ''{1}''
+circularDependency=can''t determine precedence between two or more pieces of advice that apply the same join point: {0}
+
+# aspect messages..
+missingPerClause=expected per clause on super aspect not found on {0}
+wrongPerClause=wrong kind of per clause on super, expected {0} but found {1}
+
+# Reweavable messages...
+alreadyWoven=class ''{0}'' is already woven and has not been built with -Xreweavable
+reweavableMode=weaver operating in reweavable mode.  Need to verify any required types exist.
+processingReweavable=processing reweavable type {0}: {1}
+missingReweavableType=type {0} is needed by reweavable type {1}
+verifiedReweavableType=successfully verified type {0} exists.  Originates from {1}
+aspectNeeded=aspect {0} is needed when using type {1}
+
+# The infamous and deserving a category all of its own...
+cantFindType=can''t find type {0}
+
+# Implementation limitations...
+decpBinaryLimitation=can''t use declare parents to change superclass of binary form ''{0}'' (implementation limitation)
+overwriteJSR45=overwriting JSR45 information for {0} (compiler limitation)
+ifInPerClause=if() pointcut designator cannot be used directly in a per clause (compiler limitation).  Create a named pointcut containing the if() and refer to it
+ifLexicallyInCflow=if not supported lexically within cflow (compiler limitation)
+onlyBeforeOnHandler=Only before advice is supported on handler join points (compiler limitation)
+aroundOnPreInit=around on pre-initialization not supported (compiler limitation)
+aroundOnInit=around on initialization not supported (compiler limitation)
+aroundOnInterfaceStaticInit=around on staticinitialization of interface ''{0}'' not supported (compiler limitation)
+
+# Bytecode generation nasties...
+problemGeneratingMethod=problem generating method {0}.{1} : {2}
+
+# Classpath messages
+zipfileEntryMissing=zipfile classpath entry does not exist: {0}
+zipfileEntryInvalid=zipfile classpath entry is invalid: {0} <{1}>
+directoryEntryMissing=directory classpath entry does not exist: {0}
+
+# Lint messages
+problemLoadingXLint=problem loading Xlint properties file: {0}, {1}
+unableToLoadXLintDefault=couldn''t load XlintDefault.properties
+errorLoadingXLintDefault=problem loading XlintDefault.properties, {0}
+invalidXLintKey=invalid Xlint key: {0}
+invalidXLintMessageKind=invalid Xlint message kind (must be one of ignore, warning, error): {0}
index 1803cf2fdc43e62bcf35b3ae93ec0f4831ca5dba..ac1587b54109f2fe7f62d924895a1de09f034e56 100644 (file)
@@ -53,6 +53,7 @@ public class BcweaverTests extends TestCase {
         suite.addTestSuite(MemberTestCase.class); 
                suite.addTestSuite(TypeXTestCase.class); 
                suite.addTestSuite(WeavingURLClassLoaderTest.class); 
+               suite.addTestSuite(WeaverMessagesTestCase.class);
         //$JUnit-END$
         return suite;
     }
diff --git a/weaver/testsrc/org/aspectj/weaver/WeaverMessagesTestCase.java b/weaver/testsrc/org/aspectj/weaver/WeaverMessagesTestCase.java
new file mode 100644 (file)
index 0000000..99efe3d
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.MissingResourceException;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class WeaverMessagesTestCase extends TestCase {
+       
+       public void testAllMessagesDefined() {
+               
+               Class wmClass = WeaverMessages.class;
+               Field[] fields = wmClass.getDeclaredFields();
+               List fieldList = new ArrayList();
+               for (int i = 0; i < fields.length; i++) {
+                       Field f = fields[i];
+                       if (f.getType() == String.class) {
+                               try {
+                                       String key = (String) f.get(null);
+                                       String value = WeaverMessages.format(key);
+                                       assertFalse("Each key should be unique",fieldList.contains(key));
+                                       fieldList.add(key);
+//                                     System.out.println(key + "," + value);
+                               } catch (IllegalAccessException ex) {                                   
+                               } catch(MissingResourceException mrEx) {
+                                       fail("Missing resource: " + mrEx);
+                               }
+                       }
+               }
+       }
+
+}