@@ -96,7 +96,7 @@ public class BoundedReferenceType extends ReferenceType { | |||
} | |||
@Override | |||
public UnresolvedType parameterize(Map typeBindings) { | |||
public UnresolvedType parameterize(Map<String, UnresolvedType> typeBindings) { | |||
if (this.kind == UNBOUND) { | |||
return this; | |||
} |
@@ -6,6 +6,7 @@ package org.aspectj.weaver; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import org.aspectj.weaver.patterns.Declare; | |||
import org.aspectj.weaver.patterns.PerClause; | |||
class BoundedReferenceTypeDelegate extends AbstractReferenceTypeDelegate { | |||
@@ -102,16 +103,16 @@ class BoundedReferenceTypeDelegate extends AbstractReferenceTypeDelegate { | |||
return resolvedTypeX.getPerClause(); | |||
} | |||
public Collection getDeclares() { | |||
public Collection<Declare> getDeclares() { | |||
return resolvedTypeX.getDeclares(); | |||
} | |||
public Collection getTypeMungers() { | |||
public Collection<ConcreteTypeMunger> getTypeMungers() { | |||
return resolvedTypeX.getTypeMungers(); | |||
} | |||
public Collection getPrivilegedAccesses() { | |||
return Collections.EMPTY_LIST; | |||
public Collection<ResolvedMember> getPrivilegedAccesses() { | |||
return Collections.emptyList(); | |||
} | |||
public int getModifiers() { |
@@ -38,8 +38,7 @@ public abstract class ConcreteTypeMunger implements PartialOrder.PartialComparab | |||
ResolvedTypeMunger otherTypeMunger = o.getMunger(); | |||
ResolvedTypeMunger thisTypeMunger = getMunger(); | |||
if (thisTypeMunger instanceof NewConstructorTypeMunger && otherTypeMunger instanceof NewConstructorTypeMunger) { | |||
return ((otherTypeMunger == null) ? (thisTypeMunger == null) : ((NewConstructorTypeMunger) otherTypeMunger) | |||
.equivalentTo(thisTypeMunger)) | |||
return (((NewConstructorTypeMunger) otherTypeMunger).equivalentTo(thisTypeMunger)) | |||
&& ((o.getAspectType() == null) ? (getAspectType() == null) : o.getAspectType().equals(getAspectType())); | |||
} else { | |||
return ((otherTypeMunger == null) ? (thisTypeMunger == null) : otherTypeMunger.equals(thisTypeMunger)) |
@@ -73,8 +73,8 @@ public class CrosscuttingMembers { | |||
this.shouldConcretizeIfNeeded = shouldConcretizeIfNeeded; | |||
} | |||
private final Hashtable cflowFields = new Hashtable(); | |||
private final Hashtable cflowBelowFields = new Hashtable(); | |||
private final Hashtable<String, Object> cflowFields = new Hashtable<String, Object>(); | |||
private final Hashtable<String, Object> cflowBelowFields = new Hashtable<String, Object>(); | |||
// public void addConcreteShadowMungers(Collection c) { | |||
// shadowMungers.addAll(c); | |||
@@ -558,11 +558,11 @@ public class CrosscuttingMembers { | |||
return declareTypeEow; | |||
} | |||
public Map getCflowBelowFields() { | |||
public Map<String, Object> getCflowBelowFields() { | |||
return cflowBelowFields; | |||
} | |||
public Map getCflowFields() { | |||
public Map<String, Object> getCflowFields() { | |||
return cflowFields; | |||
} | |||
@@ -46,7 +46,7 @@ public class Dump { | |||
public static final String DUMP_EXCLUDED = "Excluded"; | |||
public static final String NULL_OR_EMPTY = "Empty"; | |||
private static Class exceptionClass; | |||
private static Class<?> exceptionClass; | |||
private static IMessage.Kind conditionKind = IMessage.ABORT; | |||
private static File directory = new File("."); | |||
@@ -11,6 +11,7 @@ package org.aspectj.weaver; | |||
import java.util.Collection; | |||
import org.aspectj.weaver.patterns.Declare; | |||
import org.aspectj.weaver.patterns.PerClause; | |||
/** | |||
@@ -115,15 +116,15 @@ public class GeneratedReferenceTypeDelegate extends AbstractReferenceTypeDelegat | |||
throw new UnsupportedOperationException("Not supported for GeneratedReferenceTypeDelegate"); | |||
} | |||
public Collection getDeclares() { | |||
public Collection<Declare> getDeclares() { | |||
throw new UnsupportedOperationException("Not supported for GeneratedReferenceTypeDelegate"); | |||
} | |||
public Collection getTypeMungers() { | |||
public Collection<ConcreteTypeMunger> getTypeMungers() { | |||
throw new UnsupportedOperationException("Not supported for GeneratedReferenceTypeDelegate"); | |||
} | |||
public Collection getPrivilegedAccesses() { | |||
public Collection<ResolvedMember> getPrivilegedAccesses() { | |||
throw new UnsupportedOperationException("Not supported for GeneratedReferenceTypeDelegate"); | |||
} | |||
@@ -24,7 +24,7 @@ public class IntMap { | |||
// XXX begin hack to avoid a signature refactoring in Pointcut | |||
private ResolvedType concreteAspect; | |||
private ShadowMunger enclosingAdvice; | |||
private List/* ResolvedPointcutDefinition */enclosingDefinition = new ArrayList(); | |||
private List<ResolvedPointcutDefinition> enclosingDefinition = new ArrayList<ResolvedPointcutDefinition>(); | |||
public void pushEnclosingDefinition(ResolvedPointcutDefinition def) { | |||
enclosingDefinition.add(def); | |||
@@ -35,9 +35,10 @@ public class IntMap { | |||
} | |||
public ResolvedPointcutDefinition peekEnclosingDefinition() { | |||
if (enclosingDefinition.size() == 0) | |||
if (enclosingDefinition.size() == 0) { | |||
return null; | |||
return (ResolvedPointcutDefinition) enclosingDefinition.get(enclosingDefinition.size() - 1); | |||
} | |||
return enclosingDefinition.get(enclosingDefinition.size() - 1); | |||
} | |||
public boolean directlyInAdvice() { | |||
@@ -53,10 +54,11 @@ public class IntMap { | |||
} | |||
public Member getAdviceSignature() { | |||
if (enclosingAdvice instanceof Advice) | |||
if (enclosingAdvice instanceof Advice) { | |||
return ((Advice) enclosingAdvice).getSignature(); | |||
else | |||
} else { | |||
return null; | |||
} | |||
} | |||
public ResolvedType getConcreteAspect() { | |||
@@ -99,8 +101,9 @@ public class IntMap { | |||
if (key >= map.length) { | |||
int[] tmp = new int[key * 2 + 1]; // ??? better expansion function | |||
System.arraycopy(map, 0, tmp, 0, map.length); | |||
for (int i = map.length, len = tmp.length; i < len; i++) | |||
for (int i = map.length, len = tmp.length; i < len; i++) { | |||
tmp[i] = MISSING; | |||
} | |||
map = tmp; | |||
} | |||
map[key] = val; |
@@ -277,7 +277,7 @@ public class JoinPointSignature implements ResolvedMember { | |||
return realMember.getAnnotations(); | |||
} | |||
public Collection getDeclaringTypes(World world) { | |||
public Collection<ResolvedType> getDeclaringTypes(World world) { | |||
throw new UnsupportedOperationException("Adrian doesn't think you should be calling this..."); | |||
} | |||
@@ -139,19 +139,23 @@ public class Lint { | |||
private static Trace trace = TraceFactory.getTraceFactory().getTrace(Lint.class); | |||
public Lint(World world) { | |||
if (trace.isTraceEnabled()) | |||
if (trace.isTraceEnabled()) { | |||
trace.enter("<init>", this, world); | |||
} | |||
this.world = world; | |||
if (trace.isTraceEnabled()) | |||
if (trace.isTraceEnabled()) { | |||
trace.exit("<init>"); | |||
} | |||
} | |||
public void setAll(String messageKind) { | |||
if (trace.isTraceEnabled()) | |||
if (trace.isTraceEnabled()) { | |||
trace.enter("setAll", this, messageKind); | |||
} | |||
setAll(getMessageKind(messageKind)); | |||
if (trace.isTraceEnabled()) | |||
if (trace.isTraceEnabled()) { | |||
trace.exit("setAll"); | |||
} | |||
} | |||
private void setAll(IMessage.Kind messageKind) { | |||
@@ -161,15 +165,16 @@ public class Lint { | |||
} | |||
public void setFromProperties(File file) { | |||
if (trace.isTraceEnabled()) | |||
if (trace.isTraceEnabled()) { | |||
trace.enter("setFromProperties", this, file); | |||
} | |||
InputStream s = null; | |||
try { | |||
s = new FileInputStream(file); | |||
setFromProperties(s); | |||
} catch (IOException ioe) { | |||
MessageUtil.error(world.getMessageHandler(), WeaverMessages.format(WeaverMessages.XLINT_LOAD_ERROR, file.getPath(), ioe | |||
.getMessage())); | |||
MessageUtil.error(world.getMessageHandler(), | |||
WeaverMessages.format(WeaverMessages.XLINT_LOAD_ERROR, file.getPath(), ioe.getMessage())); | |||
} finally { | |||
if (s != null) { | |||
try { | |||
@@ -180,8 +185,9 @@ public class Lint { | |||
} | |||
} | |||
if (trace.isTraceEnabled()) | |||
if (trace.isTraceEnabled()) { | |||
trace.exit("setFromProperties"); | |||
} | |||
} | |||
public void loadDefaultProperties() { | |||
@@ -193,8 +199,8 @@ public class Lint { | |||
try { | |||
setFromProperties(s); | |||
} catch (IOException ioe) { | |||
MessageUtil.error(world.getMessageHandler(), WeaverMessages.format(WeaverMessages.XLINTDEFAULT_LOAD_PROBLEM, ioe | |||
.getMessage())); | |||
MessageUtil.error(world.getMessageHandler(), | |||
WeaverMessages.format(WeaverMessages.XLINTDEFAULT_LOAD_PROBLEM, ioe.getMessage())); | |||
} finally { | |||
try { | |||
s.close(); | |||
@@ -211,6 +217,7 @@ public class Lint { | |||
setFromProperties(p); | |||
} | |||
@SuppressWarnings("rawtypes") | |||
public void setFromProperties(Properties properties) { | |||
for (Iterator i = properties.entrySet().iterator(); i.hasNext();) { | |||
Map.Entry entry = (Map.Entry) i.next(); | |||
@@ -232,11 +239,11 @@ public class Lint { | |||
} | |||
// temporarily suppress the given lint messages | |||
public void suppressKinds(Collection lintKind) { | |||
if (lintKind.isEmpty()) | |||
public void suppressKinds(Collection<Kind> lintKind) { | |||
if (lintKind.isEmpty()) { | |||
return; | |||
for (Iterator iter = lintKind.iterator(); iter.hasNext();) { | |||
Kind k = (Kind) iter.next(); | |||
} | |||
for (Kind k : lintKind) { | |||
k.setSuppressed(true); | |||
} | |||
} | |||
@@ -255,12 +262,13 @@ public class Lint { | |||
} | |||
private IMessage.Kind getMessageKind(String v) { | |||
if (v.equals("ignore")) | |||
if (v.equals("ignore")) { | |||
return null; | |||
else if (v.equals("warning")) | |||
} else if (v.equals("warning")) { | |||
return IMessage.WARNING; | |||
else if (v.equals("error")) | |||
} else if (v.equals("error")) { | |||
return IMessage.ERROR; | |||
} | |||
MessageUtil.error(world.getMessageHandler(), WeaverMessages.format(WeaverMessages.XLINT_VALUE_ERROR, v)); | |||
return null; | |||
@@ -308,8 +316,9 @@ public class Lint { | |||
} | |||
public void signal(String info, ISourceLocation location) { | |||
if (kind == null) | |||
if (kind == null) { | |||
return; | |||
} | |||
String text = MessageFormat.format(message, new Object[] { info }); | |||
text += " [Xlint:" + name + "]"; | |||
@@ -317,8 +326,9 @@ public class Lint { | |||
} | |||
public void signal(String[] infos, ISourceLocation location, ISourceLocation[] extraLocations) { | |||
if (kind == null) | |||
if (kind == null) { | |||
return; | |||
} | |||
String text = MessageFormat.format(message, (Object[]) infos); | |||
text += " [Xlint:" + name + "]"; |
@@ -53,7 +53,7 @@ public class ReferenceType extends ResolvedType { | |||
ResolvedMember[] parameterizedPointcuts = null; | |||
WeakReference<ResolvedType[]> parameterizedInterfaces = new WeakReference<ResolvedType[]>(null); | |||
Collection<Declare> parameterizedDeclares = null; | |||
Collection parameterizedTypeMungers = null; | |||
// Collection parameterizedTypeMungers = null; | |||
// During matching it can be necessary to temporary mark types as annotated. For example | |||
// a declare @type may trigger a separate declare parents to match, and so the annotation |
@@ -27,7 +27,7 @@ import org.aspectj.bridge.ISourceLocation; | |||
* @author PARC | |||
* @author Andy Clement | |||
*/ | |||
public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, TypeVariableDeclaringElement, ResolvedMember { | |||
public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, ResolvedMember { | |||
private String[] parameterNames = null; | |||
protected UnresolvedType[] checkedExceptions = UnresolvedType.NONE; |
@@ -85,8 +85,9 @@ public abstract class Shadow { | |||
* @throws IllegalStateException if there is no this here | |||
*/ | |||
public final UnresolvedType getThisType() { | |||
if (!hasThis()) | |||
if (!hasThis()) { | |||
throw new IllegalStateException("no this"); | |||
} | |||
if (getKind().isEnclosingKind()) { | |||
return getSignature().getDeclaringType(); | |||
} else { | |||
@@ -120,8 +121,9 @@ public abstract class Shadow { | |||
* @throws IllegalStateException if there is no target here | |||
*/ | |||
public final UnresolvedType getTargetType() { | |||
if (!hasTarget()) | |||
if (!hasTarget()) { | |||
throw new IllegalStateException("no target"); | |||
} | |||
return getSignature().getDeclaringType(); | |||
} | |||
@@ -133,8 +135,9 @@ public abstract class Shadow { | |||
public abstract Var getTargetVar(); | |||
public UnresolvedType[] getArgTypes() { | |||
if (getKind() == FieldSet) | |||
if (getKind() == FieldSet) { | |||
return new UnresolvedType[] { getSignature().getReturnType() }; | |||
} | |||
return getSignature().getParameterTypes(); | |||
} | |||
@@ -153,14 +156,17 @@ public abstract class Shadow { | |||
int dims = 1; | |||
while (pos < s.length()) { | |||
pos++; | |||
if (pos < s.length()) | |||
if (pos < s.length()) { | |||
dims += (s.charAt(pos) == '[' ? 1 : 0); | |||
} | |||
} | |||
if (dims == 1) | |||
if (dims == 1) { | |||
return new ResolvedType[] { ResolvedType.INT }; | |||
} | |||
ResolvedType[] someInts = new ResolvedType[dims]; | |||
for (int i = 0; i < dims; i++) | |||
for (int i = 0; i < dims; i++) { | |||
someInts[i] = ResolvedType.INT; | |||
} | |||
return someInts; | |||
} | |||
@@ -171,20 +177,23 @@ public abstract class Shadow { | |||
if (isShadowForMonitor()) { | |||
return UnresolvedType.ARRAY_WITH_JUST_OBJECT; | |||
} | |||
if (getKind() == FieldSet) | |||
if (getKind() == FieldSet) { | |||
return new UnresolvedType[] { getResolvedSignature().getGenericReturnType() }; | |||
} | |||
return getResolvedSignature().getGenericParameterTypes(); | |||
} | |||
public UnresolvedType getArgType(int arg) { | |||
if (getKind() == FieldSet) | |||
if (getKind() == FieldSet) { | |||
return getSignature().getReturnType(); | |||
} | |||
return getSignature().getParameterTypes()[arg]; | |||
} | |||
public int getArgCount() { | |||
if (getKind() == FieldSet) | |||
if (getKind() == FieldSet) { | |||
return 1; | |||
} | |||
return getSignature().getParameterTypes().length; | |||
} | |||
@@ -263,12 +272,13 @@ public abstract class Shadow { | |||
} | |||
public UnresolvedType getReturnType() { | |||
if (kind == ConstructorCall) | |||
if (kind == ConstructorCall) { | |||
return getSignature().getDeclaringType(); | |||
else if (kind == FieldSet) | |||
} else if (kind == FieldSet) { | |||
return ResolvedType.VOID; | |||
else if (kind == SynchronizationLock || kind == SynchronizationUnlock) | |||
} else if (kind == SynchronizationLock || kind == SynchronizationUnlock) { | |||
return ResolvedType.VOID; | |||
} | |||
return getResolvedSignature().getGenericReturnType(); | |||
} | |||
@@ -337,8 +347,9 @@ public abstract class Shadow { | |||
public static int howMany(int i) { | |||
int count = 0; | |||
for (int j = 0; j < SHADOW_KINDS.length; j++) { | |||
if ((i & SHADOW_KINDS[j].bit) != 0) | |||
if ((i & SHADOW_KINDS[j].bit) != 0) { | |||
count++; | |||
} | |||
} | |||
return count; | |||
} | |||
@@ -423,10 +434,11 @@ public abstract class Shadow { | |||
public String getSimpleName() { | |||
int dash = getName().lastIndexOf('-'); | |||
if (dash == -1) | |||
if (dash == -1) { | |||
return getName(); | |||
else | |||
} else { | |||
return getName().substring(dash + 1); | |||
} | |||
} | |||
public static Kind read(DataInputStream s) throws IOException { | |||
@@ -471,9 +483,10 @@ public abstract class Shadow { | |||
*/ | |||
protected boolean checkMunger(ShadowMunger munger) { | |||
if (munger.mustCheckExceptions()) { | |||
for (Iterator i = munger.getThrownExceptions().iterator(); i.hasNext();) { | |||
if (!checkCanThrow(munger, (ResolvedType) i.next())) | |||
for (Iterator<ResolvedType> i = munger.getThrownExceptions().iterator(); i.hasNext();) { | |||
if (!checkCanThrow(munger, i.next())) { | |||
return false; | |||
} | |||
} | |||
} | |||
return true; | |||
@@ -506,24 +519,27 @@ public abstract class Shadow { | |||
private boolean isDeclaredException(ResolvedType resolvedTypeX, Member member) { | |||
ResolvedType[] excs = getIWorld().resolve(member.getExceptions(getIWorld())); | |||
for (int i = 0, len = excs.length; i < len; i++) { | |||
if (excs[i].isAssignableFrom(resolvedTypeX)) | |||
if (excs[i].isAssignableFrom(resolvedTypeX)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
public void addMunger(ShadowMunger munger) { | |||
if (checkMunger(munger)) { | |||
if (mungers == Collections.EMPTY_LIST) | |||
if (mungers == Collections.EMPTY_LIST) { | |||
mungers = new ArrayList(); | |||
} | |||
this.mungers.add(munger); | |||
} | |||
} | |||
public final void implement() { | |||
sortMungers(); | |||
if (mungers == null) | |||
if (mungers == null) { | |||
return; | |||
} | |||
prepareForMungers(); | |||
implementMungers(); | |||
} | |||
@@ -537,8 +553,7 @@ public abstract class Shadow { | |||
if (sorted == null) { | |||
// this means that we have circular dependencies | |||
for (Iterator i = mungers.iterator(); i.hasNext();) { | |||
ShadowMunger m = (ShadowMunger) i.next(); | |||
for (ShadowMunger m : mungers) { | |||
getIWorld().getMessageHandler().handleMessage( | |||
MessageUtil.error(WeaverMessages.format(WeaverMessages.CIRCULAR_DEPENDENCY, this), m.getSourceLocation())); | |||
} | |||
@@ -552,7 +567,7 @@ public abstract class Shadow { | |||
// Stores a set of strings of the form 'aspect1:aspect2' which indicates there is no | |||
// precedence specified between the two aspects at this shadow. | |||
Set clashingAspects = new HashSet(); | |||
Set<String> clashingAspects = new HashSet<String>(); | |||
int max = mungers.size(); | |||
// Compare every pair of advice mungers | |||
@@ -580,20 +595,21 @@ public abstract class Shadow { | |||
if (order != null && order.equals(new Integer(0))) { | |||
String key = adviceA.getDeclaringAspect() + ":" + adviceB.getDeclaringAspect(); | |||
String possibleExistingKey = adviceB.getDeclaringAspect() + ":" + adviceA.getDeclaringAspect(); | |||
if (!clashingAspects.contains(possibleExistingKey)) | |||
if (!clashingAspects.contains(possibleExistingKey)) { | |||
clashingAspects.add(key); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
for (Iterator iter = clashingAspects.iterator(); iter.hasNext();) { | |||
String element = (String) iter.next(); | |||
for (Iterator<String> iter = clashingAspects.iterator(); iter.hasNext();) { | |||
String element = iter.next(); | |||
String aspect1 = element.substring(0, element.indexOf(":")); | |||
String aspect2 = element.substring(element.indexOf(":") + 1); | |||
getIWorld().getLint().unorderedAdviceAtShadow.signal(new String[] { this.toString(), aspect1, aspect2 }, this | |||
.getSourceLocation(), null); | |||
getIWorld().getLint().unorderedAdviceAtShadow.signal(new String[] { this.toString(), aspect1, aspect2 }, | |||
this.getSourceLocation(), null); | |||
} | |||
} | |||
} | |||
@@ -655,12 +671,13 @@ public abstract class Shadow { | |||
* Convert a bit array for the shadow kinds into a set of them... should only be used for testing - mainline code should do bit | |||
* manipulation! | |||
*/ | |||
public static Set toSet(int i) { | |||
Set results = new HashSet(); | |||
public static Set<Kind> toSet(int i) { | |||
Set<Kind> results = new HashSet<Kind>(); | |||
for (int j = 0; j < Shadow.SHADOW_KINDS.length; j++) { | |||
Kind k = Shadow.SHADOW_KINDS[j]; | |||
if (k.isSet(i)) | |||
if (k.isSet(i)) { | |||
results.add(k); | |||
} | |||
} | |||
return results; | |||
} |
@@ -47,8 +47,8 @@ public class TypeVariableReferenceType extends ReferenceType implements TypeVari | |||
} | |||
@Override | |||
public UnresolvedType parameterize(Map typeBindings) { | |||
UnresolvedType ut = (UnresolvedType) typeBindings.get(getName()); | |||
public UnresolvedType parameterize(Map<String, UnresolvedType> typeBindings) { | |||
UnresolvedType ut = typeBindings.get(getName()); | |||
if (ut != null) { | |||
return world.resolve(ut); | |||
} |