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;
}
}
} 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;
}
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;
}
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()));
}
}
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()));
}
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;
}
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);
}
}
} 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 {
//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) {
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;
}
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;
//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());
}
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());
}
}
}
} 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();
}
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;
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;
--- /dev/null
+/*******************************************************************************
+ * 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});
+ }
+
+}
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;
}
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);
}
}
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;
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;
}
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;
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();
}
// 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();) {
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);
}
}
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;
}
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
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));
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;
if (hasSourceDebugExtensionAttribute(myGen)) {
world.showMessage(
IMessage.WARNING,
- "overwriting JSR45 information for "
- + getFileName()
- + " (compiler limitation)",
+ WeaverMessages.format(WeaverMessages.OVERWRITE_JSR45,getFileName()),
null,
null);
}
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.Member;
import org.aspectj.weaver.ResolvedTypeX;
+import org.aspectj.weaver.WeaverMessages;
/**
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;
}
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;
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);
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;
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
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 {
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;
}
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;
}
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???
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 {
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;
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;
// 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++) {
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());
}
}
}
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 {
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;
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;
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;
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);
}
// 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);
}
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;
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);
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);
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 {
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())
);
}
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;
/**
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);
}
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);
//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);
}
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;
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);
}
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.
*
}
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;
}
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 {
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());
} 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;
}
--- /dev/null
+#####################################################################
+# 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}
suite.addTestSuite(MemberTestCase.class);
suite.addTestSuite(TypeXTestCase.class);
suite.addTestSuite(WeavingURLClassLoaderTest.class);
+ suite.addTestSuite(WeaverMessagesTestCase.class);
//$JUnit-END$
return suite;
}
--- /dev/null
+/*******************************************************************************
+ * 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);
+ }
+ }
+ }
+ }
+
+}