if (!aBaseType.isGenericType()) {
// try and find the generic type...
if (someTypeParameters != null && someTypeParameters.length > 0) {
- if (!aBaseType.isRawType())
+ if (!aBaseType.isRawType()) {
throw new IllegalStateException("Expecting raw type, not: " + aBaseType);
+ }
baseType = baseType.getGenericType();
- if (baseType == null)
+ if (baseType == null) {
throw new IllegalStateException("Raw type does not have generic type set");
+ }
} // else if someTypeParameters is null, then the base type is allowed to be non-generic, it's an inner
}
ResolvedType[] resolvedParameters = inAWorld.resolve(someTypeParameters);
while (startOfParams != -1) {
erasureSig.delete(startOfParams, endOfParams + 1);
startOfParams = locateFirstBracket(erasureSig);
- if (startOfParams != -1)
+ if (startOfParams != -1) {
endOfParams = locateMatchingEndBracket(erasureSig, startOfParams);
+ }
}
String signatureErasure = "L" + erasureSig.toString().substring(1);
// if the signature is 'PMyInterface<String>$MyOtherType;' then there are none...
String lastType = null;
int nestedTypePosition = signature.indexOf("$", endOfParams); // don't look for $ INSIDE the parameters
- if (nestedTypePosition != -1)
+ if (nestedTypePosition != -1) {
lastType = signature.substring(nestedTypePosition + 1);
- else
+ } else {
lastType = new String(signature);
+ }
startOfParams = lastType.indexOf("<");
endOfParams = locateMatchingEndBracket(lastType, startOfParams);
UnresolvedType[] typeParams = UnresolvedType.NONE;
return new UnresolvedTypeVariableReferenceType(new TypeVariable(typeVariableName));
} else if (firstChar == '[') {
int dims = 0;
- while (signature.charAt(dims) == '[')
+ while (signature.charAt(dims) == '[') {
dims++;
+ }
UnresolvedType componentType = createTypeFromSignature(signature.substring(dims));
return new UnresolvedType(signature, signature.substring(0, dims) + componentType.getErasureSignature());
} else if (signature.length() == 1) { // could be a primitive
}
private static int locateMatchingEndBracket(String signature, int startOfParams) {
- if (startOfParams == -1)
+ if (startOfParams == -1) {
return -1;
+ }
int count = 1;
int idx = startOfParams;
while (count > 0 && idx < signature.length()) {
idx++;
- if (signature.charAt(idx) == '<')
+ if (signature.charAt(idx) == '<') {
count++;
- if (signature.charAt(idx) == '>')
+ }
+ if (signature.charAt(idx) == '>') {
count--;
+ }
}
return idx;
}
private static int locateMatchingEndBracket(StringBuffer signature, int startOfParams) {
- if (startOfParams == -1)
+ if (startOfParams == -1) {
return -1;
+ }
int count = 1;
int idx = startOfParams;
while (count > 0 && idx < signature.length()) {
idx++;
- if (signature.charAt(idx) == '<')
+ if (signature.charAt(idx) == '<') {
count++;
- if (signature.charAt(idx) == '>')
+ }
+ if (signature.charAt(idx) == '>') {
count--;
+ }
}
return idx;
}
private static int locateFirstBracket(StringBuffer signature) {
int idx = 0;
while (idx < signature.length()) {
- if (signature.charAt(idx) == '<')
+ if (signature.charAt(idx) == '<') {
return idx;
+ }
idx++;
}
return -1;
/**
* Equality is checked based on the underlying signature. {@link ResolvedType} objects' equals is by reference.
*/
+ @Override
public boolean equals(Object other) {
- if (!(other instanceof UnresolvedType))
+ if (!(other instanceof UnresolvedType)) {
return false;
+ }
return signature.equals(((UnresolvedType) other).signature);
}
* Equality is checked based on the underlying signature, so the hash code of a particular type is the hash code of its
* signature string.
*/
+ @Override
public final int hashCode() {
return signature.hashCode();
}
this.signature = signature;
this.signatureErasure = signatureErasure;
this.typeParameters = typeParams;
- if (typeParams != null)
+ if (typeParams != null) {
this.typeKind = TypeKind.PARAMETERIZED;
+ }
}
// ---- Things we can do without a world
public static UnresolvedType makeArray(UnresolvedType base, int dims) {
StringBuffer sig = new StringBuffer();
- for (int i = 0; i < dims; i++)
+ for (int i = 0; i < dims; i++) {
sig.append("[");
+ }
sig.append(base.getSignature());
return UnresolvedType.forSignature(sig.toString());
}
public String getBaseName() {
String name = getName();
if (isParameterizedType() || isGenericType()) {
- if (typeParameters == null)
+ if (typeParameters == null) {
return name;
- else
+ } else {
return name.substring(0, name.indexOf("<"));
+ }
} else {
return name;
}
* For parameterized types, return the signature for the raw type
*/
public String getErasureSignature() {
- if (signatureErasure == null)
+ if (signatureErasure == null) {
return signature;
+ }
return signatureErasure;
}
* @return the outermost enclosing UnresolvedType object or this.
*/
public UnresolvedType getOutermostType() {
- if (isArray() || isPrimitiveType())
+ if (isArray() || isPrimitiveType()) {
return this;
+ }
String sig = getErasureSignature();
int dollar = sig.indexOf('$');
if (dollar != -1) {
/**
* Returns a java language string representation of this type.
*/
+ @Override
public String toString() {
return getName(); // + " - " + getKind();
}
StringBuffer innerBuff = new StringBuffer();
while (paramNestLevel > 0) {
c = signature.charAt(++i);
- if (c == '<')
+ if (c == '<') {
paramNestLevel++;
- if (c == '>')
+ }
+ if (c == '>') {
paramNestLevel--;
- if (paramNestLevel > 0)
+ }
+ if (paramNestLevel > 0) {
innerBuff.append(c);
+ }
if (c == ';' && paramNestLevel == 1) {
nameBuff.append(signatureToName(innerBuff.toString()));
- if (signature.charAt(i + 1) != '>')
+ if (signature.charAt(i + 1) != '>') {
nameBuff.append(',');
+ }
innerBuff = new StringBuffer();
}
}
}
private static String nameToSignature(String name) {
- if (name.equals("byte"))
+ if (name.equals("byte")) {
return "B";
- if (name.equals("char"))
+ }
+ if (name.equals("char")) {
return "C";
- if (name.equals("double"))
+ }
+ if (name.equals("double")) {
return "D";
- if (name.equals("float"))
+ }
+ if (name.equals("float")) {
return "F";
- if (name.equals("int"))
+ }
+ if (name.equals("int")) {
return "I";
- if (name.equals("long"))
+ }
+ if (name.equals("long")) {
return "J";
- if (name.equals("short"))
+ }
+ if (name.equals("short")) {
return "S";
- if (name.equals("boolean"))
+ }
+ if (name.equals("boolean")) {
return "Z";
- if (name.equals("void"))
+ }
+ if (name.equals("void")) {
return "V";
- if (name.equals("?"))
+ }
+ if (name.equals("?")) {
return name;
- if (name.endsWith("[]"))
+ }
+ if (name.endsWith("[]")) {
return "[" + nameToSignature(name.substring(0, name.length() - 2));
+ }
if (name.length() != 0) {
// lots more tests could be made here...
StringBuffer innerBuff = new StringBuffer();
while (nestLevel > 0) {
c = name.charAt(++i);
- if (c == '<')
+ if (c == '<') {
nestLevel++;
- if (c == '>')
+ }
+ if (c == '>') {
nestLevel--;
+ }
if (c == ',' && nestLevel == 1) {
nameBuff.append(nameToSignature(innerBuff.toString()));
innerBuff = new StringBuffer();
} else {
- if (nestLevel > 0)
+ if (nestLevel > 0) {
innerBuff.append(c);
+ }
}
}
nameBuff.append(nameToSignature(innerBuff.toString()));
nameBuff.append(";");
return nameBuff.toString();
}
- } else
+ } else {
throw new BCException("Bad type name: " + name);
+ }
}
public void write(DataOutputStream s) throws IOException {
public static UnresolvedType[] readArray(DataInputStream s) throws IOException {
int len = s.readShort();
- if (len == 0)
+ if (len == 0) {
return UnresolvedType.NONE;
+ }
UnresolvedType[] types = new UnresolvedType[len];
for (int i = 0; i < len; i++) {
types[i] = UnresolvedType.read(s);
public final static TypeKind TYPE_VARIABLE = new TypeKind("type_variable"); // a type variable
public final static TypeKind WILDCARD = new TypeKind("wildcard"); // a generic wildcard type
+ @Override
public String toString() {
return type;
}
public TypeVariable getTypeVariableNamed(String name) {
TypeVariable[] vars = getTypeVariables();
- if (vars == null || vars.length == 0)
+ if (vars == null || vars.length == 0) {
return null;
+ }
for (int i = 0; i < vars.length; i++) {
TypeVariable aVar = vars[i];
- if (aVar.getName().equals(name))
+ if (aVar.getName().equals(name)) {
return aVar;
+ }
}
return null;
}
*/
protected World() {
super();
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.enter("<init>", this);
+ }
Dump.registerNode(this.getClass(), this);
typeMap.put("B", ResolvedType.BYTE);
typeMap.put("S", ResolvedType.SHORT);
typeMap.put("Z", ResolvedType.BOOLEAN);
typeMap.put("V", ResolvedType.VOID);
precedenceCalculator = new AspectPrecedenceCalculator(this);
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.exit("<init>");
+ }
}
/**
* signatures.
*/
public ResolvedType[] resolve(UnresolvedType[] types) {
- if (types == null)
+ if (types == null) {
return new ResolvedType[0];
+ }
ResolvedType[] ret = new ResolvedType[types.length];
for (int i = 0; i < types.length; i++) {
* them there. Resolved types are also told their world which is needed for the special autoboxing resolved types.
*/
public ResolvedType resolve(ResolvedType ty) {
- if (ty.isTypeVariableReference())
+ if (ty.isTypeVariableReference()) {
return ty; // until type variables have proper sigs...
+ }
ResolvedType resolved = typeMap.get(ty.getSignature());
if (resolved == null) {
typeMap.put(ty.getSignature(), ty);
if (ty.isParameterizedType()) {
// ======= parameterized types ================
ResolvedType rt = resolveGenericTypeFor(ty, allowMissing);
- if (rt.isMissing())
+ if (rt.isMissing()) {
return rt;
+ }
ReferenceType genericType = (ReferenceType) rt;
ReferenceType parameterizedType = TypeFactory.createParameterizedType(genericType, ty.typeParameters, this);
return parameterizedType;
// ======= simple and raw types ===============
String erasedSignature = ty.getErasureSignature();
ReferenceType simpleOrRawType = new ReferenceType(erasedSignature, this);
- if (ty.needsModifiableDelegate())
+ if (ty.needsModifiableDelegate()) {
simpleOrRawType.setNeedsModifiableDelegate(true);
+ }
ReferenceTypeDelegate delegate = resolveDelegate(simpleOrRawType);
// 117854
// if (delegate == null) return ResolvedType.MISSING;
- if (delegate == null)
+ if (delegate == null) {
return new MissingResolvedTypeWithKnownSignature(ty.getSignature(), erasedSignature, this);// ResolvedType
- // .
- // MISSING
- // ;
+ // .
+ // MISSING
+ // ;
+ }
if (delegate.isGeneric() && behaveInJava5Way) {
// ======== raw type ===========
rawType = resolve(UnresolvedType.forSignature(rawSignature), allowMissing);
typeMap.put(rawSignature, rawType);
}
- if (rawType.isMissing())
+ if (rawType.isMissing()) {
return rawType;
+ }
// Does the raw type know its generic form? (It will if we created the
// raw type from a source type, it won't if its been created just
*/
public ResolvedMember resolve(Member member) {
ResolvedType declaring = member.getDeclaringType().resolve(this);
- if (declaring.isRawType())
+ if (declaring.isRawType()) {
declaring = declaring.getGenericType();
+ }
ResolvedMember ret;
if (member.getKind() == Member.FIELD) {
ret = declaring.lookupField(member);
ret = declaring.lookupMethod(member);
}
- if (ret != null)
+ if (ret != null) {
return ret;
+ }
return declaring.lookupSyntheticMember(member);
}
public boolean isIgnoringUnusedDeclaredThrownException() {
// the 0x800000 is CompilerOptions.UnusedDeclaredThrownException
// which is ASTNode.bit24
- if ((errorThreshold & 0x800000) != 0 || (warningThreshold & 0x800000) != 0)
+ if ((errorThreshold & 0x800000) != 0 || (warningThreshold & 0x800000) != 0) {
return false;
+ }
return true;
}
public void performExtraConfiguration(String config) {
- if (config == null)
+ if (config == null) {
return;
+ }
// Bunch of name value pairs to split
extraConfiguration = new Properties();
int pos = -1;
}
public void setOptionalJoinpoints(String jps) {
- if (jps == null)
+ if (jps == null) {
return;
- if (jps.indexOf("arrayconstruction") != -1)
+ }
+ if (jps.indexOf("arrayconstruction") != -1) {
optionalJoinpoint_ArrayConstruction = true;
- if (jps.indexOf("synchronization") != -1)
+ }
+ if (jps.indexOf("synchronization") != -1) {
optionalJoinpoint_Synchronization = true;
+ }
}
public boolean isJoinpointArrayConstructionEnabled() {
// the old runtime?
public boolean isTargettingAspectJRuntime12() {
boolean b = false; // pr116679
- if (!isInJava5Mode())
+ if (!isInJava5Mode()) {
b = true;
- else
+ } else {
b = getTargetAspectjRuntimeLevel().equals(org.aspectj.weaver.Constants.RUNTIME_LEVEL_12);
+ }
// System.err.println("Asked if targetting runtime 1.2 , returning: "+b);
return b;
}
return type;
}
if (type.isParameterizedType() && type.isParameterizedWithTypeVariable()) {
- if (debug)
+ if (debug) {
System.err
.println("Not putting a parameterized type that utilises member declared type variables into the typemap: key="
+ key + " type=" + type);
+ }
return type;
}
if (type.isTypeVariableReference()) {
- if (debug)
+ if (debug) {
System.err.println("Not putting a type variable reference type into the typemap: key=" + key + " type=" + type);
+ }
return type;
}
// this test should be improved - only avoid putting them in if one
// of the
// bounds is a member type variable
if (type instanceof BoundedReferenceType) {
- if (debug)
+ if (debug) {
System.err.println("Not putting a bounded reference type into the typemap: key=" + key + " type=" + type);
+ }
return type;
}
if (type instanceof MissingResolvedTypeWithKnownSignature) {
- if (debug)
+ if (debug) {
System.err.println("Not putting a missing type into the typemap: key=" + key + " type=" + type);
+ }
return type;
}
if ((type instanceof ReferenceType) && (((ReferenceType) type).getDelegate() == null) && w.isExpendable(type)) {
- if (debug)
+ if (debug) {
System.err.println("Not putting expendable ref type with null delegate into typemap: key=" + key + " type="
+ type);
+ }
return type;
}
if (w.isExpendable(type)) {
// Dont use reference queue for tracking if not profiling...
if (policy == USE_WEAK_REFS) {
- if (memoryProfiling)
+ if (memoryProfiling) {
expendableMap.put(key, new WeakReference(type, rq));
- else
+ } else {
expendableMap.put(key, new WeakReference(type));
+ }
} else if (policy == USE_SOFT_REFS) {
- if (memoryProfiling)
+ if (memoryProfiling) {
expendableMap.put(key, new SoftReference(type, rq));
- else
+ } else {
expendableMap.put(key, new SoftReference(type));
+ }
} else {
expendableMap.put(key, type);
}
}
public void report() {
- if (!memoryProfiling)
+ if (!memoryProfiling) {
return;
+ }
checkq();
w.getMessageHandler().handleMessage(
MessageUtil.info("MEMORY: world expendable type map reached maximum size of #" + maxExpendableMapSize
}
public void checkq() {
- if (!memoryProfiling)
+ if (!memoryProfiling) {
return;
- while (rq.poll() != null)
+ }
+ while (rq.poll() != null) {
collectedTypes++;
+ }
}
/**
if (ret == null) {
if (policy == USE_WEAK_REFS) {
WeakReference wref = (WeakReference) expendableMap.remove(key);
- if (wref != null)
+ if (wref != null) {
ret = (ResolvedType) wref.get();
+ }
} else if (policy == USE_SOFT_REFS) {
SoftReference wref = (SoftReference) expendableMap.remove(key);
- if (wref != null)
+ if (wref != null) {
ret = (ResolvedType) wref.get();
+ }
} else {
ret = (ResolvedType) expendableMap.remove(key);
}
DeclarePrecedence d = (DeclarePrecedence) i.next();
int thisOrder = d.compare(firstAspect, secondAspect);
if (thisOrder != 0) {
- if (orderer == null)
+ if (orderer == null) {
orderer = d;
+ }
if (order != 0 && order != thisOrder) {
ISourceLocation[] isls = new ISourceLocation[2];
isls[0] = orderer.getSourceLocation();
}
public int compareByPrecedenceAndHierarchy(ResolvedType firstAspect, ResolvedType secondAspect) {
- if (firstAspect.equals(secondAspect))
+ if (firstAspect.equals(secondAspect)) {
return 0;
+ }
int ret = compareByPrecedence(firstAspect, secondAspect);
- if (ret != 0)
+ if (ret != 0) {
return ret;
+ }
- if (firstAspect.isAssignableFrom(secondAspect))
+ if (firstAspect.isAssignableFrom(secondAspect)) {
return -1;
- else if (secondAspect.isAssignableFrom(firstAspect))
+ } else if (secondAspect.isAssignableFrom(firstAspect)) {
return +1;
+ }
return 0;
}
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof PrecedenceCacheKey))
+ if (!(obj instanceof PrecedenceCacheKey)) {
return false;
+ }
PrecedenceCacheKey other = (PrecedenceCacheKey) obj;
return (aspect1 == other.aspect1 && aspect2 == other.aspect2);
}
}
public void setSynchronizationPointcutsInUse() {
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.enter("setSynchronizationPointcutsInUse", this);
+ }
synchronizationPointcutsInUse = true;
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.exit("setSynchronizationPointcutsInUse");
+ }
}
public boolean areSynchronizationPointcutsInUse() {
* @param designatorHandler handler for the new pointcut
*/
public void registerPointcutHandler(PointcutDesignatorHandler designatorHandler) {
- if (pointcutDesignators == null)
+ if (pointcutDesignators == null) {
pointcutDesignators = new HashSet();
+ }
pointcutDesignators.add(designatorHandler);
}
public Set getRegisteredPointcutHandlers() {
- if (pointcutDesignators == null)
+ if (pointcutDesignators == null) {
return Collections.EMPTY_SET;
+ }
return pointcutDesignators;
}