Browse Source

formatted

tags/V1_6_6
aclement 14 years ago
parent
commit
53368cb03d
47 changed files with 1268 additions and 1226 deletions
  1. 3
    1
      org.aspectj.matcher/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java
  2. 88
    70
      org.aspectj.matcher/src/org/aspectj/weaver/AdviceKind.java
  3. 11
    17
      org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java
  4. 2
    2
      org.aspectj.matcher/src/org/aspectj/weaver/AnnotationAJ.java
  5. 5
    5
      org.aspectj.matcher/src/org/aspectj/weaver/AnnotationAnnotationValue.java
  6. 19
    19
      org.aspectj.matcher/src/org/aspectj/weaver/AnnotationNameValuePair.java
  7. 1
    2
      org.aspectj.matcher/src/org/aspectj/weaver/AnnotationOnTypeMunger.java
  8. 23
    15
      org.aspectj.matcher/src/org/aspectj/weaver/AnnotationTargetKind.java
  9. 40
    41
      org.aspectj.matcher/src/org/aspectj/weaver/AnnotationValue.java
  10. 11
    9
      org.aspectj.matcher/src/org/aspectj/weaver/ArrayAnnotationValue.java
  11. 37
    33
      org.aspectj.matcher/src/org/aspectj/weaver/BCException.java
  12. 1
    1
      org.aspectj.matcher/src/org/aspectj/weaver/BindingScope.java
  13. 5
    5
      org.aspectj.matcher/src/org/aspectj/weaver/ClassAnnotationValue.java
  14. 6
    8
      org.aspectj.matcher/src/org/aspectj/weaver/Constants.java
  15. 12
    18
      org.aspectj.matcher/src/org/aspectj/weaver/CustomMungerFactory.java
  16. 213
    208
      org.aspectj.matcher/src/org/aspectj/weaver/Dump.java
  17. 7
    7
      org.aspectj.matcher/src/org/aspectj/weaver/EnumAnnotationValue.java
  18. 3
    2
      org.aspectj.matcher/src/org/aspectj/weaver/ExposeTypeMunger.java
  19. 1
    0
      org.aspectj.matcher/src/org/aspectj/weaver/GeneratedReferenceTypeDelegate.java
  20. 13
    14
      org.aspectj.matcher/src/org/aspectj/weaver/IClassFileProvider.java
  21. 9
    10
      org.aspectj.matcher/src/org/aspectj/weaver/IClassWeaver.java
  22. 0
    1
      org.aspectj.matcher/src/org/aspectj/weaver/IEclipseSourceContext.java
  23. 12
    13
      org.aspectj.matcher/src/org/aspectj/weaver/IHasPosition.java
  24. 1
    1
      org.aspectj.matcher/src/org/aspectj/weaver/IHasSourceLocation.java
  25. 1
    0
      org.aspectj.matcher/src/org/aspectj/weaver/IUnwovenClassFile.java
  26. 0
    1
      org.aspectj.matcher/src/org/aspectj/weaver/IWeaveRequestor.java
  27. 11
    14
      org.aspectj.matcher/src/org/aspectj/weaver/LintMessage.java
  28. 8
    14
      org.aspectj.matcher/src/org/aspectj/weaver/Member.java
  29. 51
    93
      org.aspectj.matcher/src/org/aspectj/weaver/MemberImpl.java
  30. 29
    18
      org.aspectj.matcher/src/org/aspectj/weaver/MemberKind.java
  31. 82
    56
      org.aspectj.matcher/src/org/aspectj/weaver/MissingResolvedTypeWithKnownSignature.java
  32. 62
    58
      org.aspectj.matcher/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java
  33. 17
    16
      org.aspectj.matcher/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java
  34. 1
    1
      org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java
  35. 1
    2
      org.aspectj.matcher/src/org/aspectj/weaver/Position.java
  36. 28
    25
      org.aspectj.matcher/src/org/aspectj/weaver/PrivilegedAccessMunger.java
  37. 9
    7
      org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java
  38. 191
    197
      org.aspectj.matcher/src/org/aspectj/weaver/SignatureUtils.java
  39. 69
    41
      org.aspectj.matcher/src/org/aspectj/weaver/SimpleAnnotationValue.java
  40. 37
    39
      org.aspectj.matcher/src/org/aspectj/weaver/StaticJoinPointFactory.java
  41. 2
    4
      org.aspectj.matcher/src/org/aspectj/weaver/TypeVariableDeclaringElement.java
  42. 2
    2
      org.aspectj.matcher/src/org/aspectj/weaver/TypeVariableReference.java
  43. 24
    26
      org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java
  44. 21
    8
      org.aspectj.matcher/src/org/aspectj/weaver/VersionedDataInputStream.java
  45. 60
    62
      org.aspectj.matcher/src/org/aspectj/weaver/WeaverMessages.java
  46. 37
    36
      org.aspectj.matcher/src/org/aspectj/weaver/WildcardedUnresolvedType.java
  47. 2
    4
      org.aspectj.matcher/src/org/aspectj/weaver/World.java

+ 3
- 1
org.aspectj.matcher/src/org/aspectj/weaver/AbstractReferenceTypeDelegate.java View File

List typeParameters = new ArrayList(); List typeParameters = new ArrayList();
ResolvedType outerClassType = getOuterClass(); ResolvedType outerClassType = getOuterClass();
if (!(outerClassType instanceof ReferenceType)) { if (!(outerClassType instanceof ReferenceType)) {
throw new BCException("Whilst processing type '"+this.resolvedTypeX.getSignature()+"' - cannot cast the outer type to a reference type. Signature="+outerClassType.getSignature()+" toString()="+outerClassType.toString());
throw new BCException("Whilst processing type '" + this.resolvedTypeX.getSignature()
+ "' - cannot cast the outer type to a reference type. Signature=" + outerClassType.getSignature()
+ " toString()=" + outerClassType.toString());
} }
ReferenceType outer = (ReferenceType) outerClassType; ReferenceType outer = (ReferenceType) outerClassType;
ReferenceTypeDelegate outerDelegate = outer.getDelegate(); ReferenceTypeDelegate outerDelegate = outer.getDelegate();

+ 88
- 70
org.aspectj.matcher/src/org/aspectj/weaver/AdviceKind.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/



package org.aspectj.weaver; package org.aspectj.weaver;


import java.io.IOException; import java.io.IOException;
private int precedence; private int precedence;
private boolean isAfter; private boolean isAfter;
private boolean isCflow; private boolean isCflow;
public AdviceKind(String name, int key, int precedence, boolean isAfter, boolean isCflow) {
super(name, key);
this.precedence = precedence;
this.isAfter = isAfter;
this.isCflow = isCflow;
}
public static AdviceKind read(VersionedDataInputStream s) throws IOException {
int key = s.readByte();
switch(key) {
case 1: return Before;
case 2: return After;
case 3: return AfterThrowing;
case 4: return AfterReturning;
case 5: return Around;
case 6: return CflowEntry;
case 7: return CflowBelowEntry;

case 8: return InterInitializer;
case 9: return PerCflowEntry;
case 10: return PerCflowBelowEntry;
case 11: return PerThisEntry;
case 12: return PerTargetEntry;

case 13: return Softener;
case 14: return PerTypeWithinEntry;
}
throw new RuntimeException("unimplemented kind: " + key);
}
public static final AdviceKind Before = new AdviceKind("before", 1, 0, false, false);
public static final AdviceKind After = new AdviceKind("after", 2, 0, true, false);
public static final AdviceKind AfterThrowing = new AdviceKind("afterThrowing", 3, 0, true, false);
public static final AdviceKind AfterReturning = new AdviceKind("afterReturning", 4, 0, true, false);
public static final AdviceKind Around = new AdviceKind("around", 5, 0, false, false);
// these kinds can't be declared, but are used by the weaver
public static final AdviceKind CflowEntry = new AdviceKind("cflowEntry", 6, 1, false, true);
public static final AdviceKind CflowBelowEntry = new AdviceKind("cflowBelowEntry", 7, -1, false, true); //XXX resolve precednece with the below
public static final AdviceKind InterInitializer = new AdviceKind("interInitializer", 8, -2, false, false);

public static final AdviceKind PerCflowEntry = new AdviceKind("perCflowEntry", 9, 1, false, true);
public static final AdviceKind PerCflowBelowEntry = new AdviceKind("perCflowBelowEntry", 10, -1, false, true);

public static final AdviceKind PerThisEntry = new AdviceKind("perThisEntry", 11, 1, false, false);
public static final AdviceKind PerTargetEntry = new AdviceKind("perTargetEntry", 12, 1, false, false);

public static final AdviceKind Softener = new AdviceKind("softener", 13, 1, false, false);
// PTWIMPL Advice representing when aspect should be initialized
public static final AdviceKind PerTypeWithinEntry = new AdviceKind("perTypeWithinEntry",14,1,false,false);

public static AdviceKind stringToKind(String s) {
if (s.equals(Before.getName())) return Before;
if (s.equals(After.getName())) return After;
if (s.equals(AfterThrowing.getName())) return AfterThrowing;
if (s.equals(AfterReturning.getName())) return AfterReturning;
if (s.equals(Around.getName())) return Around;
throw new IllegalArgumentException("unknown kind: " + "\"" + s + "\"");
}

public AdviceKind(String name, int key, int precedence, boolean isAfter, boolean isCflow) {
super(name, key);
this.precedence = precedence;
this.isAfter = isAfter;
this.isCflow = isCflow;
}

public static AdviceKind read(VersionedDataInputStream s) throws IOException {
int key = s.readByte();
switch (key) {
case 1:
return Before;
case 2:
return After;
case 3:
return AfterThrowing;
case 4:
return AfterReturning;
case 5:
return Around;
case 6:
return CflowEntry;
case 7:
return CflowBelowEntry;

case 8:
return InterInitializer;

case 9:
return PerCflowEntry;
case 10:
return PerCflowBelowEntry;
case 11:
return PerThisEntry;
case 12:
return PerTargetEntry;

case 13:
return Softener;

case 14:
return PerTypeWithinEntry;
}
throw new RuntimeException("unimplemented kind: " + key);
}

public static final AdviceKind Before = new AdviceKind("before", 1, 0, false, false);
public static final AdviceKind After = new AdviceKind("after", 2, 0, true, false);
public static final AdviceKind AfterThrowing = new AdviceKind("afterThrowing", 3, 0, true, false);
public static final AdviceKind AfterReturning = new AdviceKind("afterReturning", 4, 0, true, false);
public static final AdviceKind Around = new AdviceKind("around", 5, 0, false, false);

// these kinds can't be declared, but are used by the weaver
public static final AdviceKind CflowEntry = new AdviceKind("cflowEntry", 6, 1, false, true);
public static final AdviceKind CflowBelowEntry = new AdviceKind("cflowBelowEntry", 7, -1, false, true); // XXX resolve
// precednece with the
// below
public static final AdviceKind InterInitializer = new AdviceKind("interInitializer", 8, -2, false, false);

public static final AdviceKind PerCflowEntry = new AdviceKind("perCflowEntry", 9, 1, false, true);
public static final AdviceKind PerCflowBelowEntry = new AdviceKind("perCflowBelowEntry", 10, -1, false, true);

public static final AdviceKind PerThisEntry = new AdviceKind("perThisEntry", 11, 1, false, false);
public static final AdviceKind PerTargetEntry = new AdviceKind("perTargetEntry", 12, 1, false, false);

public static final AdviceKind Softener = new AdviceKind("softener", 13, 1, false, false);

// PTWIMPL Advice representing when aspect should be initialized
public static final AdviceKind PerTypeWithinEntry = new AdviceKind("perTypeWithinEntry", 14, 1, false, false);

public static AdviceKind stringToKind(String s) {
if (s.equals(Before.getName()))
return Before;
if (s.equals(After.getName()))
return After;
if (s.equals(AfterThrowing.getName()))
return AfterThrowing;
if (s.equals(AfterReturning.getName()))
return AfterReturning;
if (s.equals(Around.getName()))
return Around;
throw new IllegalArgumentException("unknown kind: " + "\"" + s + "\"");
}


public boolean isAfter() { public boolean isAfter() {
return this.isAfter; return this.isAfter;
} }
public boolean isCflow() { public boolean isCflow() {
return this.isCflow; return this.isCflow;
} }
} }


public boolean isPerEntry() { public boolean isPerEntry() {
return
this == PerCflowEntry || this == PerCflowBelowEntry ||
this == PerThisEntry || this == PerTargetEntry ||
this == PerTypeWithinEntry; // PTWIMPL Allow for PTW case
return this == PerCflowEntry || this == PerCflowBelowEntry || this == PerThisEntry || this == PerTargetEntry
|| this == PerTypeWithinEntry; // PTWIMPL Allow for PTW case
} }

public boolean isPerObjectEntry() { public boolean isPerObjectEntry() {
return this == PerThisEntry || this == PerTargetEntry; return this == PerThisEntry || this == PerTargetEntry;
} }

+ 11
- 17
org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java View File

import org.aspectj.weaver.patterns.Pointcut; import org.aspectj.weaver.patterns.Pointcut;


/** /**
* These attributes are written to and read from .class files (see the JVM
* spec).
* These attributes are written to and read from .class files (see the JVM spec).
* *
* <p> * <p>
* Each member or type can have a number of AjAttributes. Each such attribute is
* in 1-1 correspondence with an Unknown bcel attribute. Creating one of these
* does NOTHING to the underlying thing, so if you really want to add an
* attribute to a particular thing, well, you'd better actually do that.
* Each member or type can have a number of AjAttributes. Each such attribute is in 1-1 correspondence with an Unknown bcel
* attribute. Creating one of these does NOTHING to the underlying thing, so if you really want to add an attribute to a particular
* thing, well, you'd better actually do that.
* *
* @author Erik Hilsdale * @author Erik Hilsdale
* @author Jim Hugunin * @author Jim Hugunin
// ---- // ----


/** /**
* Synthetic members should have NO advice put on them or on their contents.
* This attribute is currently unused as we consider all members starting
* with NameMangler.PREFIX to automatically be synthetic. As we use this we
* might find that we want multiple kinds of synthetic. In particular, if we
* want to treat the call to a synthetic getter (say, of an introduced
* field) as a field reference itself, then a method might want a particular
* kind of AjSynthetic attribute that also includes a signature of what it
* stands for.
* Synthetic members should have NO advice put on them or on their contents. This attribute is currently unused as we consider
* all members starting with NameMangler.PREFIX to automatically be synthetic. As we use this we might find that we want
* multiple kinds of synthetic. In particular, if we want to treat the call to a synthetic getter (say, of an introduced field)
* as a field reference itself, then a method might want a particular kind of AjSynthetic attribute that also includes a
* signature of what it stands for.
*/ */
public static class AjSynthetic extends AjAttribute { public static class AjSynthetic extends AjAttribute {
public static final String AttributeName = "org.aspectj.weaver.AjSynthetic"; public static final String AttributeName = "org.aspectj.weaver.AjSynthetic";
private UnresolvedType[] declaredExceptions; private UnresolvedType[] declaredExceptions;


/** /**
* @param lexicalPosition must be greater than the lexicalPosition of
* any advice declared before this one in an aspect,
* otherwise, it can be any value.
* @param lexicalPosition must be greater than the lexicalPosition of any advice declared before this one in an aspect,
* otherwise, it can be any value.
*/ */
public AdviceAttribute(AdviceKind kind, Pointcut pointcut, int extraArgumentFlags, int start, int end, public AdviceAttribute(AdviceKind kind, Pointcut pointcut, int extraArgumentFlags, int start, int end,
ISourceContext sourceContext) { ISourceContext sourceContext) {

+ 2
- 2
org.aspectj.matcher/src/org/aspectj/weaver/AnnotationAJ.java View File

public boolean isRuntimeVisible(); public boolean isRuntimeVisible();


/** /**
* Determine the string representation of the value of a field. For example in @SuppressAjWarnings({"adviceDidNotMatch"})
* the return value for getStringFormOfValue("value") would be "[adviceDidNotMatch]".
* Determine the string representation of the value of a field. For example in @SuppressAjWarnings({"adviceDidNotMatch"}) the
* return value for getStringFormOfValue("value") would be "[adviceDidNotMatch]".
* *
* @param name the name of the annotation field being looked up * @param name the name of the annotation field being looked up
* @return string representation of the value of that field, may be null if no such field set * @return string representation of the value of that field, may be null if no such field set

+ 5
- 5
org.aspectj.matcher/src/org/aspectj/weaver/AnnotationAnnotationValue.java View File

* Contributors: * Contributors:
* Andy Clement IBM initial implementation * Andy Clement IBM initial implementation
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;


public class AnnotationAnnotationValue extends AnnotationValue { public class AnnotationAnnotationValue extends AnnotationValue {


private AnnotationAJ value; private AnnotationAJ value;
public AnnotationAnnotationValue(AnnotationAJ value) { public AnnotationAnnotationValue(AnnotationAJ value) {
super(AnnotationValue.ANNOTATION); super(AnnotationValue.ANNOTATION);
this.value = value; this.value = value;
} }
public AnnotationAJ getAnnotation() { public AnnotationAJ getAnnotation() {
return value; return value;
} }
public String stringify() { public String stringify() {
return value.stringify(); return value.stringify();
} }
public String toString() { public String toString() {
return value.toString(); return value.toString();
} }

+ 19
- 19
org.aspectj.matcher/src/org/aspectj/weaver/AnnotationNameValuePair.java View File

* Contributors: * Contributors:
* Andy Clement IBM initial implementation * Andy Clement IBM initial implementation
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;


public class AnnotationNameValuePair { public class AnnotationNameValuePair {
private String name; private String name;
private AnnotationValue val; private AnnotationValue val;


public AnnotationNameValuePair(String name,AnnotationValue val) {
this.name = name;
this.val = val;
}
public String getName() {
return name;
}
public AnnotationValue getValue() {
return val;
}
public String toString() {
public AnnotationNameValuePair(String name, AnnotationValue val) {
this.name = name;
this.val = val;
}
public String getName() {
return name;
}
public AnnotationValue getValue() {
return val;
}
public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append(name+"="+val.toString());
sb.append(name + "=" + val.toString());
return sb.toString(); return sb.toString();
} }


public String stringify() { public String stringify() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (!name.equals("value")) { if (!name.equals("value")) {
sb.append(name+"=");
sb.append(name + "=");
} }
sb.append(val.stringify()); sb.append(val.stringify());
return sb.toString(); return sb.toString();

+ 1
- 2
org.aspectj.matcher/src/org/aspectj/weaver/AnnotationOnTypeMunger.java View File

return false; return false;
AnnotationOnTypeMunger o = (AnnotationOnTypeMunger) other; AnnotationOnTypeMunger o = (AnnotationOnTypeMunger) other;
// TODO does not check equality of annotation values // TODO does not check equality of annotation values
return newAnnotation.getTypeSignature().equals(
o.newAnnotation.getTypeSignature());
return newAnnotation.getTypeSignature().equals(o.newAnnotation.getTypeSignature());
} }


private volatile int hashCode = 0; private volatile int hashCode = 0;

+ 23
- 15
org.aspectj.matcher/src/org/aspectj/weaver/AnnotationTargetKind.java View File

public AnnotationTargetKind(String name, int key) { public AnnotationTargetKind(String name, int key) {
super(name, key); super(name, key);
} }
public static AnnotationTargetKind read(DataInputStream s) throws IOException {
int key = s.readByte();
switch(key) {
case 1: return ANNOTATION_TYPE;
case 2: return CONSTRUCTOR;
case 3: return FIELD;
case 4: return LOCAL_VARIABLE;
case 5: return METHOD;
case 6: return PACKAGE;
case 7: return PARAMETER;
case 8: return TYPE;
}
throw new BCException("weird annotation target kind " + key);
}

public static AnnotationTargetKind read(DataInputStream s) throws IOException {
int key = s.readByte();
switch (key) {
case 1:
return ANNOTATION_TYPE;
case 2:
return CONSTRUCTOR;
case 3:
return FIELD;
case 4:
return LOCAL_VARIABLE;
case 5:
return METHOD;
case 6:
return PACKAGE;
case 7:
return PARAMETER;
case 8:
return TYPE;
}
throw new BCException("weird annotation target kind " + key);
}


public static final AnnotationTargetKind ANNOTATION_TYPE = new AnnotationTargetKind("ANNOTATION_TYPE", 1); public static final AnnotationTargetKind ANNOTATION_TYPE = new AnnotationTargetKind("ANNOTATION_TYPE", 1);
public static final AnnotationTargetKind CONSTRUCTOR = new AnnotationTargetKind("CONSTRUCTOR", 2); public static final AnnotationTargetKind CONSTRUCTOR = new AnnotationTargetKind("CONSTRUCTOR", 2);

+ 40
- 41
org.aspectj.matcher/src/org/aspectj/weaver/AnnotationValue.java View File

* Contributors: * Contributors:
* Andy Clement IBM initial implementation * Andy Clement IBM initial implementation
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;

package org.aspectj.weaver;


public abstract class AnnotationValue { public abstract class AnnotationValue {
protected int valueKind; protected int valueKind;


public static final int STRING = 's'; public static final int STRING = 's';
public static final int CLASS = 'c'; public static final int CLASS = 'c';
public static final int ANNOTATION = '@'; public static final int ANNOTATION = '@';
public static final int ARRAY = '['; public static final int ARRAY = '[';
public static final int PRIMITIVE_INT = 'I';
public static final int PRIMITIVE_BYTE = 'B';
public static final int PRIMITIVE_CHAR = 'C';
public static final int PRIMITIVE_INT = 'I';
public static final int PRIMITIVE_BYTE = 'B';
public static final int PRIMITIVE_CHAR = 'C';
public static final int PRIMITIVE_DOUBLE = 'D'; public static final int PRIMITIVE_DOUBLE = 'D';
public static final int PRIMITIVE_FLOAT = 'F';
public static final int PRIMITIVE_LONG = 'J';
public static final int PRIMITIVE_SHORT = 'S';
public static final int PRIMITIVE_BOOLEAN= 'Z';
public static final int PRIMITIVE_FLOAT = 'F';
public static final int PRIMITIVE_LONG = 'J';
public static final int PRIMITIVE_SHORT = 'S';
public static final int PRIMITIVE_BOOLEAN = 'Z';


public abstract String stringify(); public abstract String stringify();
public AnnotationValue(int kind) { public AnnotationValue(int kind) {
valueKind = kind; valueKind = kind;
} }
public static String whatKindIsThis(int kind) { public static String whatKindIsThis(int kind) {
switch (kind) { switch (kind) {
case PRIMITIVE_BYTE: // byte
return "byte";
case PRIMITIVE_CHAR: // char
return "char";
case PRIMITIVE_DOUBLE: // double
return "double";
case PRIMITIVE_FLOAT: // float
return "float";
case PRIMITIVE_INT: // int
return "int";
case PRIMITIVE_LONG: // long
return "long";
case PRIMITIVE_SHORT: // short
return "short";
case PRIMITIVE_BOOLEAN: // boolean
return "boolean";
case 's': // String
return "string";
case 'e': // Enum constant
return "enum";
case 'c': // Class
return "class";
case '@': // Annotation
return "annotation";
case '[': // Array
return "array";
default:
throw new RuntimeException("Dont know what this is : "+kind);
case PRIMITIVE_BYTE: // byte
return "byte";
case PRIMITIVE_CHAR: // char
return "char";
case PRIMITIVE_DOUBLE: // double
return "double";
case PRIMITIVE_FLOAT: // float
return "float";
case PRIMITIVE_INT: // int
return "int";
case PRIMITIVE_LONG: // long
return "long";
case PRIMITIVE_SHORT: // short
return "short";
case PRIMITIVE_BOOLEAN: // boolean
return "boolean";
case 's': // String
return "string";
case 'e': // Enum constant
return "enum";
case 'c': // Class
return "class";
case '@': // Annotation
return "annotation";
case '[': // Array
return "array";
default:
throw new RuntimeException("Dont know what this is : " + kind);
} }
} }
} }

+ 11
- 9
org.aspectj.matcher/src/org/aspectj/weaver/ArrayAnnotationValue.java View File

* Contributors: * Contributors:
* Andy Clement IBM initial implementation * Andy Clement IBM initial implementation
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;


public class ArrayAnnotationValue extends AnnotationValue { public class ArrayAnnotationValue extends AnnotationValue {


private AnnotationValue[] values; private AnnotationValue[] values;
public ArrayAnnotationValue() { public ArrayAnnotationValue() {
super(AnnotationValue.ARRAY); super(AnnotationValue.ARRAY);
} }
public void setValues(AnnotationValue[] values) { public void setValues(AnnotationValue[] values) {
this.values = values; this.values = values;
} }
public ArrayAnnotationValue(AnnotationValue[] values) { public ArrayAnnotationValue(AnnotationValue[] values) {
super(AnnotationValue.ARRAY); super(AnnotationValue.ARRAY);
this.values = values; this.values = values;
} }
public AnnotationValue[] getValues() { public AnnotationValue[] getValues() {
return values; return values;
} }
public String stringify() { public String stringify() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("["); sb.append("[");
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
sb.append(values[i].stringify()); sb.append(values[i].stringify());
if (i+1<values.length) sb.append(",");
if (i + 1 < values.length)
sb.append(",");
} }
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("{"); sb.append("{");
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
sb.append(values[i].toString()); sb.append(values[i].toString());
if ((i+1)<values.length) sb.append(",");
if ((i + 1) < values.length)
sb.append(",");
} }
sb.append("}"); sb.append("}");
return sb.toString(); return sb.toString();

+ 37
- 33
org.aspectj.matcher/src/org/aspectj/weaver/BCException.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/



package org.aspectj.weaver; package org.aspectj.weaver;


import java.io.PrintStream; import java.io.PrintStream;
* Exception to use inside the bcweaver. * Exception to use inside the bcweaver.
*/ */
public class BCException extends RuntimeException { public class BCException extends RuntimeException {
Throwable thrown;
public BCException() {
super();
}

public BCException(String s) {
super(s + "\n" + CompilationAndWeavingContext.getCurrentContext());
}
public BCException(String s, Throwable thrown) {
this(s);
this.thrown = thrown;
}
public void printStackTrace() {
printStackTrace(System.err);
}
public void printStackTrace(PrintStream s) {
printStackTrace(new PrintWriter(s));
}
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
if (null != thrown) {
s.print("Caused by: ");
s.print(thrown.getClass().getName());
String message = thrown.getMessage();
if (null != message) {
s.print(": ");
s.print(message);
}
s.println();
thrown.printStackTrace(s);
}
}
Throwable thrown;

public BCException() {
super();
}

public BCException(String s) {
super(s + "\n" + CompilationAndWeavingContext.getCurrentContext());
}

public BCException(String s, Throwable thrown) {
this(s);
this.thrown = thrown;
}

public void printStackTrace() {
printStackTrace(System.err);
}

public void printStackTrace(PrintStream s) {
printStackTrace(new PrintWriter(s));
}

public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
if (null != thrown) {
s.print("Caused by: ");
s.print(thrown.getClass().getName());
String message = thrown.getMessage();
if (null != message) {
s.print(": ");
s.print(message);
}
s.println();
thrown.printStackTrace(s);
}
}


} }

+ 1
- 1
org.aspectj.matcher/src/org/aspectj/weaver/BindingScope.java View File

* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;


import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.ISourceLocation;
import org.aspectj.weaver.patterns.FormalBinding; import org.aspectj.weaver.patterns.FormalBinding;

+ 5
- 5
org.aspectj.matcher/src/org/aspectj/weaver/ClassAnnotationValue.java View File

* Contributors: * Contributors:
* Andy Clement IBM initial implementation * Andy Clement IBM initial implementation
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;


public class ClassAnnotationValue extends AnnotationValue { public class ClassAnnotationValue extends AnnotationValue {


private String signature; private String signature;
public ClassAnnotationValue(String sig) { public ClassAnnotationValue(String sig) {
super(AnnotationValue.CLASS); super(AnnotationValue.CLASS);
this.signature = sig; this.signature = sig;
} }
public String stringify() { public String stringify() {
return signature; return signature;
}
}
public String toString() { public String toString() {
return signature; return signature;
} }

+ 6
- 8
org.aspectj.matcher/src/org/aspectj/weaver/Constants.java View File

package org.aspectj.weaver; package org.aspectj.weaver;


/** /**
* Some useful weaver constants.
*
* Current uses:
* 1. Holds values that are necessary for working with 1.5 code but
* which don't exist in a 1.4 world.
* Some useful weaver constants.
*
* Current uses: 1. Holds values that are necessary for working with 1.5 code but which don't exist in a 1.4 world.
*/ */
public interface Constants { public interface Constants {


public final static int ACC_BRIDGE = 0x0040;
public final static int ACC_BRIDGE = 0x0040;
public final static int ACC_VARARGS = 0x0080; public final static int ACC_VARARGS = 0x0080;
public final static String RUNTIME_LEVEL_12 = "1.2"; public final static String RUNTIME_LEVEL_12 = "1.2";
public final static String RUNTIME_LEVEL_15 = "1.5"; public final static String RUNTIME_LEVEL_15 = "1.5";
// Default for 1.5.0 // Default for 1.5.0
public final static String RUNTIME_LEVEL_DEFAULT = RUNTIME_LEVEL_15; public final static String RUNTIME_LEVEL_DEFAULT = RUNTIME_LEVEL_15;
} }

+ 12
- 18
org.aspectj.matcher/src/org/aspectj/weaver/CustomMungerFactory.java View File

* This interface is introduced to support tools like PointcutDoctor. * This interface is introduced to support tools like PointcutDoctor.
* </p> * </p>
* <p> * <p>
* A CustomMungerFactory is used to create ShadowMungers and/or
* ConcreteTypeMungers so that an extender can extract extra information during
* the weaving process.
* A CustomMungerFactory is used to create ShadowMungers and/or ConcreteTypeMungers so that an extender can extract extra
* information during the weaving process.
* </p> * </p>
* <p> * <p>
* A CustomMungerFactory is assigned to a weaver through its AjCompiler in
* extenders' code, and gets invoked by the weaver right before the weaving
* starts. The custom shadow/type mungers being created will be added into the
* shadow/type munger list in the weaver and participate the weaving process.
* For example, the match method of each custom shadow munger will be called
* against each shadow.
* A CustomMungerFactory is assigned to a weaver through its AjCompiler in extenders' code, and gets invoked by the weaver right
* before the weaving starts. The custom shadow/type mungers being created will be added into the shadow/type munger list in the
* weaver and participate the weaving process. For example, the match method of each custom shadow munger will be called against
* each shadow.
* </p> * </p>
*
* @author lintonye * @author lintonye
* *
*/ */


/** /**
* @param aspectType * @param aspectType
* @return a Collection&lt;ShadowMunger&gt; of custom shadow mungers for the
* given aspect
* @return a Collection&lt;ShadowMunger&gt; of custom shadow mungers for the given aspect
*/ */
public Collection/* ShadowMunger */createCustomShadowMungers(
ResolvedType aspectType);
public Collection/* ShadowMunger */createCustomShadowMungers(ResolvedType aspectType);


/** /**
* @param aspectType * @param aspectType
* @return a Collection&lt;ConcreteTypeMunger&gt; of custom type mungers for the
* given aspect
* @return a Collection&lt;ConcreteTypeMunger&gt; of custom type mungers for the given aspect
*/ */
public Collection/* ConcreteTypeMunger */createCustomTypeMungers(
ResolvedType aspectType);
public Collection/* ConcreteTypeMunger */createCustomTypeMungers(ResolvedType aspectType);

public Collection/* ShadowMunger */getAllCreatedCustomShadowMungers(); public Collection/* ShadowMunger */getAllCreatedCustomShadowMungers();


public Collection/* ConcreteTypeMunger */getAllCreatedCustomTypeMungers(); public Collection/* ConcreteTypeMunger */getAllCreatedCustomTypeMungers();

+ 213
- 208
org.aspectj.matcher/src/org/aspectj/weaver/Dump.java View File



/** /**
* @author websterm * @author websterm
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*
* To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and Comments
*/ */
public class Dump { public class Dump {




/* Format for unique filename based on date & time */ /* Format for unique filename based on date & time */
private static final String FILENAME_PREFIX = "ajcore"; private static final String FILENAME_PREFIX = "ajcore";
// private static final DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
// private static final DateFormat timeFormat = new SimpleDateFormat("HHmmss.SSS");
// private static final DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
// private static final DateFormat timeFormat = new SimpleDateFormat("HHmmss.SSS");
private static final String FILENAME_SUFFIX = "txt"; private static final String FILENAME_SUFFIX = "txt";
public static final String UNKNOWN_FILENAME = "Unknown"; public static final String UNKNOWN_FILENAME = "Unknown";
public static final String DUMP_EXCLUDED = "Excluded"; public static final String DUMP_EXCLUDED = "Excluded";
public static final String NULL_OR_EMPTY = "Empty"; 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 IMessage.Kind conditionKind = IMessage.ABORT;
private static File directory = new File("."); private static File directory = new File(".");
private String reason; private String reason;
private String fileName; private String fileName;
private PrintStream print; private PrintStream print;
private static String[] savedCommandLine; private static String[] savedCommandLine;
private static List savedFullClasspath; private static List savedFullClasspath;
private static IMessageHolder savedMessageHolder; private static IMessageHolder savedMessageHolder;
private static Map nodes = new WeakHashMap(); private static Map nodes = new WeakHashMap();
private static String lastDumpFileName = UNKNOWN_FILENAME; private static String lastDumpFileName = UNKNOWN_FILENAME;
private static boolean preserveOnNextReset = false; private static boolean preserveOnNextReset = false;
private static Trace trace = TraceFactory.getTraceFactory().getTrace(Dump.class); private static Trace trace = TraceFactory.getTraceFactory().getTrace(Dump.class);
/** /**
* for testing only, so that we can verify dump contents
* after compilation has completely finished
* for testing only, so that we can verify dump contents after compilation has completely finished
*/ */
public static void preserveOnNextReset() { public static void preserveOnNextReset() {
preserveOnNextReset = true;
preserveOnNextReset = true;
} }
public static void reset() { public static void reset() {
if (preserveOnNextReset) { if (preserveOnNextReset) {
preserveOnNextReset = false; preserveOnNextReset = false;
return; return;
}
else {
} else {
nodes.clear(); nodes.clear();
savedMessageHolder = null; savedMessageHolder = null;
} }
} }

/* /*
* Dump methods * Dump methods
*/ */
public static String dump (String reason) {
public static String dump(String reason) {
String fileName = UNKNOWN_FILENAME; String fileName = UNKNOWN_FILENAME;
Dump dump = null; Dump dump = null;
try { try {
dump = new Dump(reason); dump = new Dump(reason);
fileName = dump.getFileName(); fileName = dump.getFileName();
dump.dumpDefault(); dump.dumpDefault();
}
finally {
if (dump != null) dump.close();
} finally {
if (dump != null)
dump.close();
} }
return fileName; return fileName;
} }
public static String dumpWithException (Throwable th) {
return dumpWithException(savedMessageHolder,th);
public static String dumpWithException(Throwable th) {
return dumpWithException(savedMessageHolder, th);
} }
public static String dumpWithException (IMessageHolder messageHolder, Throwable th) {
if (trace.isTraceEnabled()) trace.enter("dumpWithException",null,new Object[] {messageHolder, th});

public static String dumpWithException(IMessageHolder messageHolder, Throwable th) {
if (trace.isTraceEnabled())
trace.enter("dumpWithException", null, new Object[] { messageHolder, th });


String fileName = UNKNOWN_FILENAME; String fileName = UNKNOWN_FILENAME;
Dump dump = null; Dump dump = null;
try { try {
dump = new Dump(th.getClass().getName()); dump = new Dump(th.getClass().getName());
fileName = dump.getFileName(); fileName = dump.getFileName();
dump.dumpException(messageHolder,th);
dump.dumpException(messageHolder, th);
} finally {
if (dump != null)
dump.close();
} }
finally {
if (dump != null) dump.close();
}
if (trace.isTraceEnabled()) trace.exit("dumpWithException",fileName);

if (trace.isTraceEnabled())
trace.exit("dumpWithException", fileName);
return fileName; return fileName;
} }


public static String dumpOnExit () {
public static String dumpOnExit() {
return dumpOnExit(savedMessageHolder, false); return dumpOnExit(savedMessageHolder, false);
} }


public static String dumpOnExit (IMessageHolder messageHolder, boolean reset) {
if (trace.isTraceEnabled()) trace.enter("dumpOnExit",null,messageHolder);
public static String dumpOnExit(IMessageHolder messageHolder, boolean reset) {
if (trace.isTraceEnabled())
trace.enter("dumpOnExit", null, messageHolder);
String fileName = UNKNOWN_FILENAME; String fileName = UNKNOWN_FILENAME;
if (!shouldDumpOnExit(messageHolder)) { if (!shouldDumpOnExit(messageHolder)) {
fileName = DUMP_EXCLUDED; fileName = DUMP_EXCLUDED;
}
else {
} else {
Dump dump = null; Dump dump = null;
try { try {
dump = new Dump(conditionKind.toString()); dump = new Dump(conditionKind.toString());
fileName = dump.getFileName(); fileName = dump.getFileName();
dump.dumpDefault(messageHolder); dump.dumpDefault(messageHolder);
}
finally {
if (dump != null) dump.close();
} finally {
if (dump != null)
dump.close();
} }
} }
if (reset) messageHolder.clearMessages();


if (trace.isTraceEnabled()) trace.exit("dumpOnExit",fileName);
if (reset)
messageHolder.clearMessages();

if (trace.isTraceEnabled())
trace.exit("dumpOnExit", fileName);
return fileName; return fileName;
} }


private static boolean shouldDumpOnExit (IMessageHolder messageHolder) {
if (trace.isTraceEnabled()) trace.enter("shouldDumpOnExit",null,messageHolder);
if (trace.isTraceEnabled()) trace.event("shouldDumpOnExit",null,conditionKind);
boolean result = (messageHolder == null) || messageHolder.hasAnyMessage(conditionKind,true);
if (trace.isTraceEnabled()) trace.exit("shouldDumpOnExit",result);
private static boolean shouldDumpOnExit(IMessageHolder messageHolder) {
if (trace.isTraceEnabled())
trace.enter("shouldDumpOnExit", null, messageHolder);
if (trace.isTraceEnabled())
trace.event("shouldDumpOnExit", null, conditionKind);
boolean result = (messageHolder == null) || messageHolder.hasAnyMessage(conditionKind, true);

if (trace.isTraceEnabled())
trace.exit("shouldDumpOnExit", result);
return result; return result;
} }


/* /*
* Dump configuration * Dump configuration
*/ */
public static void setDumpOnException (boolean b) {
public static void setDumpOnException(boolean b) {
if (b) { if (b) {
exceptionClass = java.lang.Throwable.class; exceptionClass = java.lang.Throwable.class;
}
else {
} else {
exceptionClass = null; exceptionClass = null;
} }
} }
public static boolean setDumpDirectory (String directoryName) {
if (trace.isTraceEnabled()) trace.enter("setDumpDirectory",null,directoryName);

public static boolean setDumpDirectory(String directoryName) {
if (trace.isTraceEnabled())
trace.enter("setDumpDirectory", null, directoryName);
boolean success = false; boolean success = false;


File newDirectory = new File(directoryName); File newDirectory = new File(directoryName);
directory = newDirectory; directory = newDirectory;
success = true; success = true;
} }
if (trace.isTraceEnabled()) trace.exit("setDumpDirectory",success);

if (trace.isTraceEnabled())
trace.exit("setDumpDirectory", success);
return success; return success;
} }
public static boolean getDumpOnException () {
public static boolean getDumpOnException() {
return (exceptionClass != null); return (exceptionClass != null);
} }


public static boolean setDumpOnExit (IMessage.Kind condition) {
if (trace.isTraceEnabled()) trace.event("setDumpOnExit",null,condition);
public static boolean setDumpOnExit(IMessage.Kind condition) {
if (trace.isTraceEnabled())
trace.event("setDumpOnExit", null, condition);


conditionKind = condition; conditionKind = condition;
return true; return true;
} }


public static boolean setDumpOnExit (String condition) {
public static boolean setDumpOnExit(String condition) {
for (Iterator i = IMessage.KINDS.iterator(); i.hasNext();) { for (Iterator i = IMessage.KINDS.iterator(); i.hasNext();) {
IMessage.Kind kind = (IMessage.Kind)i.next();
IMessage.Kind kind = (IMessage.Kind) i.next();
if (kind.toString().equals(condition)) { if (kind.toString().equals(condition)) {
return setDumpOnExit(kind); return setDumpOnExit(kind);
} }
} }
return false; return false;
} }
public static IMessage.Kind getDumpOnExit () {
return conditionKind;
public static IMessage.Kind getDumpOnExit() {
return conditionKind;
} }
public static String getLastDumpFileName () {
public static String getLastDumpFileName() {
return lastDumpFileName; return lastDumpFileName;
} }


/* /*
* Dump registration * Dump registration
*/ */
public static void saveCommandLine (String[] args) {
public static void saveCommandLine(String[] args) {
savedCommandLine = new String[args.length]; savedCommandLine = new String[args.length];
System.arraycopy(args,0,savedCommandLine,0,args.length);
System.arraycopy(args, 0, savedCommandLine, 0, args.length);
} }


public static void saveFullClasspath (List list) {
public static void saveFullClasspath(List list) {
savedFullClasspath = list; savedFullClasspath = list;
} }


public static void saveMessageHolder (IMessageHolder holder) {
public static void saveMessageHolder(IMessageHolder holder) {
savedMessageHolder = holder; savedMessageHolder = holder;
} }


public static void registerNode (Class module, INode newNode) {
if (trace.isTraceEnabled()) trace.enter("registerNode",null,new Object[] { module, newNode} );
public static void registerNode(Class module, INode newNode) {
if (trace.isTraceEnabled())
trace.enter("registerNode", null, new Object[] { module, newNode });


nodes.put(newNode,new WeakReference(newNode));
nodes.put(newNode, new WeakReference(newNode));


if (trace.isTraceEnabled()) trace.exit("registerNode",nodes.size());
if (trace.isTraceEnabled())
trace.exit("registerNode", nodes.size());
} }
/* /*
* Dump methods * Dump methods
*/ */
private Dump (String reason) {
if (trace.isTraceEnabled()) trace.enter("<init>",this,reason);
private Dump(String reason) {
if (trace.isTraceEnabled())
trace.enter("<init>", this, reason);


this.reason = reason; this.reason = reason;
openDump(); openDump();
dumpAspectJProperties(); dumpAspectJProperties();
dumpDumpConfiguration(); dumpDumpConfiguration();
if (trace.isTraceEnabled()) trace.exit("<init>",this);

if (trace.isTraceEnabled())
trace.exit("<init>", this);
} }


public String getFileName() { public String getFileName() {
return fileName; return fileName;
} }
private void dumpDefault () {
private void dumpDefault() {
dumpDefault(savedMessageHolder); dumpDefault(savedMessageHolder);
} }
private void dumpDefault (IMessageHolder holder) {
private void dumpDefault(IMessageHolder holder) {
dumpSytemProperties(); dumpSytemProperties();
dumpCommandLine(); dumpCommandLine();
dumpFullClasspath(); dumpFullClasspath();
dumpCompilerMessages(holder); dumpCompilerMessages(holder);
dumpNodes(); dumpNodes();
} }


*/ */
IVisitor dumpVisitor = new IVisitor() { IVisitor dumpVisitor = new IVisitor() {


public void visitObject (Object obj) {
public void visitObject(Object obj) {
println(formatObj(obj)); println(formatObj(obj));
} }


public void visitList (List list) {
public void visitList(List list) {
println(list); println(list);
} }
}; };
Set keys = nodes.keySet(); Set keys = nodes.keySet();
for (Iterator i = keys.iterator(); i.hasNext();) { for (Iterator i = keys.iterator(); i.hasNext();) {
Object module = i.next(); Object module = i.next();
// INode dumpNode = (INode)nodes.get(module);
INode dumpNode = (INode)module;
// INode dumpNode = (INode)nodes.get(module);
INode dumpNode = (INode) module;
println("---- " + formatObj(dumpNode) + " ----"); println("---- " + formatObj(dumpNode) + " ----");
try { try {
dumpNode.accept(dumpVisitor);
}
catch (Exception ex) {
trace.error(formatObj(dumpNode).toString(),ex);
dumpNode.accept(dumpVisitor);
} catch (Exception ex) {
trace.error(formatObj(dumpNode).toString(), ex);
} }
} }
} }
private void dumpException (IMessageHolder messageHolder, Throwable th) {
private void dumpException(IMessageHolder messageHolder, Throwable th) {
println("---- Exception Information ---"); println("---- Exception Information ---");
println(th); println(th);
dumpDefault(messageHolder); dumpDefault(messageHolder);
} }
private void dumpAspectJProperties () {
private void dumpAspectJProperties() {
println("---- AspectJ Properties ---"); println("---- AspectJ Properties ---");
println("AspectJ Compiler " + Version.text + " built on " + Version.time_text); println("AspectJ Compiler " + Version.text + " built on " + Version.time_text);
} }
private void dumpDumpConfiguration () {
private void dumpDumpConfiguration() {
println("---- Dump Properties ---"); println("---- Dump Properties ---");
println("Dump file: " + fileName); println("Dump file: " + fileName);
println("Dump reason: " + reason); println("Dump reason: " + reason);
println("Dump on exception: " + (exceptionClass != null)); println("Dump on exception: " + (exceptionClass != null));
println("Dump at exit condition: " + conditionKind); println("Dump at exit condition: " + conditionKind);
} }
private void dumpFullClasspath () {
private void dumpFullClasspath() {
println("---- Full Classpath ---"); println("---- Full Classpath ---");
if (savedFullClasspath != null && savedFullClasspath.size() > 0) { if (savedFullClasspath != null && savedFullClasspath.size() > 0) {
for (Iterator iter = savedFullClasspath.iterator(); iter.hasNext(); ) {
String fileName = (String)iter.next();
for (Iterator iter = savedFullClasspath.iterator(); iter.hasNext();) {
String fileName = (String) iter.next();
File file = new File(fileName); File file = new File(fileName);
println(file); println(file);
} }
}
else {
} else {
println(NULL_OR_EMPTY); println(NULL_OR_EMPTY);
} }
} }
private void dumpSytemProperties () {
private void dumpSytemProperties() {
println("---- System Properties ---"); println("---- System Properties ---");
Properties props = System.getProperties(); Properties props = System.getProperties();
println(props); println(props);
} }
private void dumpCommandLine () {
private void dumpCommandLine() {
println("---- Command Line ---"); println("---- Command Line ---");
println(savedCommandLine); println(savedCommandLine);
} }
private void dumpCompilerMessages (IMessageHolder messageHolder) {
private void dumpCompilerMessages(IMessageHolder messageHolder) {
println("---- Compiler Messages ---"); println("---- Compiler Messages ---");
if (messageHolder != null) for (Iterator i = messageHolder.getUnmodifiableListView().iterator(); i.hasNext(); ) {
IMessage message = (IMessage)i.next();
println(message.toString());
}
if (messageHolder != null)
for (Iterator i = messageHolder.getUnmodifiableListView().iterator(); i.hasNext();) {
IMessage message = (IMessage) i.next();
println(message.toString());
}
else { else {
println(NULL_OR_EMPTY); println(NULL_OR_EMPTY);
} }


/* /*
* Dump output * Dump output
*/
private void openDump () {
if (print != null) return;
*/
private void openDump() {
if (print != null)
return;

Date now = new Date(); Date now = new Date();
fileName = FILENAME_PREFIX + "."
+ new SimpleDateFormat("yyyyMMdd").format(now) + "."
+ new SimpleDateFormat("HHmmss.SSS").format(now) + "."
+ FILENAME_SUFFIX;
fileName = FILENAME_PREFIX + "." + new SimpleDateFormat("yyyyMMdd").format(now) + "."
+ new SimpleDateFormat("HHmmss.SSS").format(now) + "." + FILENAME_SUFFIX;
try { try {
File file = new File(directory,fileName);
print = new PrintStream(new FileOutputStream(file),true);
File file = new File(directory, fileName);
print = new PrintStream(new FileOutputStream(file), true);
trace.info("Dumping to " + file.getAbsolutePath()); trace.info("Dumping to " + file.getAbsolutePath());
}
catch (Exception ex) {
} catch (Exception ex) {
print = System.err; print = System.err;
trace.info("Dumping to stderr"); trace.info("Dumping to stderr");
fileName = UNKNOWN_FILENAME; fileName = UNKNOWN_FILENAME;
} }
lastDumpFileName = fileName; lastDumpFileName = fileName;
} }
public void close () {
public void close() {
print.close(); print.close();
} }
private void println (Object obj) {
private void println(Object obj) {
print.println(obj); print.println(obj);
} }
private void println (Object[] array) {
private void println(Object[] array) {
if (array == null) { if (array == null) {
println(NULL_OR_EMPTY); println(NULL_OR_EMPTY);
return; return;
} }
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
print.println(array[i]); print.println(array[i]);
} }
} }
private void println (Properties props) {
private void println(Properties props) {
Iterator iter = props.keySet().iterator(); Iterator iter = props.keySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
String key = (String)iter.next();
String key = (String) iter.next();
String value = props.getProperty(key); String value = props.getProperty(key);
print.println(key + "=" + value); print.println(key + "=" + value);
} }
} }
private void println (Throwable th) {
private void println(Throwable th) {
th.printStackTrace(print); th.printStackTrace(print);
} }
private void println (File file) {
private void println(File file) {
print.print(file.getAbsolutePath()); print.print(file.getAbsolutePath());
if (!file.exists()) { if (!file.exists()) {
println("(missing)");
}
else if (file.isDirectory()) {
println("(missing)");
} else if (file.isDirectory()) {
int count = file.listFiles().length; int count = file.listFiles().length;
println("(" + count + " entries)");
}
else {
println("(" + file.length() + " bytes)");
println("(" + count + " entries)");
} else {
println("(" + file.length() + " bytes)");
} }
} }
private void println (List list) {
if (list == null || list.isEmpty()) println(NULL_OR_EMPTY);
else for (Iterator i = list.iterator(); i.hasNext();) {
Object o = i.next();
if (o instanceof Exception) {
println((Exception)o);
} else {
println(o.toString());
}
}

private void println(List list) {
if (list == null || list.isEmpty())
println(NULL_OR_EMPTY);
else
for (Iterator i = list.iterator(); i.hasNext();) {
Object o = i.next();
if (o instanceof Exception) {
println((Exception) o);
} else {
println(o.toString());
}
}
} }
private static Object formatObj(Object obj) { private static Object formatObj(Object obj) {
/* These classes have a safe implementation of toString() */ /* These classes have a safe implementation of toString() */
if (obj == null
|| obj instanceof String
|| obj instanceof Number
|| obj instanceof Boolean
|| obj instanceof Exception
|| obj instanceof Character
|| obj instanceof Class
|| obj instanceof File
|| obj instanceof StringBuffer
|| obj instanceof URL
) return obj;
else try {
/* Classes can provide an alternative implementation of toString() */
if (obj instanceof Traceable) {
Traceable t = (Traceable)obj;
return t.toTraceString();
if (obj == null || obj instanceof String || obj instanceof Number || obj instanceof Boolean || obj instanceof Exception
|| obj instanceof Character || obj instanceof Class || obj instanceof File || obj instanceof StringBuffer
|| obj instanceof URL)
return obj;
else
try {

/* Classes can provide an alternative implementation of toString() */
if (obj instanceof Traceable) {
Traceable t = (Traceable) obj;
return t.toTraceString();
}

/* Use classname@hashcode */
else
return obj.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(obj));

/* Object.hashCode() can be override and may thow an exception */
} catch (Exception ex) {
return obj.getClass().getName() + "@FFFFFFFF";
} }
/* Use classname@hashcode */
else return obj.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(obj));
/* Object.hashCode() can be override and may thow an exception */
} catch (Exception ex) {
return obj.getClass().getName() + "@FFFFFFFF";
}
} }

static { static {
String exceptionName = System.getProperty("org.aspectj.weaver.Dump.exception","true");
if (!exceptionName.equals("false")) setDumpOnException(true);
String exceptionName = System.getProperty("org.aspectj.weaver.Dump.exception", "true");
if (!exceptionName.equals("false"))
setDumpOnException(true);

String conditionName = System.getProperty(DUMP_CONDITION_PROPERTY); String conditionName = System.getProperty(DUMP_CONDITION_PROPERTY);
if (conditionName != null) setDumpOnExit(conditionName);
if (conditionName != null)
setDumpOnExit(conditionName);

String directoryName = System.getProperty(DUMP_DIRECTORY_PROPERTY); String directoryName = System.getProperty(DUMP_DIRECTORY_PROPERTY);
if (directoryName != null) setDumpDirectory(directoryName);
if (directoryName != null)
setDumpDirectory(directoryName);
} }


public interface INode { public interface INode {
public void accept (IVisitor visior);
public void accept(IVisitor visior);
} }


public interface IVisitor { public interface IVisitor {
public void visitObject (Object s);
public void visitList (List list);

public void visitObject(Object s);

public void visitList(List list);
} }


} }

+ 7
- 7
org.aspectj.matcher/src/org/aspectj/weaver/EnumAnnotationValue.java View File

* Contributors: * Contributors:
* Andy Clement IBM initial implementation * Andy Clement IBM initial implementation
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;


public class EnumAnnotationValue extends AnnotationValue { public class EnumAnnotationValue extends AnnotationValue {


private String type; private String type;
private String value; private String value;
public EnumAnnotationValue(String type,String value) {
public EnumAnnotationValue(String type, String value) {
super(AnnotationValue.ENUM_CONSTANT); super(AnnotationValue.ENUM_CONSTANT);
this.type = type; this.type = type;
this.value = value; this.value = value;
} }
public String getType() { public String getType() {
return type; return type;
} }
public String stringify() { public String stringify() {
return value; return value;
}
}
public String toString() { public String toString() {
return value; return value;
} }

+ 3
- 2
org.aspectj.matcher/src/org/aspectj/weaver/ExposeTypeMunger.java View File

public class ExposeTypeMunger extends PrivilegedAccessMunger { public class ExposeTypeMunger extends PrivilegedAccessMunger {


public ExposeTypeMunger(UnresolvedType typeToExpose) { public ExposeTypeMunger(UnresolvedType typeToExpose) {
super(new ResolvedMemberImpl(Member.STATIC_INITIALIZATION, typeToExpose, 0, ResolvedType.VOID, "<clinit>", UnresolvedType.NONE));
super(new ResolvedMemberImpl(Member.STATIC_INITIALIZATION, typeToExpose, 0, ResolvedType.VOID, "<clinit>",
UnresolvedType.NONE));
} }


public String toString() { public String toString() {
return "ExposeTypeMunger("+getSignature().getDeclaringType().getName()+")";
return "ExposeTypeMunger(" + getSignature().getDeclaringType().getName() + ")";
} }


public String getExposedTypeSignature() { public String getExposedTypeSignature() {

+ 1
- 0
org.aspectj.matcher/src/org/aspectj/weaver/GeneratedReferenceTypeDelegate.java View File

public GeneratedReferenceTypeDelegate(ReferenceType backing) { public GeneratedReferenceTypeDelegate(ReferenceType backing) {
super(backing, false); super(backing, false);
} }

public boolean isAspect() { public boolean isAspect() {
throw new UnsupportedOperationException("Not supported for GeneratedReferenceTypeDelegate"); throw new UnsupportedOperationException("Not supported for GeneratedReferenceTypeDelegate");
} }

+ 13
- 14
org.aspectj.matcher/src/org/aspectj/weaver/IClassFileProvider.java View File



/** /**
* @author colyer * @author colyer
*
* Clients implementing the IClassFileProvider can have a set of class files under
* their control woven by a weaver, by calling the weave(IClassFileProvider source) method.
* The contract is that a call to getRequestor().acceptResult() is providing a result for
* the class file most recently returned from the getClassFileIterator().
*
* Clients implementing the IClassFileProvider can have a set of class files under their control woven by a weaver, by
* calling the weave(IClassFileProvider source) method. The contract is that a call to getRequestor().acceptResult() is
* providing a result for the class file most recently returned from the getClassFileIterator().
*/ */
public interface IClassFileProvider { public interface IClassFileProvider {
/** /**
* Answer an iterator that can be used to iterate over a set of UnwovenClassFiles to
* be woven. During a weave, this method may be called multiple times.
* Answer an iterator that can be used to iterate over a set of UnwovenClassFiles to be woven. During a weave, this method may
* be called multiple times.
*
* @return iterator over UnwovenClassFiles. * @return iterator over UnwovenClassFiles.
*/ */
Iterator getClassFileIterator(); Iterator getClassFileIterator();
/** /**
* The client to which the woven results should be returned. * The client to which the woven results should be returned.
*/ */
IWeaveRequestor getRequestor(); IWeaveRequestor getRequestor();


/**
* @return true if weaver should only do some internal munging as the one needed
* for @AspectJ aspectOf methods creation
*/
boolean isApplyAtAspectJMungersOnly();
/**
* @return true if weaver should only do some internal munging as the one needed for @AspectJ aspectOf methods creation
*/
boolean isApplyAtAspectJMungersOnly();


} }

+ 9
- 10
org.aspectj.matcher/src/org/aspectj/weaver/IClassWeaver.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/



package org.aspectj.weaver; package org.aspectj.weaver;


/** /**
* An IClassWeaver is initialized with a class (a type, really, but let's ignore that for now)
* and a world, and has one method that actually weaves the contents of the world into the class
* implementation.
* An IClassWeaver is initialized with a class (a type, really, but let's ignore that for now) and a world, and has one method that
* actually weaves the contents of the world into the class implementation.
*/ */


public interface IClassWeaver { public interface IClassWeaver {
/** perform the weaving.
*
* @return <code>true</code> if the class is changed by the weaving, <code>false</code> otherwise.
*/
boolean weave();

/**
* perform the weaving.
*
* @return <code>true</code> if the class is changed by the weaving, <code>false</code> otherwise.
*/
boolean weave();
} }

+ 0
- 1
org.aspectj.matcher/src/org/aspectj/weaver/IEclipseSourceContext.java View File

*******************************************************************/ *******************************************************************/
package org.aspectj.weaver; package org.aspectj.weaver;



public interface IEclipseSourceContext extends ISourceContext { public interface IEclipseSourceContext extends ISourceContext {
public void removeUnnecessaryProblems(Member method, int problemLineNumber); public void removeUnnecessaryProblems(Member method, int problemLineNumber);
} }

+ 12
- 13
org.aspectj.matcher/src/org/aspectj/weaver/IHasPosition.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/



package org.aspectj.weaver; package org.aspectj.weaver;


public interface IHasPosition { public interface IHasPosition {
/** /**
* The starting index of this location in the character stream. * The starting index of this location in the character stream.
*/ */
int getStart();
/**
* The ending index of this location in the character stream
*
* This points to the last character in this token.
*
* If a location truly had no contents, then start == end + 1. We don't recommend this.
*/
int getEnd();
//
// String getFileName();
int getStart();
/**
* The ending index of this location in the character stream
*
* This points to the last character in this token.
*
* If a location truly had no contents, then start == end + 1. We don't recommend this.
*/
int getEnd();
//
// String getFileName();


} }

+ 1
- 1
org.aspectj.matcher/src/org/aspectj/weaver/IHasSourceLocation.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/



package org.aspectj.weaver; package org.aspectj.weaver;


import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.ISourceLocation;


public interface IHasSourceLocation extends IHasPosition { public interface IHasSourceLocation extends IHasPosition {
ISourceContext getSourceContext(); ISourceContext getSourceContext();

ISourceLocation getSourceLocation(); ISourceLocation getSourceLocation();
} }

+ 1
- 0
org.aspectj.matcher/src/org/aspectj/weaver/IUnwovenClassFile.java View File



/** /**
* History: 246125 * History: 246125
*
* @author Andy Clement * @author Andy Clement
*/ */
public interface IUnwovenClassFile { public interface IUnwovenClassFile {

+ 0
- 1
org.aspectj.matcher/src/org/aspectj/weaver/IWeaveRequestor.java View File

*******************************************************************************/ *******************************************************************************/
package org.aspectj.weaver; package org.aspectj.weaver;



/** /**
* @author colyer * @author colyer
* *

+ 11
- 14
org.aspectj.matcher/src/org/aspectj/weaver/LintMessage.java View File

import org.aspectj.bridge.Message; import org.aspectj.bridge.Message;


public class LintMessage extends Message { public class LintMessage extends Message {
// private Lint.Kind lintKind; // private Lint.Kind lintKind;
private String lintKind; private String lintKind;
public LintMessage(
String message,
IMessage.Kind messageKind,
ISourceLocation location,
ISourceLocation[] extraLocations,
Lint.Kind lintKind) {
super(message,"",messageKind,location,null,extraLocations);

public LintMessage(String message, IMessage.Kind messageKind, ISourceLocation location, ISourceLocation[] extraLocations,
Lint.Kind lintKind) {
super(message, "", messageKind, location, null, extraLocations);
this.lintKind = lintKind.getName(); this.lintKind = lintKind.getName();
} }
public LintMessage(String message, String extraDetails, org.aspectj.weaver.Lint.Kind kind2, Kind kind, ISourceLocation sourceLocation, Throwable object,
ISourceLocation[] seeAlsoLocations, boolean declared, int id, int sourceStart, int sourceEnd) {
super(message,extraDetails,kind,sourceLocation,object,seeAlsoLocations,declared,id,sourceStart,sourceEnd);

public LintMessage(String message, String extraDetails, org.aspectj.weaver.Lint.Kind kind2, Kind kind,
ISourceLocation sourceLocation, Throwable object, ISourceLocation[] seeAlsoLocations, boolean declared, int id,
int sourceStart, int sourceEnd) {
super(message, extraDetails, kind, sourceLocation, object, seeAlsoLocations, declared, id, sourceStart, sourceEnd);
this.lintKind = kind2.getName(); this.lintKind = kind2.getName();
} }


public String getLintKind() { public String getLintKind() {
return lintKind; return lintKind;
} }
} }

+ 8
- 14
org.aspectj.matcher/src/org/aspectj/weaver/Member.java View File

public static final Member[] NONE = new Member[0]; public static final Member[] NONE = new Member[0];
public static final MemberKind METHOD = new MemberKind("METHOD", 1); public static final MemberKind METHOD = new MemberKind("METHOD", 1);
public static final MemberKind FIELD = new MemberKind("FIELD", 2); public static final MemberKind FIELD = new MemberKind("FIELD", 2);
public static final MemberKind CONSTRUCTOR = new MemberKind("CONSTRUCTOR",
3);
public static final MemberKind STATIC_INITIALIZATION = new MemberKind(
"STATIC_INITIALIZATION", 4);
public static final MemberKind CONSTRUCTOR = new MemberKind("CONSTRUCTOR", 3);
public static final MemberKind STATIC_INITIALIZATION = new MemberKind("STATIC_INITIALIZATION", 4);
public static final MemberKind POINTCUT = new MemberKind("POINTCUT", 5); public static final MemberKind POINTCUT = new MemberKind("POINTCUT", 5);
public static final MemberKind ADVICE = new MemberKind("ADVICE", 6); public static final MemberKind ADVICE = new MemberKind("ADVICE", 6);
public static final MemberKind HANDLER = new MemberKind("HANDLER", 7); public static final MemberKind HANDLER = new MemberKind("HANDLER", 7);
public static final MemberKind MONITORENTER = new MemberKind(
"MONITORENTER", 8);
public static final MemberKind MONITOREXIT = new MemberKind("MONITOREXIT",
9);
public static final MemberKind MONITORENTER = new MemberKind("MONITORENTER", 8);
public static final MemberKind MONITOREXIT = new MemberKind("MONITOREXIT", 9);


public static final AnnotationAJ[][] NO_PARAMETER_ANNOTATIONXS = new AnnotationAJ[][] {}; public static final AnnotationAJ[][] NO_PARAMETER_ANNOTATIONXS = new AnnotationAJ[][] {};
public static final ResolvedType[][] NO_PARAMETER_ANNOTATION_TYPES = new ResolvedType[][] {}; public static final ResolvedType[][] NO_PARAMETER_ANNOTATION_TYPES = new ResolvedType[][] {};
public UnresolvedType[] getParameterTypes(); public UnresolvedType[] getParameterTypes();


/** /**
* Return full signature, including return type, e.g. "()LFastCar;". For a
* signature without the return type, use getParameterSignature() - it is
* important to choose the right one in the face of covariance.
* Return full signature, including return type, e.g. "()LFastCar;". For a signature without the return type, use
* getParameterSignature() - it is important to choose the right one in the face of covariance.
*/ */
public String getSignature(); public String getSignature();


public int getArity(); public int getArity();


/** /**
* Return signature without return type, e.g. "()" for a signature *with*
* the return type, use getSignature() - it is important to choose the right
* one in the face of covariance.
* Return signature without return type, e.g. "()" for a signature *with* the return type, use getSignature() - it is important
* to choose the right one in the face of covariance.
*/ */
public String getParameterSignature(); public String getParameterSignature();



+ 51
- 93
org.aspectj.matcher/src/org/aspectj/weaver/MemberImpl.java View File

private boolean reportedUnresolvableMember = false; private boolean reportedUnresolvableMember = false;


/** /**
* All the signatures that a join point with this member as its signature
* has.
* All the signatures that a join point with this member as its signature has.
*/ */
private JoinPointSignatureIterator joinPointSignatures = null; private JoinPointSignatureIterator joinPointSignatures = null;


public MemberImpl(MemberKind kind, UnresolvedType declaringType,
int modifiers, String name, String signature) {
public MemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers, String name, String signature) {
this.kind = kind; this.kind = kind;
this.declaringType = declaringType; this.declaringType = declaringType;
this.modifiers = modifiers; this.modifiers = modifiers;
} }
} }


public MemberImpl(MemberKind kind, UnresolvedType declaringType,
int modifiers, UnresolvedType returnType, String name,
public MemberImpl(MemberKind kind, UnresolvedType declaringType, int modifiers, UnresolvedType returnType, String name,
UnresolvedType[] parameterTypes) { UnresolvedType[] parameterTypes) {
this.kind = kind; this.kind = kind;
this.declaringType = declaringType; this.declaringType = declaringType;
// ---- utility methods // ---- utility methods


/** /**
* returns an Object[] pair of UnresolvedType, UnresolvedType[] representing
* return type, argument types parsed from the JVM bytecode signature of a
* method. Yes, this should actually return a nice statically-typed pair
* object, but we don't have one of those.
* returns an Object[] pair of UnresolvedType, UnresolvedType[] representing return type, argument types parsed from the JVM
* bytecode signature of a method. Yes, this should actually return a nice statically-typed pair object, but we don't have one
* of those.
* *
* <blockquote> * <blockquote>
* *
* *
* </blockquote> * </blockquote>
* *
* @param signature
* the JVM bytecode method signature string we want to break
* apart
* @return a pair of UnresolvedType, UnresolvedType[] representing the
* return types and parameter types.
* @param signature the JVM bytecode method signature string we want to break apart
* @return a pair of UnresolvedType, UnresolvedType[] representing the return types and parameter types.
*/ */
// OPTIMIZE move static util methods out into a memberutils class // OPTIMIZE move static util methods out into a memberutils class
public static String typesToSignature(UnresolvedType returnType,
UnresolvedType[] paramTypes, boolean useRawTypes) {
public static String typesToSignature(UnresolvedType returnType, UnresolvedType[] paramTypes, boolean useRawTypes) {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
buf.append("("); buf.append("(");
for (int i = 0, len = paramTypes.length; i < len; i++) { for (int i = 0, len = paramTypes.length; i < len; i++) {
} }


/** /**
* Returns "(<signaturesOfParamTypes>,...)" - unlike the other
* typesToSignature that also includes the return type, this one just deals
* with the parameter types.
* Returns "(<signaturesOfParamTypes>,...)" - unlike the other typesToSignature that also includes the return type, this one
* just deals with the parameter types.
*/ */
public static String typesToSignature(UnresolvedType[] paramTypes) { public static String typesToSignature(UnresolvedType[] paramTypes) {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
} }


/** /**
* returns an Object[] pair of UnresolvedType, UnresolvedType[] representing
* return type, argument types parsed from the JVM bytecode signature of a
* method. Yes, this should actually return a nice statically-typed pair
* object, but we don't have one of those.
* returns an Object[] pair of UnresolvedType, UnresolvedType[] representing return type, argument types parsed from the JVM
* bytecode signature of a method. Yes, this should actually return a nice statically-typed pair object, but we don't have one
* of those.
* *
* <blockquote> * <blockquote>
* *
* *
* </blockquote> * </blockquote>
* *
* @param signature
* the JVM bytecode method signature string we want to break
* apart
* @return a pair of UnresolvedType, UnresolvedType[] representing the
* return types and parameter types.
* @param signature the JVM bytecode method signature string we want to break apart
* @return a pair of UnresolvedType, UnresolvedType[] representing the return types and parameter types.
*/ */
private static Object[] signatureToTypes(String sig,
boolean keepParameterizationInfo) {
private static Object[] signatureToTypes(String sig, boolean keepParameterizationInfo) {
boolean hasParameters = sig.charAt(1) != ')'; boolean hasParameters = sig.charAt(1) != ')';
if (hasParameters) { if (hasParameters) {
List l = new ArrayList(); List l = new ArrayList();
c = sig.charAt(++i); c = sig.charAt(++i);
if (c == 'L' || c == 'P') { if (c == 'L' || c == 'P') {
int nextSemicolon = sig.indexOf(';', start); int nextSemicolon = sig.indexOf(';', start);
int firstAngly = (hasAnyAnglies ? sig.indexOf('<', start)
: -1);
if (!hasAnyAnglies || firstAngly == -1
|| firstAngly > nextSemicolon) {
int firstAngly = (hasAnyAnglies ? sig.indexOf('<', start) : -1);
if (!hasAnyAnglies || firstAngly == -1 || firstAngly > nextSemicolon) {
i = nextSemicolon + 1; i = nextSemicolon + 1;
l.add(UnresolvedType.forSignature(sig.substring(start,
i)));
l.add(UnresolvedType.forSignature(sig.substring(start, i)));
} else { } else {
// generics generics generics // generics generics generics
// Have to skip to the *correct* ';' // Have to skip to the *correct* ';'
} }
// posn now points to the correct nextSemicolon :) // posn now points to the correct nextSemicolon :)
i = posn; i = posn;
l.add(UnresolvedType.forSignature(sig.substring(start,
i)));
l.add(UnresolvedType.forSignature(sig.substring(start, i)));
} }
} else if (c == 'T') { // assumed 'reference' to a type } else if (c == 'T') { // assumed 'reference' to a type
// variable, so just "Tname;"
// variable, so just "Tname;"
int nextSemicolon = sig.indexOf(';', start); int nextSemicolon = sig.indexOf(';', start);
String nextbit = sig.substring(start, nextSemicolon); String nextbit = sig.substring(start, nextSemicolon);
l.add(UnresolvedType.forSignature(nextbit)); l.add(UnresolvedType.forSignature(nextbit));
l.add(UnresolvedType.forSignature(sig.substring(start, i))); l.add(UnresolvedType.forSignature(sig.substring(start, i)));
} }
} }
UnresolvedType[] paramTypes = (UnresolvedType[]) l
.toArray(new UnresolvedType[l.size()]);
UnresolvedType returnType = UnresolvedType.forSignature(sig
.substring(i + 1, sig.length()));
UnresolvedType[] paramTypes = (UnresolvedType[]) l.toArray(new UnresolvedType[l.size()]);
UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(i + 1, sig.length()));
return new Object[] { returnType, paramTypes }; return new Object[] { returnType, paramTypes };
} else { } else {
UnresolvedType returnType = UnresolvedType.forSignature(sig
.substring(2));
UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(2));
return new Object[] { returnType, UnresolvedType.NONE }; return new Object[] { returnType, UnresolvedType.NONE };
} }
} }


// ---- factory methods // ---- factory methods
public static MemberImpl field(String declaring, int mods, String name,
String signature) {
return field(declaring, mods, UnresolvedType.forSignature(signature),
name);
public static MemberImpl field(String declaring, int mods, String name, String signature) {
return field(declaring, mods, UnresolvedType.forSignature(signature), name);
} }


// public static Member field(UnresolvedType declaring, int mods, String // public static Member field(UnresolvedType declaring, int mods, String
// OPTIMIZE do we need to call this? unless necessary the signatureToTypes() // OPTIMIZE do we need to call this? unless necessary the signatureToTypes()
// call smacks of laziness on the behalf of the caller // call smacks of laziness on the behalf of the caller
// of this method // of this method
public static MemberImpl method(UnresolvedType declaring, int mods,
String name, String signature) {
public static MemberImpl method(UnresolvedType declaring, int mods, String name, String signature) {
Object[] pair = signatureToTypes(signature, false); Object[] pair = signatureToTypes(signature, false);
return method(declaring, mods, (UnresolvedType) pair[0], name,
(UnresolvedType[]) pair[1]);
return method(declaring, mods, (UnresolvedType) pair[0], name, (UnresolvedType[]) pair[1]);
} }


public static MemberImpl monitorEnter() { public static MemberImpl monitorEnter() {
return new MemberImpl(MONITORENTER, UnresolvedType.OBJECT,
Modifier.STATIC, ResolvedType.VOID, "<lock>",
return new MemberImpl(MONITORENTER, UnresolvedType.OBJECT, Modifier.STATIC, ResolvedType.VOID, "<lock>",
UnresolvedType.ARRAY_WITH_JUST_OBJECT); UnresolvedType.ARRAY_WITH_JUST_OBJECT);
} }


public static MemberImpl monitorExit() { public static MemberImpl monitorExit() {
return new MemberImpl(MONITOREXIT, UnresolvedType.OBJECT,
Modifier.STATIC, ResolvedType.VOID, "<unlock>",
return new MemberImpl(MONITOREXIT, UnresolvedType.OBJECT, Modifier.STATIC, ResolvedType.VOID, "<unlock>",
UnresolvedType.ARRAY_WITH_JUST_OBJECT); UnresolvedType.ARRAY_WITH_JUST_OBJECT);
} }


public static Member pointcut(UnresolvedType declaring, String name,
String signature) {
public static Member pointcut(UnresolvedType declaring, String name, String signature) {
Object[] pair = signatureToTypes(signature, false); Object[] pair = signatureToTypes(signature, false);
return pointcut(declaring, 0, (UnresolvedType) pair[0], name,
(UnresolvedType[]) pair[1]);
return pointcut(declaring, 0, (UnresolvedType) pair[0], name, (UnresolvedType[]) pair[1]);
} }


private static MemberImpl field(String declaring, int mods,
UnresolvedType ty, String name) {
return new MemberImpl(FIELD, UnresolvedType.forName(declaring), mods,
ty, name, UnresolvedType.NONE);
private static MemberImpl field(String declaring, int mods, UnresolvedType ty, String name) {
return new MemberImpl(FIELD, UnresolvedType.forName(declaring), mods, ty, name, UnresolvedType.NONE);
} }


public static MemberImpl method(UnresolvedType declTy, int mods,
UnresolvedType rTy, String name, UnresolvedType[] paramTys) {
public static MemberImpl method(UnresolvedType declTy, int mods, UnresolvedType rTy, String name, UnresolvedType[] paramTys) {
return new MemberImpl( return new MemberImpl(
// ??? this calls <clinit> a method
name.equals("<init>") ? CONSTRUCTOR : METHOD, declTy, mods,
rTy, name, paramTys);
// ??? this calls <clinit> a method
name.equals("<init>") ? CONSTRUCTOR : METHOD, declTy, mods, rTy, name, paramTys);
} }


private static Member pointcut(UnresolvedType declTy, int mods,
UnresolvedType rTy, String name, UnresolvedType[] paramTys) {
private static Member pointcut(UnresolvedType declTy, int mods, UnresolvedType rTy, String name, UnresolvedType[] paramTys) {
return new MemberImpl(POINTCUT, declTy, mods, rTy, name, paramTys); return new MemberImpl(POINTCUT, declTy, mods, rTy, name, paramTys);
} }


public static ResolvedMemberImpl makeExceptionHandlerSignature(
UnresolvedType inType, UnresolvedType catchType) {
return new ResolvedMemberImpl(HANDLER, inType, Modifier.STATIC,
"<catch>", "(" + catchType.getSignature() + ")V");
public static ResolvedMemberImpl makeExceptionHandlerSignature(UnresolvedType inType, UnresolvedType catchType) {
return new ResolvedMemberImpl(HANDLER, inType, Modifier.STATIC, "<catch>", "(" + catchType.getSignature() + ")V");
} }


public boolean equals(Object other) { public boolean equals(Object other) {
if (!(other instanceof Member)) if (!(other instanceof Member))
return false; return false;
Member o = (Member) other; Member o = (Member) other;
return (getKind() == o.getKind() && getName().equals(o.getName())
&& getSignature().equals(o.getSignature()) && getDeclaringType()
return (getKind() == o.getKind() && getName().equals(o.getName()) && getSignature().equals(o.getSignature()) && getDeclaringType()
.equals(o.getDeclaringType())); .equals(o.getDeclaringType()));
} }


/** /**
* Equality is checked based on the underlying signature, so the hash code
* of a member is based on its kind, name, signature, and declaring type.
* The algorithm for this was taken from page 38 of effective java.
* Equality is checked based on the underlying signature, so the hash code of a member is based on its kind, name, signature,
* and declaring type. The algorithm for this was taken from page 38 of effective java.
*/ */
private volatile int hashCode = 0; private volatile int hashCode = 0;


StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
buf.append(returnType.getName()); buf.append(returnType.getName());
buf.append(' '); buf.append(' ');
if (declaringType==null) {
if (declaringType == null) {
buf.append("<NULL>"); buf.append("<NULL>");
} else { } else {
buf.append(declaringType.getName()); buf.append(declaringType.getName());
} }


public AnnotationAJ[] getAnnotations() { public AnnotationAJ[] getAnnotations() {
throw new UnsupportedOperationException(
"You should resolve this member '" + this
+ "' and call getAnnotations() on the result...");
throw new UnsupportedOperationException("You should resolve this member '" + this
+ "' and call getAnnotations() on the result...");
} }


// ---- fields 'n' stuff // ---- fields 'n' stuff
} }


/** /**
* All the signatures that a join point with this member as its signature
* has.
* All the signatures that a join point with this member as its signature has.
*/ */
public Iterator getJoinPointSignatures(World inAWorld) { public Iterator getJoinPointSignatures(World inAWorld) {
if (joinPointSignatures == null) { if (joinPointSignatures == null) {
} }


/** /**
* Raises an [Xlint:cantFindType] message if the declaring type cannot be
* found or an [Xlint:unresolvableMember] message if the type can be found
* (bug 149908)
* Raises an [Xlint:cantFindType] message if the declaring type cannot be found or an [Xlint:unresolvableMember] message if the
* type can be found (bug 149908)
*/ */
private void reportDidntFindMember(World world) { private void reportDidntFindMember(World world) {
if (reportedCantFindDeclaringType || reportedUnresolvableMember) if (reportedCantFindDeclaringType || reportedUnresolvableMember)
return; return;
ResolvedType rType = getDeclaringType().resolve(world); ResolvedType rType = getDeclaringType().resolve(world);
if (rType.isMissing()) { if (rType.isMissing()) {
world.getLint().cantFindType.signal(WeaverMessages.format(
WeaverMessages.CANT_FIND_TYPE, rType.getName()), null);
world.getLint().cantFindType.signal(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE, rType.getName()), null);
reportedCantFindDeclaringType = true; reportedCantFindDeclaringType = true;
} else { } else {
world.getLint().unresolvableMember.signal(getName(), null); world.getLint().unresolvableMember.signal(getName(), null);

+ 29
- 18
org.aspectj.matcher/src/org/aspectj/weaver/MemberKind.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver; package org.aspectj.weaver;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;


import org.aspectj.util.TypeSafeEnum; import org.aspectj.util.TypeSafeEnum;


public class MemberKind extends TypeSafeEnum { public class MemberKind extends TypeSafeEnum {
public MemberKind(String name, int key) { super(name, key); }
public static MemberKind read(DataInputStream s) throws IOException {
int key = s.readByte();
switch(key) {
case 1: return Member.METHOD;
case 2: return Member.FIELD;
case 3: return Member.CONSTRUCTOR;
case 4: return Member.STATIC_INITIALIZATION;
case 5: return Member.POINTCUT;
case 6: return Member.ADVICE;
case 7: return Member.HANDLER;
case 8: return Member.MONITORENTER;
case 9: return Member.MONITOREXIT;
}
throw new BCException("Unexpected memberkind, should be (1-9) but was " + key);
}
public MemberKind(String name, int key) {
super(name, key);
}

public static MemberKind read(DataInputStream s) throws IOException {
int key = s.readByte();
switch (key) {
case 1:
return Member.METHOD;
case 2:
return Member.FIELD;
case 3:
return Member.CONSTRUCTOR;
case 4:
return Member.STATIC_INITIALIZATION;
case 5:
return Member.POINTCUT;
case 6:
return Member.ADVICE;
case 7:
return Member.HANDLER;
case 8:
return Member.MONITORENTER;
case 9:
return Member.MONITOREXIT;
}
throw new BCException("Unexpected memberkind, should be (1-9) but was " + key);
}
} }

+ 82
- 56
org.aspectj.matcher/src/org/aspectj/weaver/MissingResolvedTypeWithKnownSignature.java View File

import org.aspectj.bridge.context.CompilationAndWeavingContext; import org.aspectj.bridge.context.CompilationAndWeavingContext;


/** /**
* When we try to resolve a type in the world that we require to be present,
* and then fail to find it, we return an instance of this class. This class
* defers the production of the "can't find type error" until the first time
* that someone asks a question that can't be answered solely from the signature.
* This enables the weaver to be more tolerant of missing types.
*
* When we try to resolve a type in the world that we require to be present, and then fail to find it, we return an instance of this
* class. This class defers the production of the "can't find type error" until the first time that someone asks a question that
* can't be answered solely from the signature. This enables the weaver to be more tolerant of missing types.
*
*/ */
public class MissingResolvedTypeWithKnownSignature extends ResolvedType { public class MissingResolvedTypeWithKnownSignature extends ResolvedType {


private boolean issuedCantFindTypeError = false; private boolean issuedCantFindTypeError = false;
private boolean issuedJoinPointWarning = false; private boolean issuedJoinPointWarning = false;
private boolean issuedMissingInterfaceWarning = false; private boolean issuedMissingInterfaceWarning = false;
/** /**
* @param signature * @param signature
* @param world * @param world
super(signature, world); super(signature, world);
} }


public boolean isMissing() { return true; }
public boolean isMissing() {
return true;
}

/** /**
* @param signature * @param signature
* @param signatureErasure * @param signatureErasure
* @param world * @param world
*/ */
public MissingResolvedTypeWithKnownSignature(String signature,
String signatureErasure, World world) {
public MissingResolvedTypeWithKnownSignature(String signature, String signatureErasure, World world) {
super(signature, signatureErasure, world); super(signature, signatureErasure, world);
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getDeclaredFields() * @see org.aspectj.weaver.ResolvedType#getDeclaredFields()
*/ */
public ResolvedMember[] getDeclaredFields() { public ResolvedMember[] getDeclaredFields() {
return NO_MEMBERS; return NO_MEMBERS;
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getDeclaredMethods() * @see org.aspectj.weaver.ResolvedType#getDeclaredMethods()
*/ */
public ResolvedMember[] getDeclaredMethods() { public ResolvedMember[] getDeclaredMethods() {
return NO_MEMBERS; return NO_MEMBERS;
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getDeclaredInterfaces() * @see org.aspectj.weaver.ResolvedType#getDeclaredInterfaces()
*/ */
public ResolvedType[] getDeclaredInterfaces() { public ResolvedType[] getDeclaredInterfaces() {
return NO_TYPES; return NO_TYPES;
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getDeclaredPointcuts() * @see org.aspectj.weaver.ResolvedType#getDeclaredPointcuts()
*/ */
public ResolvedMember[] getDeclaredPointcuts() { public ResolvedMember[] getDeclaredPointcuts() {
return NO_MEMBERS; return NO_MEMBERS;
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getSuperclass() * @see org.aspectj.weaver.ResolvedType#getSuperclass()
*/ */
public ResolvedType getSuperclass() { public ResolvedType getSuperclass() {
return ResolvedType.MISSING; return ResolvedType.MISSING;
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getModifiers() * @see org.aspectj.weaver.ResolvedType#getModifiers()
*/ */
public int getModifiers() { public int getModifiers() {
return 0; return 0;
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getSourceContext() * @see org.aspectj.weaver.ResolvedType#getSourceContext()
*/ */
public ISourceContext getSourceContext() { public ISourceContext getSourceContext() {
public int getOffset() { public int getOffset() {
return 0; return 0;
} }
public void tidy() {}

public void tidy() {
}

}; };
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#isAssignableFrom(org.aspectj.weaver.ResolvedType) * @see org.aspectj.weaver.ResolvedType#isAssignableFrom(org.aspectj.weaver.ResolvedType)
*/ */
public boolean isAssignableFrom(ResolvedType other) { public boolean isAssignableFrom(ResolvedType other) {
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_ASSIGNABLE,other.getName());
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_ASSIGNABLE, other.getName());
return false; return false;
} }
public boolean isAssignableFrom(ResolvedType other, boolean allowMissing) { public boolean isAssignableFrom(ResolvedType other, boolean allowMissing) {
if (allowMissing) return false;
else return isAssignableFrom(other);
if (allowMissing)
return false;
else
return isAssignableFrom(other);
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#isCoerceableFrom(org.aspectj.weaver.ResolvedType) * @see org.aspectj.weaver.ResolvedType#isCoerceableFrom(org.aspectj.weaver.ResolvedType)
*/ */
public boolean isCoerceableFrom(ResolvedType other) { public boolean isCoerceableFrom(ResolvedType other) {
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_COERCEABLE,other.getName());
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_COERCEABLE, other.getName());
return false; return false;
} }


/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.AnnotatedElement#hasAnnotation(org.aspectj.weaver.UnresolvedType) * @see org.aspectj.weaver.AnnotatedElement#hasAnnotation(org.aspectj.weaver.UnresolvedType)
*/ */
public boolean hasAnnotation(UnresolvedType ofType) { public boolean hasAnnotation(UnresolvedType ofType) {
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_ANNOTATION); raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_ANNOTATION);
return false; return false;
} }
public List getInterTypeMungers() { public List getInterTypeMungers() {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
public List getInterTypeMungersIncludingSupers() { public List getInterTypeMungersIncludingSupers() {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
public List getInterTypeParentMungers() { public List getInterTypeParentMungers() {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
public List getInterTypeParentMungersIncludingSupers() { public List getInterTypeParentMungersIncludingSupers() {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
protected void collectInterTypeMungers(List collector) { protected void collectInterTypeMungers(List collector) {
return; return;
} }
public void raiseWarningOnJoinPointSignature(String signature) { public void raiseWarningOnJoinPointSignature(String signature) {
if (issuedJoinPointWarning) return;
String message = WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_JOINPOINT,getName(),signature);
if (issuedJoinPointWarning)
return;
String message = WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_JOINPOINT, getName(), signature);
message += "\n" + CompilationAndWeavingContext.getCurrentContext(); message += "\n" + CompilationAndWeavingContext.getCurrentContext();
world.getLint().cantFindTypeAffectingJoinPointMatch.signal(message,null);
// MessageUtil.warn(world.getMessageHandler(),message);
issuedJoinPointWarning = true;
world.getLint().cantFindTypeAffectingJoinPointMatch.signal(message, null);
// MessageUtil.warn(world.getMessageHandler(),message);
issuedJoinPointWarning = true;
} }
public void raiseWarningOnMissingInterfaceWhilstFindingMethods() { public void raiseWarningOnMissingInterfaceWhilstFindingMethods() {
if (issuedMissingInterfaceWarning) return;
String message = WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_INTERFACE_METHODS,getName(),signature);
if (issuedMissingInterfaceWarning)
return;
String message = WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_INTERFACE_METHODS, getName(), signature);
message += "\n" + CompilationAndWeavingContext.getCurrentContext(); message += "\n" + CompilationAndWeavingContext.getCurrentContext();
world.getLint().cantFindTypeAffectingJoinPointMatch.signal(message,null);
//MessageUtil.warn(world.getMessageHandler(),message);
issuedMissingInterfaceWarning = true;
world.getLint().cantFindTypeAffectingJoinPointMatch.signal(message, null);
// MessageUtil.warn(world.getMessageHandler(),message);
issuedMissingInterfaceWarning = true;
} }
private void raiseCantFindType(String key) { private void raiseCantFindType(String key) {
if (issuedCantFindTypeError) return;
String message = WeaverMessages.format(key,getName());
if (issuedCantFindTypeError)
return;
String message = WeaverMessages.format(key, getName());
message += "\n" + CompilationAndWeavingContext.getCurrentContext(); message += "\n" + CompilationAndWeavingContext.getCurrentContext();
world.getLint().cantFindType.signal(message,null);
// MessageUtil.error(world.getMessageHandler(),message);
world.getLint().cantFindType.signal(message, null);
// MessageUtil.error(world.getMessageHandler(),message);
issuedCantFindTypeError = true; issuedCantFindTypeError = true;
} }


private void raiseCantFindType(String key,String insert) {
if (issuedCantFindTypeError) return;
String message = WeaverMessages.format(key,getName(),insert);
private void raiseCantFindType(String key, String insert) {
if (issuedCantFindTypeError)
return;
String message = WeaverMessages.format(key, getName(), insert);
message += "\n" + CompilationAndWeavingContext.getCurrentContext(); message += "\n" + CompilationAndWeavingContext.getCurrentContext();
world.getLint().cantFindType.signal(message,null);
// MessageUtil.error(world.getMessageHandler(),message);
world.getLint().cantFindType.signal(message, null);
// MessageUtil.error(world.getMessageHandler(),message);
issuedCantFindTypeError = true; issuedCantFindTypeError = true;
} }



+ 62
- 58
org.aspectj.matcher/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java View File



public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger { public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger {


private final UnresolvedType interfaceType;
private final Pointcut testPointcut;
private TypePattern lazyTestTypePattern;
public boolean equals(Object other) {
if (other==null || !(other instanceof PerObjectInterfaceTypeMunger)) return false;
PerObjectInterfaceTypeMunger o = (PerObjectInterfaceTypeMunger)other;
return ((testPointcut == null) ? (o.testPointcut == null ) : testPointcut.equals(o.testPointcut))
&& ((lazyTestTypePattern == null) ? (o.lazyTestTypePattern == null ) : lazyTestTypePattern.equals(o.lazyTestTypePattern));
}
private final UnresolvedType interfaceType;
private final Pointcut testPointcut;
private TypePattern lazyTestTypePattern;


private volatile int hashCode = 0;
public int hashCode() {
if (hashCode == 0) {
int result = 17;
result = 37*result + ((testPointcut == null) ? 0 : testPointcut.hashCode());
result = 37*result + ((lazyTestTypePattern == null) ? 0 : lazyTestTypePattern.hashCode());
hashCode = result;
public boolean equals(Object other) {
if (other == null || !(other instanceof PerObjectInterfaceTypeMunger))
return false;
PerObjectInterfaceTypeMunger o = (PerObjectInterfaceTypeMunger) other;
return ((testPointcut == null) ? (o.testPointcut == null) : testPointcut.equals(o.testPointcut))
&& ((lazyTestTypePattern == null) ? (o.lazyTestTypePattern == null) : lazyTestTypePattern
.equals(o.lazyTestTypePattern));
}

private volatile int hashCode = 0;

public int hashCode() {
if (hashCode == 0) {
int result = 17;
result = 37 * result + ((testPointcut == null) ? 0 : testPointcut.hashCode());
result = 37 * result + ((lazyTestTypePattern == null) ? 0 : lazyTestTypePattern.hashCode());
hashCode = result;
}
return hashCode;
}

public PerObjectInterfaceTypeMunger(UnresolvedType aspectType, Pointcut testPointcut) {
super(PerObjectInterface, null);
this.testPointcut = testPointcut;
this.interfaceType = AjcMemberMaker.perObjectInterfaceType(aspectType);
}

private TypePattern getTestTypePattern(ResolvedType aspectType) {
if (lazyTestTypePattern == null) {
final boolean isPerThis;
if (aspectType.getPerClause() instanceof PerFromSuper) {
PerFromSuper ps = (PerFromSuper) aspectType.getPerClause();
isPerThis = ((PerObject) ps.lookupConcretePerClause(aspectType)).isThis();
} else {
isPerThis = ((PerObject) aspectType.getPerClause()).isThis();
}
PerThisOrTargetPointcutVisitor v = new PerThisOrTargetPointcutVisitor(!isPerThis, aspectType);
lazyTestTypePattern = v.getPerTypePointcut(testPointcut);
// reset hashCode so that its recalculated with the new lazyTestTypePattern
hashCode = 0;
} }
return hashCode;
}
public PerObjectInterfaceTypeMunger(UnresolvedType aspectType, Pointcut testPointcut) {
super(PerObjectInterface, null);
this.testPointcut = testPointcut;
this.interfaceType = AjcMemberMaker.perObjectInterfaceType(aspectType);
}
return lazyTestTypePattern;
}


private TypePattern getTestTypePattern(ResolvedType aspectType) {
if (lazyTestTypePattern == null) {
final boolean isPerThis;
if (aspectType.getPerClause() instanceof PerFromSuper) {
PerFromSuper ps = (PerFromSuper) aspectType.getPerClause();
isPerThis = ((PerObject) ps.lookupConcretePerClause(aspectType)).isThis();
} else {
isPerThis = ((PerObject) aspectType.getPerClause()).isThis();
}
PerThisOrTargetPointcutVisitor v = new PerThisOrTargetPointcutVisitor(!isPerThis, aspectType);
lazyTestTypePattern = v.getPerTypePointcut(testPointcut);
// reset hashCode so that its recalculated with the new lazyTestTypePattern
hashCode = 0;
}
return lazyTestTypePattern;
}
public void write(DataOutputStream s) throws IOException {
throw new RuntimeException("shouldn't be serialized");
}


public void write(DataOutputStream s) throws IOException {
throw new RuntimeException("shouldn't be serialized");
}
public UnresolvedType getInterfaceType() {
return interfaceType;
}


public UnresolvedType getInterfaceType() {
return interfaceType;
}
public Pointcut getTestPointcut() {
return testPointcut;
}


public Pointcut getTestPointcut() {
return testPointcut;
}
public boolean matches(ResolvedType matchType, ResolvedType aspectType) {
if (matchType.isInterface())
return false;
return getTestTypePattern(aspectType).matchesStatically(matchType);
}


public boolean matches(ResolvedType matchType, ResolvedType aspectType) {
if (matchType.isInterface()) return false;
return getTestTypePattern(aspectType).matchesStatically(matchType);
}
public boolean isLateMunger() {
return true;
}
public boolean isLateMunger() {
return true;
}
} }

+ 17
- 16
org.aspectj.matcher/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java View File



public PerTypeWithinTargetTypeMunger(UnresolvedType aspectType, PerTypeWithin testPointcut) { public PerTypeWithinTargetTypeMunger(UnresolvedType aspectType, PerTypeWithin testPointcut) {
super(PerTypeWithinInterface, null); super(PerTypeWithinInterface, null);
this.aspectType = aspectType;
this.testPointcut = testPointcut;
this.aspectType = aspectType;
this.testPointcut = testPointcut;
} }


public boolean equals(Object other) { public boolean equals(Object other) {
if (!(other instanceof PerTypeWithinTargetTypeMunger)) return false;
PerTypeWithinTargetTypeMunger o = (PerTypeWithinTargetTypeMunger)other;
return ((o.testPointcut == null) ? (testPointcut == null ) : testPointcut.equals(o.testPointcut))
&& ((o.aspectType == null) ? (aspectType == null ) : aspectType.equals(o.aspectType));
if (!(other instanceof PerTypeWithinTargetTypeMunger))
return false;
PerTypeWithinTargetTypeMunger o = (PerTypeWithinTargetTypeMunger) other;
return ((o.testPointcut == null) ? (testPointcut == null) : testPointcut.equals(o.testPointcut))
&& ((o.aspectType == null) ? (aspectType == null) : aspectType.equals(o.aspectType));
} }


private volatile int hashCode = 0; private volatile int hashCode = 0;

public int hashCode() { public int hashCode() {
if (hashCode == 0) { if (hashCode == 0) {
int result = 17; int result = 17;
result = 37*result + ((testPointcut == null) ? 0 : testPointcut.hashCode());
result = 37*result + ((aspectType == null) ? 0 : aspectType.hashCode());
hashCode = result;
result = 37 * result + ((testPointcut == null) ? 0 : testPointcut.hashCode());
result = 37 * result + ((aspectType == null) ? 0 : aspectType.hashCode());
hashCode = result;
} }
return hashCode;
return hashCode;
} }
public void write(DataOutputStream s) throws IOException { public void write(DataOutputStream s) throws IOException {
throw new RuntimeException("shouldn't be serialized"); throw new RuntimeException("shouldn't be serialized");
} }
public UnresolvedType getAspectType() { public UnresolvedType getAspectType() {
return aspectType; return aspectType;
} }
public Pointcut getTestPointcut() { public Pointcut getTestPointcut() {
return testPointcut; return testPointcut;
} }
// This is a lexical within() so if you say PerTypeWithin(Test) and matchType is an // This is a lexical within() so if you say PerTypeWithin(Test) and matchType is an
// inner type (e.g. Test$NestedType) then it should match successfully // inner type (e.g. Test$NestedType) then it should match successfully
// Does not match if the target is an interface // Does not match if the target is an interface
public boolean matches(ResolvedType matchType, ResolvedType aspectType) { public boolean matches(ResolvedType matchType, ResolvedType aspectType) {
return isWithinType(matchType).alwaysTrue() &&
!matchType.isInterface();
return isWithinType(matchType).alwaysTrue() && !matchType.isInterface();
} }
private FuzzyBoolean isWithinType(ResolvedType type) { private FuzzyBoolean isWithinType(ResolvedType type) {
while (type != null) { while (type != null) {
if (testPointcut.getTypePattern().matchesStatically(type)) { if (testPointcut.getTypePattern().matchesStatically(type)) {

+ 1
- 1
org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java View File

* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;


import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;

+ 1
- 2
org.aspectj.matcher/src/org/aspectj/weaver/Position.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/



package org.aspectj.weaver; package org.aspectj.weaver;


public class Position implements IHasPosition { public class Position implements IHasPosition {
private int start, end; private int start, end;
public Position(int start, int end) { public Position(int start, int end) {
this.start = start; this.start = start;
this.end = end; this.end = end;

+ 28
- 25
org.aspectj.matcher/src/org/aspectj/weaver/PrivilegedAccessMunger.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/



package org.aspectj.weaver; package org.aspectj.weaver;


import java.io.DataOutputStream; import java.io.DataOutputStream;
public PrivilegedAccessMunger(ResolvedMember member) { public PrivilegedAccessMunger(ResolvedMember member) {
super(PrivilegedAccess, member); super(PrivilegedAccess, member);
} }


public void write(DataOutputStream s) throws IOException { public void write(DataOutputStream s) throws IOException {
throw new RuntimeException("shouldn't be serialized"); throw new RuntimeException("shouldn't be serialized");
ResolvedMember ret; ResolvedMember ret;
if (getSignature().getKind() == Member.FIELD) { if (getSignature().getKind() == Member.FIELD) {
ret = AjcMemberMaker.privilegedAccessMethodForFieldGet(aspectType, getSignature()); ret = AjcMemberMaker.privilegedAccessMethodForFieldGet(aspectType, getSignature());
if (ResolvedType.matches(ret, member)) return getSignature();
if (ResolvedType.matches(ret, member))
return getSignature();
ret = AjcMemberMaker.privilegedAccessMethodForFieldSet(aspectType, getSignature()); ret = AjcMemberMaker.privilegedAccessMethodForFieldSet(aspectType, getSignature());
if (ResolvedType.matches(ret, member)) return getSignature();
if (ResolvedType.matches(ret, member))
return getSignature();
} else { } else {
//System.err.println("sig: " + getSignature());
// System.err.println("sig: " + getSignature());
ret = AjcMemberMaker.privilegedAccessMethodForMethod(aspectType, getSignature()); ret = AjcMemberMaker.privilegedAccessMethodForMethod(aspectType, getSignature());
if (ResolvedType.matches(ret, member)) return getSignature();
if (ResolvedType.matches(ret, member))
return getSignature();
} }
return null; return null;
} }


public boolean equals(Object other) {
if (! (other instanceof PrivilegedAccessMunger)) return false;
PrivilegedAccessMunger o = (PrivilegedAccessMunger) other;
return kind.equals(o.kind)
&& ((o.signature == null) ? (signature == null ) : signature.equals(o.signature))
&& ((o.declaredSignature == null) ? (declaredSignature == null ) : declaredSignature.equals(o.declaredSignature))
&& ((o.typeVariableAliases == null) ? (typeVariableAliases == null ) : typeVariableAliases.equals(o.typeVariableAliases));
}
public int hashCode() {
int result = 17;
result = 37*result + kind.hashCode();
result = 37*result + ((signature == null) ? 0 : signature.hashCode());
result = 37*result + ((declaredSignature == null) ? 0 : declaredSignature.hashCode());
result = 37*result + ((typeVariableAliases == null) ? 0 : typeVariableAliases.hashCode());
return result;
}
public boolean existsToSupportShadowMunging() {
public boolean equals(Object other) {
if (!(other instanceof PrivilegedAccessMunger))
return false;
PrivilegedAccessMunger o = (PrivilegedAccessMunger) other;
return kind.equals(o.kind)
&& ((o.signature == null) ? (signature == null) : signature.equals(o.signature))
&& ((o.declaredSignature == null) ? (declaredSignature == null) : declaredSignature.equals(o.declaredSignature))
&& ((o.typeVariableAliases == null) ? (typeVariableAliases == null) : typeVariableAliases
.equals(o.typeVariableAliases));
}

public int hashCode() {
int result = 17;
result = 37 * result + kind.hashCode();
result = 37 * result + ((signature == null) ? 0 : signature.hashCode());
result = 37 * result + ((declaredSignature == null) ? 0 : declaredSignature.hashCode());
result = 37 * result + ((typeVariableAliases == null) ? 0 : typeVariableAliases.hashCode());
return result;
}

public boolean existsToSupportShadowMunging() {
return true; return true;
} }
} }

+ 9
- 7
org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java View File

this.end = end; this.end = end;
this.sourceContext = sourceContext; this.sourceContext = sourceContext;
} }
/** /**
* All overriding methods should call super * All overriding methods should call super
*/ */
if (world.isXmlConfigured() && world.isAspectIncluded(declaringType)) { if (world.isXmlConfigured() && world.isAspectIncluded(declaringType)) {
TypePattern scoped = world.getAspectScope(declaringType); TypePattern scoped = world.getAspectScope(declaringType);
if (scoped != null) { if (scoped != null) {
// Check the 'cached' exclusion map
// Check the 'cached' exclusion map
Set<ResolvedType> excludedTypes = world.getExclusionMap().get(declaringType); Set<ResolvedType> excludedTypes = world.getExclusionMap().get(declaringType);
ResolvedType type = shadow.getEnclosingType().resolve(world); ResolvedType type = shadow.getEnclosingType().resolve(world);
if (excludedTypes!=null && excludedTypes.contains(type)) {
if (excludedTypes != null && excludedTypes.contains(type)) {
return false; return false;
} }
boolean b = scoped.matches(type, TypePattern.STATIC).alwaysTrue(); boolean b = scoped.matches(type, TypePattern.STATIC).alwaysTrue();
if (!b) { if (!b) {
if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) { if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
world.getMessageHandler().handleMessage(MessageUtil.info("Type '"+type.getName()+"' not woven by aspect '"+declaringType.getName()+"' due to scope exclusion in XML definition"));
world.getMessageHandler().handleMessage(
MessageUtil.info("Type '" + type.getName() + "' not woven by aspect '" + declaringType.getName()
+ "' due to scope exclusion in XML definition"));
} }
if (excludedTypes==null) {
if (excludedTypes == null) {
excludedTypes = new HashSet<ResolvedType>(); excludedTypes = new HashSet<ResolvedType>();
excludedTypes.add(type); excludedTypes.add(type);
world.getExclusionMap().put(declaringType,excludedTypes);
world.getExclusionMap().put(declaringType, excludedTypes);
} else { } else {
excludedTypes.add(type); excludedTypes.add(type);
}
}
return false; return false;
} }
} }

+ 191
- 197
org.aspectj.matcher/src/org/aspectj/weaver/SignatureUtils.java View File



public class SignatureUtils { public class SignatureUtils {


public static String getSignatureString(Member m, World world) {
MemberKind kind = m.getKind();
if (kind == Member.METHOD) {
return getMethodSignatureString(m,world);
} else if (kind == Member.CONSTRUCTOR) {
return getConstructorSignatureString(m,world);
} else if (kind == Member.FIELD) {
return getFieldSignatureString(m,world);
} else if (kind == Member.HANDLER) {
return getHandlerSignatureString(m,world);
} else if (kind == Member.STATIC_INITIALIZATION) {
return getStaticInitializationSignatureString(m,world);
} else if (kind == Member.ADVICE) {
return getAdviceSignatureString(m,world);
} else if (kind == Member.MONITORENTER || kind == Member.MONITOREXIT) {
return getMonitorSignatureString(m,world);
} else {
throw new BCException("Do not know the signature string for MemberKind "+kind);
}
}
public static String getSignatureMakerName(Member m) {
MemberKind kind = m.getKind();
if (kind == Member.METHOD) {
return "makeMethodSig";
} else if (kind == Member.CONSTRUCTOR) {
return "makeConstructorSig";
} else if (kind == Member.FIELD) {
return "makeFieldSig";
} else if (kind == Member.HANDLER) {
return "makeCatchClauseSig";
} else if (kind == Member.STATIC_INITIALIZATION) {
return "makeInitializerSig";
} else if (kind == Member.ADVICE) {
return "makeAdviceSig";
} else if (kind == Member.MONITORENTER) {
return "makeLockSig";
} else if (kind == Member.MONITOREXIT) {
return "makeUnlockSig";
} else {
throw new BCException("Do not know the signature maker name for MemberKind "+kind);
}
}
public static String getSignatureString(Member m, World world) {
MemberKind kind = m.getKind();
if (kind == Member.METHOD) {
return getMethodSignatureString(m, world);
} else if (kind == Member.CONSTRUCTOR) {
return getConstructorSignatureString(m, world);
} else if (kind == Member.FIELD) {
return getFieldSignatureString(m, world);
} else if (kind == Member.HANDLER) {
return getHandlerSignatureString(m, world);
} else if (kind == Member.STATIC_INITIALIZATION) {
return getStaticInitializationSignatureString(m, world);
} else if (kind == Member.ADVICE) {
return getAdviceSignatureString(m, world);
} else if (kind == Member.MONITORENTER || kind == Member.MONITOREXIT) {
return getMonitorSignatureString(m, world);
} else {
throw new BCException("Do not know the signature string for MemberKind " + kind);
}
}
public static String getSignatureMakerName(Member m) {
MemberKind kind = m.getKind();
if (kind == Member.METHOD) {
return "makeMethodSig";
} else if (kind == Member.CONSTRUCTOR) {
return "makeConstructorSig";
} else if (kind == Member.FIELD) {
return "makeFieldSig";
} else if (kind == Member.HANDLER) {
return "makeCatchClauseSig";
} else if (kind == Member.STATIC_INITIALIZATION) {
return "makeInitializerSig";
} else if (kind == Member.ADVICE) {
return "makeAdviceSig";
} else if (kind == Member.MONITORENTER) {
return "makeLockSig";
} else if (kind == Member.MONITOREXIT) {
return "makeUnlockSig";
} else {
throw new BCException("Do not know the signature maker name for MemberKind " + kind);
}
}


public static String getSignatureType(Member m) { public static String getSignatureType(Member m) {
MemberKind kind = m.getKind();
if (m.getName().equals("<clinit>") && kind!=Member.STATIC_INITIALIZATION) throw new BCException();
// if (m.getName().equals("<clinit>")) return "org.aspectj.lang.reflect.InitializerSignature";
if (kind == Member.METHOD) {
return "org.aspectj.lang.reflect.MethodSignature";
} else if (kind == Member.CONSTRUCTOR) {
return "org.aspectj.lang.reflect.ConstructorSignature";
} else if (kind == Member.FIELD) {
return "org.aspectj.lang.reflect.FieldSignature";
} else if (kind == Member.HANDLER) {
return "org.aspectj.lang.reflect.CatchClauseSignature";
} else if (kind == Member.STATIC_INITIALIZATION) {
return "org.aspectj.lang.reflect.InitializerSignature";
} else if (kind == Member.ADVICE) {
return "org.aspectj.lang.reflect.AdviceSignature";
} else if (kind == Member.MONITORENTER) {
return "org.aspectj.lang.reflect.LockSignature";
} else if (kind == Member.MONITOREXIT) {
return "org.aspectj.lang.reflect.UnlockSignature";
} else {
throw new BCException("Do not know the signature type for MemberKind "+kind);
}
}

// ---
MemberKind kind = m.getKind();
if (m.getName().equals("<clinit>") && kind != Member.STATIC_INITIALIZATION)
throw new BCException();
// if (m.getName().equals("<clinit>")) return "org.aspectj.lang.reflect.InitializerSignature";

if (kind == Member.METHOD) {
return "org.aspectj.lang.reflect.MethodSignature";
} else if (kind == Member.CONSTRUCTOR) {
return "org.aspectj.lang.reflect.ConstructorSignature";
} else if (kind == Member.FIELD) {
return "org.aspectj.lang.reflect.FieldSignature";
} else if (kind == Member.HANDLER) {
return "org.aspectj.lang.reflect.CatchClauseSignature";
} else if (kind == Member.STATIC_INITIALIZATION) {
return "org.aspectj.lang.reflect.InitializerSignature";
} else if (kind == Member.ADVICE) {
return "org.aspectj.lang.reflect.AdviceSignature";
} else if (kind == Member.MONITORENTER) {
return "org.aspectj.lang.reflect.LockSignature";
} else if (kind == Member.MONITOREXIT) {
return "org.aspectj.lang.reflect.UnlockSignature";
} else {
throw new BCException("Do not know the signature type for MemberKind " + kind);
}
}

// ---


private static String getHandlerSignatureString(Member m, World world) { private static String getHandlerSignatureString(Member m, World world) {
StringBuffer buf = new StringBuffer();
buf.append(makeString(0));
buf.append('-');
//buf.append(getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getParameterTypes()[0]));
buf.append('-');
String pName = "<missing>";
String[] names = m.getParameterNames(world);
if (names != null) pName = names[0];
buf.append(pName);
buf.append('-');
return buf.toString();
StringBuffer buf = new StringBuffer();
buf.append(makeString(0));
buf.append('-');
// buf.append(getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getParameterTypes()[0]));
buf.append('-');
String pName = "<missing>";
String[] names = m.getParameterNames(world);
if (names != null)
pName = names[0];
buf.append(pName);
buf.append('-');
return buf.toString();
} }
private static String getStaticInitializationSignatureString(Member m, World world) { private static String getStaticInitializationSignatureString(Member m, World world) {
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
//buf.append(getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
return buf.toString();
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
// buf.append(getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
return buf.toString();
} }


protected static String getAdviceSignatureString(Member m, World world) { protected static String getAdviceSignatureString(Member m, World world) {
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
buf.append(m.getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getParameterTypes()));
buf.append('-');
buf.append(makeString(m.getParameterNames(world)));
buf.append('-');
buf.append(makeString(m.getExceptions(world)));
buf.append('-');
buf.append(makeString(m.getReturnType()));
buf.append('-');
return buf.toString();
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
buf.append(m.getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getParameterTypes()));
buf.append('-');
buf.append(makeString(m.getParameterNames(world)));
buf.append('-');
buf.append(makeString(m.getExceptions(world)));
buf.append('-');
buf.append(makeString(m.getReturnType()));
buf.append('-');
return buf.toString();
} }



protected static String getMethodSignatureString(Member m, World world) { protected static String getMethodSignatureString(Member m, World world) {
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
buf.append(m.getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getParameterTypes()));
buf.append('-');
buf.append(makeString(m.getParameterNames(world)));
buf.append('-');
buf.append(makeString(m.getExceptions(world)));
buf.append('-');
buf.append(makeString(m.getReturnType()));
buf.append('-');
return buf.toString();
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
buf.append(m.getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getParameterTypes()));
buf.append('-');
buf.append(makeString(m.getParameterNames(world)));
buf.append('-');
buf.append(makeString(m.getExceptions(world)));
buf.append('-');
buf.append(makeString(m.getReturnType()));
buf.append('-');
return buf.toString();
} }
protected static String getMonitorSignatureString(Member m, World world) { protected static String getMonitorSignatureString(Member m, World world) {
StringBuffer buf = new StringBuffer();
buf.append(makeString(Modifier.STATIC)); // modifiers
buf.append('-');
buf.append(m.getName()); // name
buf.append('-');
buf.append(makeString(m.getDeclaringType())); // Declaring Type
buf.append('-');
buf.append(makeString(m.getParameterTypes()[0])); // Parameter Types
buf.append('-');
buf.append(""); // Parameter names
buf.append('-');
return buf.toString();
StringBuffer buf = new StringBuffer();
buf.append(makeString(Modifier.STATIC)); // modifiers
buf.append('-');
buf.append(m.getName()); // name
buf.append('-');
buf.append(makeString(m.getDeclaringType())); // Declaring Type
buf.append('-');
buf.append(makeString(m.getParameterTypes()[0])); // Parameter Types
buf.append('-');
buf.append(""); // Parameter names
buf.append('-');
return buf.toString();
} }


protected static String getConstructorSignatureString(Member m, World world) { protected static String getConstructorSignatureString(Member m, World world) {
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getParameterTypes()));
buf.append('-');
buf.append(makeString(m.getParameterNames(world)));
buf.append('-');
buf.append(makeString(m.getExceptions(world)));
buf.append('-');
return buf.toString();
}

StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getParameterTypes()));
buf.append('-');
buf.append(makeString(m.getParameterNames(world)));
buf.append('-');
buf.append(makeString(m.getExceptions(world)));
buf.append('-');
return buf.toString();
}


protected static String getFieldSignatureString(Member m, World world) { protected static String getFieldSignatureString(Member m, World world) {
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
buf.append(m.getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getReturnType()));
buf.append('-');
return buf.toString();
}
StringBuffer buf = new StringBuffer();
buf.append(makeString(m.getModifiers(world)));
buf.append('-');
buf.append(m.getName());
buf.append('-');
buf.append(makeString(m.getDeclaringType()));
buf.append('-');
buf.append(makeString(m.getReturnType()));
buf.append('-');
return buf.toString();
}


protected static String makeString(int i) { protected static String makeString(int i) {
return Integer.toString(i, 16); return Integer.toString(i, 16);
} }


protected static String makeString(UnresolvedType t) { protected static String makeString(UnresolvedType t) {
// this is the inverse of the odd behavior for Class.forName w/ arrays
if (t.isArray()) {
// this behavior matches the string used by the eclipse compiler for Foo.class literals
return t.getSignature().replace('/', '.');
} else {
return t.getName();
}
}

// this is the inverse of the odd behavior for Class.forName w/ arrays
if (t.isArray()) {
// this behavior matches the string used by the eclipse compiler for Foo.class literals
return t.getSignature().replace('/', '.');
} else {
return t.getName();
}
}


protected static String makeString(UnresolvedType[] types) { protected static String makeString(UnresolvedType[] types) {
if (types == null) return "";
StringBuffer buf = new StringBuffer();
for (int i = 0, len=types.length; i < len; i++) {
buf.append(makeString(types[i]));
buf.append(':');
}
return buf.toString();
}

if (types == null)
return "";
StringBuffer buf = new StringBuffer();
for (int i = 0, len = types.length; i < len; i++) {
buf.append(makeString(types[i]));
buf.append(':');
}
return buf.toString();
}


protected static String makeString(String[] names) { protected static String makeString(String[] names) {
if (names == null) return "";
StringBuffer buf = new StringBuffer();
for (int i = 0, len=names.length; i < len; i++) {
buf.append(names[i]);
buf.append(':');
}
return buf.toString();
}
if (names == null)
return "";
StringBuffer buf = new StringBuffer();
for (int i = 0, len = names.length; i < len; i++) {
buf.append(names[i]);
buf.append(':');
}
return buf.toString();
}


} }

+ 69
- 41
org.aspectj.matcher/src/org/aspectj/weaver/SimpleAnnotationValue.java View File

* Contributors: * Contributors:
* Andy Clement IBM initial implementation * Andy Clement IBM initial implementation
* ******************************************************************/ * ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;


public class SimpleAnnotationValue extends AnnotationValue { public class SimpleAnnotationValue extends AnnotationValue {


} }


public SimpleAnnotationValue(int kind, Object value) { public SimpleAnnotationValue(int kind, Object value) {
super(kind);
super(kind);
switch (kind) { switch (kind) {
case AnnotationValue.PRIMITIVE_BYTE: theByte = ((Byte)value).byteValue(); break;
case AnnotationValue.PRIMITIVE_CHAR: theChar = ((Character)value).charValue(); break;
case AnnotationValue.PRIMITIVE_INT: theInt = ((Integer)value).intValue(); break;
case AnnotationValue.STRING: theString = (String)value; break;
case AnnotationValue.PRIMITIVE_DOUBLE: theDouble = ((Double)value).doubleValue(); break;
case AnnotationValue.PRIMITIVE_FLOAT: theFloat = ((Float)value).floatValue(); break;
case AnnotationValue.PRIMITIVE_LONG: theLong = ((Long)value).longValue(); break;
case AnnotationValue.PRIMITIVE_SHORT: theShort = ((Short)value).shortValue(); break;
case AnnotationValue.PRIMITIVE_BOOLEAN: theBoolean = ((Boolean)value).booleanValue(); break;
default:
throw new BCException("Not implemented for this kind: "+whatKindIsThis(kind));
case AnnotationValue.PRIMITIVE_BYTE:
theByte = ((Byte) value).byteValue();
break;
case AnnotationValue.PRIMITIVE_CHAR:
theChar = ((Character) value).charValue();
break;
case AnnotationValue.PRIMITIVE_INT:
theInt = ((Integer) value).intValue();
break;
case AnnotationValue.STRING:
theString = (String) value;
break;
case AnnotationValue.PRIMITIVE_DOUBLE:
theDouble = ((Double) value).doubleValue();
break;
case AnnotationValue.PRIMITIVE_FLOAT:
theFloat = ((Float) value).floatValue();
break;
case AnnotationValue.PRIMITIVE_LONG:
theLong = ((Long) value).longValue();
break;
case AnnotationValue.PRIMITIVE_SHORT:
theShort = ((Short) value).shortValue();
break;
case AnnotationValue.PRIMITIVE_BOOLEAN:
theBoolean = ((Boolean) value).booleanValue();
break;
default:
throw new BCException("Not implemented for this kind: " + whatKindIsThis(kind));
} }
} }


private byte theByte; private byte theByte;
private char theChar; private char theChar;
private int theInt;
private int theInt;
private String theString; private String theString;
private double theDouble; private double theDouble;
private float theFloat; private float theFloat;
private long theLong; private long theLong;
private short theShort; private short theShort;
private boolean theBoolean; private boolean theBoolean;
public void setValueString(String s) { theString = s; }
public void setValueByte(byte b) { theByte = b; }
public void setValueChar(char c) { theChar = c; }
public void setValueInt(int i) { theInt = i; }

public void setValueString(String s) {
theString = s;
}

public void setValueByte(byte b) {
theByte = b;
}

public void setValueChar(char c) {
theChar = c;
}

public void setValueInt(int i) {
theInt = i;
}


public String stringify() { public String stringify() {
switch (valueKind) { switch (valueKind) {
case 'B': // byte
return Byte.toString(theByte);
case 'C': // char
return new Character(theChar).toString();
case 'D': // double
return Double.toString(theDouble);
case 'F': // float
return Float.toString(theFloat);
case 'I': // int
return Integer.toString(theInt);
case 'J': // long
return Long.toString(theLong);
case 'S': // short
return Short.toString(theShort);
case 'Z': // boolean
return new Boolean(theBoolean).toString();
case 's': // String
return theString;
default: throw new BCException("Do not understand this kind: "+valueKind);
case 'B': // byte
return Byte.toString(theByte);
case 'C': // char
return new Character(theChar).toString();
case 'D': // double
return Double.toString(theDouble);
case 'F': // float
return Float.toString(theFloat);
case 'I': // int
return Integer.toString(theInt);
case 'J': // long
return Long.toString(theLong);
case 'S': // short
return Short.toString(theShort);
case 'Z': // boolean
return new Boolean(theBoolean).toString();
case 's': // String
return theString;
default:
throw new BCException("Do not understand this kind: " + valueKind);
} }
} }
public String toString() { public String toString() {
return stringify(); return stringify();
} }



} }

+ 37
- 39
org.aspectj.matcher/src/org/aspectj/weaver/StaticJoinPointFactory.java View File

* PARC initial implementation * PARC initial implementation
* ******************************************************************/ * ******************************************************************/



package org.aspectj.weaver; package org.aspectj.weaver;



public class StaticJoinPointFactory { public class StaticJoinPointFactory {
// int usedKeys;
//
// List/*String*/ strings = new ArrayList();
// Map/*String,Integer*/ keysForStrings = new HashMap();
//
// public StaticJoinPointFactory() {
// super();
// }
//
// static char[] encoding = new char[] {
// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',//10
// 'a', 'b', 'z', //36
// 'A', 'B', 'Z', //62
// '%', '$', //64
// };
//
// static int TWO_WORDS = 64*64-1;
// static int WORD_MASK = 63;
//
// public void write(String s, StringBuffer result) {
// int i = getIndex(s);
// encode(i, result);
// }
//
// void encode(int i, StringBuffer result) {
// if (i > TWO_WORDS) {
// throw new RuntimeException("unimplemented");
// } else {
// result.append( encoding[(i >> 6) & WORD_MASK] );
// result.append( encoding[i & WORD_MASK] );
// }
// }
//
// public String read(StringReader reader) {
// int i = reader.read();
//
// }
// int usedKeys;
//
// List/*String*/ strings = new ArrayList();
// Map/*String,Integer*/ keysForStrings = new HashMap();
//
// public StaticJoinPointFactory() {
// super();
// }
//
// static char[] encoding = new char[] {
// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',//10
// 'a', 'b', 'z', //36
// 'A', 'B', 'Z', //62
// '%', '$', //64
// };
//
// static int TWO_WORDS = 64*64-1;
// static int WORD_MASK = 63;
//
// public void write(String s, StringBuffer result) {
// int i = getIndex(s);
// encode(i, result);
// }
//
// void encode(int i, StringBuffer result) {
// if (i > TWO_WORDS) {
// throw new RuntimeException("unimplemented");
// } else {
// result.append( encoding[(i >> 6) & WORD_MASK] );
// result.append( encoding[i & WORD_MASK] );
// }
// }
//
// public String read(StringReader reader) {
// int i = reader.read();
//
// }


} }

+ 2
- 4
org.aspectj.matcher/src/org/aspectj/weaver/TypeVariableDeclaringElement.java View File



package org.aspectj.weaver; package org.aspectj.weaver;



/** /**
* Tag interface - methods and types can be declaring elements for
* type variables. See the TypeVariable class which holds onto
* the declaring element
* Tag interface - methods and types can be declaring elements for type variables. See the TypeVariable class which holds onto the
* declaring element
*/ */
public interface TypeVariableDeclaringElement { public interface TypeVariableDeclaringElement {
public TypeVariable getTypeVariableNamed(String name); public TypeVariable getTypeVariableNamed(String name);

+ 2
- 2
org.aspectj.matcher/src/org/aspectj/weaver/TypeVariableReference.java View File



/** /**
* Implemented by Types that represent references to type variables * Implemented by Types that represent references to type variables
*
*
*/ */
public interface TypeVariableReference { public interface TypeVariableReference {


TypeVariable getTypeVariable(); TypeVariable getTypeVariable();
} }

+ 24
- 26
org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java View File

import java.io.IOException; import java.io.IOException;


/** /**
* @author colyer
* Represents a type variable encountered in the Eclipse Source world,
* which when resolved will turn into a TypeVariableReferenceType
* @author colyer Represents a type variable encountered in the Eclipse Source world, which when resolved will turn into a
* TypeVariableReferenceType
*/ */
public class UnresolvedTypeVariableReferenceType extends UnresolvedType implements TypeVariableReference { public class UnresolvedTypeVariableReferenceType extends UnresolvedType implements TypeVariableReference {


private TypeVariable typeVariable; private TypeVariable typeVariable;
// constructor used as place-holder when dealing with circular refs such as Enum // constructor used as place-holder when dealing with circular refs such as Enum
public UnresolvedTypeVariableReferenceType() { public UnresolvedTypeVariableReferenceType() {
super("Ljava/lang/Object;"); super("Ljava/lang/Object;");
} }
public UnresolvedTypeVariableReferenceType(TypeVariable aTypeVariable) { public UnresolvedTypeVariableReferenceType(TypeVariable aTypeVariable) {
super(aTypeVariable.getFirstBound().getSignature()); super(aTypeVariable.getFirstBound().getSignature());
this.typeVariable = aTypeVariable; this.typeVariable = aTypeVariable;
} }
// only used when resolving circular refs... // only used when resolving circular refs...
public void setTypeVariable(TypeVariable aTypeVariable) { public void setTypeVariable(TypeVariable aTypeVariable) {
this.signature = "T" + aTypeVariable.getName() + ";"; //aTypeVariable.getUpperBound().getSignature();
this.signature = "T" + aTypeVariable.getName() + ";"; // aTypeVariable.getUpperBound().getSignature();
this.typeVariable = aTypeVariable; this.typeVariable = aTypeVariable;
this.typeKind=TypeKind.TYPE_VARIABLE;
this.typeKind = TypeKind.TYPE_VARIABLE;
} }
public ResolvedType resolve(World world) { public ResolvedType resolve(World world) {
TypeVariableDeclaringElement typeVariableScope = world.getTypeVariableLookupScope(); TypeVariableDeclaringElement typeVariableScope = world.getTypeVariableLookupScope();
TypeVariable resolvedTypeVariable = null; TypeVariable resolvedTypeVariable = null;
TypeVariableReferenceType tvrt = null;
TypeVariableReferenceType tvrt = null;
if (typeVariableScope == null) { if (typeVariableScope == null) {
// throw new BCException("There is no scope in which to lookup type variables!"); // throw new BCException("There is no scope in which to lookup type variables!");
// FIXME asc correct thing to do is go bang, but to limp along, lets cope with the scope missing // FIXME asc correct thing to do is go bang, but to limp along, lets cope with the scope missing
resolvedTypeVariable = typeVariable.resolve(world); resolvedTypeVariable = typeVariable.resolve(world);
tvrt = new TypeVariableReferenceType(resolvedTypeVariable,world);
tvrt = new TypeVariableReferenceType(resolvedTypeVariable, world);
} else { } else {
boolean foundOK = false;
boolean foundOK = false;
resolvedTypeVariable = typeVariableScope.getTypeVariableNamed(typeVariable.getName()); resolvedTypeVariable = typeVariableScope.getTypeVariableNamed(typeVariable.getName());
// FIXME asc remove this when the shared type var stuff is sorted // FIXME asc remove this when the shared type var stuff is sorted
if (resolvedTypeVariable == null) { if (resolvedTypeVariable == null) {
resolvedTypeVariable = typeVariable.resolve(world); resolvedTypeVariable = typeVariable.resolve(world);
} else { } else {
foundOK = true;
foundOK = true;
} }
tvrt = new TypeVariableReferenceType(resolvedTypeVariable,world);
tvrt = new TypeVariableReferenceType(resolvedTypeVariable, world);
tvrt.fixedUp = foundOK; tvrt.fixedUp = foundOK;
} }
return tvrt; return tvrt;
} }

public boolean isTypeVariableReference() { public boolean isTypeVariableReference() {
return true; return true;
} }
public TypeVariable getTypeVariable() { public TypeVariable getTypeVariable() {
return typeVariable; return typeVariable;
} }


// public String getName() {
// if (typeVariable == null) return "<type variable not set!>";
// return typeVariable.getDisplayName();
// }
// public String getName() {
// if (typeVariable == null) return "<type variable not set!>";
// return typeVariable.getDisplayName();
// }
public String toString() { public String toString() {
if (typeVariable == null) { if (typeVariable == null) {
return "<type variable not set!>"; return "<type variable not set!>";
return "T" + typeVariable.getName() + ";"; return "T" + typeVariable.getName() + ";";
} }
} }
public String toDebugString() { public String toDebugString() {
return typeVariable.getName(); return typeVariable.getName();
} }
public void write(DataOutputStream s) throws IOException { public void write(DataOutputStream s) throws IOException {
super.write(s); super.write(s);
} }
public String getErasureSignature() { public String getErasureSignature() {
return typeVariable.getFirstBound().getSignature(); return typeVariable.getFirstBound().getSignature();
} }
} }

+ 21
- 8
org.aspectj.matcher/src/org/aspectj/weaver/VersionedDataInputStream.java View File

* Andy Clement initial implementation * Andy Clement initial implementation
* ******************************************************************/ * ******************************************************************/


package org.aspectj.weaver;
package org.aspectj.weaver;


import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.InputStream; import java.io.InputStream;
*/ */
public class VersionedDataInputStream extends DataInputStream { public class VersionedDataInputStream extends DataInputStream {
private WeaverVersionInfo version = new WeaverVersionInfo();// assume we are the latest unless something tells us otherwise... private WeaverVersionInfo version = new WeaverVersionInfo();// assume we are the latest unless something tells us otherwise...
public VersionedDataInputStream(InputStream is) { super(is); }
public int getMajorVersion() { return version.getMajorVersion(); }
public int getMinorVersion() { return version.getMinorVersion(); }
public long getBuildstamp() { return version.getBuildstamp(); }
public void setVersion(WeaverVersionInfo version) { this.version = version; }

public VersionedDataInputStream(InputStream is) {
super(is);
}

public int getMajorVersion() {
return version.getMajorVersion();
}

public int getMinorVersion() {
return version.getMinorVersion();
}

public long getBuildstamp() {
return version.getBuildstamp();
}

public void setVersion(WeaverVersionInfo version) {
this.version = version;
}
} }

+ 60
- 62
org.aspectj.matcher/src/org/aspectj/weaver/WeaverMessages.java View File

import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ResourceBundle; import java.util.ResourceBundle;



public class WeaverMessages { public class WeaverMessages {
private static ResourceBundle bundle = ResourceBundle.getBundle("org.aspectj.weaver.weaver-messages"); private static ResourceBundle bundle = ResourceBundle.getBundle("org.aspectj.weaver.weaver-messages");


public static final String ARGS_IN_DECLARE = "argsInDeclare"; public static final String ARGS_IN_DECLARE = "argsInDeclare";
public static final String NO_NEWARRAY_JOINPOINTS_BY_DEFAULT = "noNewArrayJoinpointsByDefault"; public static final String NO_NEWARRAY_JOINPOINTS_BY_DEFAULT = "noNewArrayJoinpointsByDefault";
public static final String UNSUPPORTED_POINTCUT_PRIMITIVE = "unsupportedPointcutPrimitive"; public static final String UNSUPPORTED_POINTCUT_PRIMITIVE = "unsupportedPointcutPrimitive";
public static final String MISSING_TYPE_PREVENTS_MATCH = "missingTypePreventsMatch"; public static final String MISSING_TYPE_PREVENTS_MATCH = "missingTypePreventsMatch";
public static final String DECP_OBJECT = "decpObject"; 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 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 DECP_HIERARCHY_ERROR = "decpHierarchy";
public static final String MULTIPLE_MATCHES_IN_PRECEDENCE = "multipleMatchesInPrecedence"; public static final String MULTIPLE_MATCHES_IN_PRECEDENCE = "multipleMatchesInPrecedence";
public static final String TWO_STARS_IN_PRECEDENCE = "circularityInPrecedenceStar"; public static final String TWO_STARS_IN_PRECEDENCE = "circularityInPrecedenceStar";
public static final String CLASSES_IN_PRECEDENCE = "nonAspectTypesInPrecedence"; public static final String CLASSES_IN_PRECEDENCE = "nonAspectTypesInPrecedence";
public static final String TWO_PATTERN_MATCHES_IN_PRECEDENCE = "circularityInPrecedenceTwo"; public static final String TWO_PATTERN_MATCHES_IN_PRECEDENCE = "circularityInPrecedenceTwo";
public static final String NOT_THROWABLE = "notThrowable"; public static final String NOT_THROWABLE = "notThrowable";
public static final String ITD_CONS_ON_ASPECT = "itdConsOnAspect"; public static final String ITD_CONS_ON_ASPECT = "itdConsOnAspect";
public static final String ITD_RETURN_TYPE_MISMATCH = "returnTypeMismatch"; public static final String ITD_RETURN_TYPE_MISMATCH = "returnTypeMismatch";
public static final String ITD_PARAM_TYPE_MISMATCH = "paramTypeMismatch"; public static final String ITD_PARAM_TYPE_MISMATCH = "paramTypeMismatch";
public static final String ITD_NON_EXPOSED_IMPLEMENTOR = "itdNonExposedImplementor"; public static final String ITD_NON_EXPOSED_IMPLEMENTOR = "itdNonExposedImplementor";
public static final String ITD_ABSTRACT_MUST_BE_PUBLIC_ON_INTERFACE = "itdAbstractMustBePublicOnInterface"; public static final String ITD_ABSTRACT_MUST_BE_PUBLIC_ON_INTERFACE = "itdAbstractMustBePublicOnInterface";
public static final String CANT_OVERRIDE_FINAL_MEMBER = "cantOverrideFinalMember"; public static final String CANT_OVERRIDE_FINAL_MEMBER = "cantOverrideFinalMember";
public static final String NON_VOID_RETURN = "nonVoidReturn"; public static final String NON_VOID_RETURN = "nonVoidReturn";
public static final String INCOMPATIBLE_RETURN_TYPE="incompatibleReturnType";
public static final String INCOMPATIBLE_RETURN_TYPE = "incompatibleReturnType";
public static final String CANT_THROW_CHECKED = "cantThrowChecked"; public static final String CANT_THROW_CHECKED = "cantThrowChecked";
public static final String CIRCULAR_DEPENDENCY = "circularDependency"; public static final String CIRCULAR_DEPENDENCY = "circularDependency";
public static final String MISSING_PER_CLAUSE = "missingPerClause"; public static final String MISSING_PER_CLAUSE = "missingPerClause";
public static final String WRONG_PER_CLAUSE = "wrongPerClause"; public static final String WRONG_PER_CLAUSE = "wrongPerClause";
public static final String ALREADY_WOVEN = "alreadyWoven"; public static final String ALREADY_WOVEN = "alreadyWoven";
public static final String REWEAVABLE_MODE = "reweavableMode"; public static final String REWEAVABLE_MODE = "reweavableMode";
public static final String PROCESSING_REWEAVABLE = "processingReweavable"; public static final String PROCESSING_REWEAVABLE = "processingReweavable";
public static final String MISSING_REWEAVABLE_TYPE = "missingReweavableType"; public static final String MISSING_REWEAVABLE_TYPE = "missingReweavableType";
public static final String VERIFIED_REWEAVABLE_TYPE = "verifiedReweavableType"; public static final String VERIFIED_REWEAVABLE_TYPE = "verifiedReweavableType";
public static final String ASPECT_NEEDED = "aspectNeeded"; public static final String ASPECT_NEEDED = "aspectNeeded";
public static final String REWEAVABLE_ASPECT_NOT_REGISTERED = "reweavableAspectNotRegistered";
public static final String REWEAVABLE_ASPECT_NOT_REGISTERED = "reweavableAspectNotRegistered";


public static final String CANT_FIND_TYPE = "cantFindType";
public static final String CANT_FIND_TYPE = "cantFindType";
public static final String CANT_FIND_CORE_TYPE = "cantFindCoreType"; public static final String CANT_FIND_CORE_TYPE = "cantFindCoreType";
public static final String CANT_FIND_TYPE_WITHINPCD = "cantFindTypeWithinpcd"; public static final String CANT_FIND_TYPE_WITHINPCD = "cantFindTypeWithinpcd";
public static final String CANT_FIND_TYPE_DURING_AROUND_WEAVE = "cftDuringAroundWeave";
public static final String CANT_FIND_TYPE_DURING_AROUND_WEAVE_PREINIT = "cftDuringAroundWeavePreinit";
public static final String CANT_FIND_TYPE_EXCEPTION_TYPE = "cftExceptionType";
public static final String CANT_FIND_TYPE_ARG_TYPE = "cftArgType";
public static final String CANT_FIND_PARENT_TYPE = "cantFindParentType";
public static final String CANT_FIND_PARENT_TYPE_NO_SUB = "cantFindParentTypeNoSub";
public static final String CANT_FIND_TYPE_FIELDS = "cantFindTypeFields";
public static final String CANT_FIND_TYPE_SUPERCLASS = "cantFindTypeSuperclass";
public static final String CANT_FIND_TYPE_INTERFACES = "cantFindTypeInterfaces";
public static final String CANT_FIND_TYPE_METHODS = "cantFindTypeMethods";
public static final String CANT_FIND_TYPE_POINTCUTS = "cantFindTypePointcuts";
public static final String CANT_FIND_TYPE_MODIFIERS = "cantFindTypeModifiers";
public static final String CANT_FIND_TYPE_ANNOTATION = "cantFindTypeAnnotation";
public static final String CANT_FIND_TYPE_ASSIGNABLE = "cantFindTypeAssignable";
public static final String CANT_FIND_TYPE_COERCEABLE = "cantFindTypeCoerceable";
public static final String CANT_FIND_TYPE_JOINPOINT = "cantFindTypeJoinPoint";
public static final String CANT_FIND_TYPE_INTERFACE_METHODS = "cantFindTypeInterfaceMethods";
public static final String CANT_FIND_TYPE_DURING_AROUND_WEAVE = "cftDuringAroundWeave";
public static final String CANT_FIND_TYPE_DURING_AROUND_WEAVE_PREINIT = "cftDuringAroundWeavePreinit";
public static final String CANT_FIND_TYPE_EXCEPTION_TYPE = "cftExceptionType";
public static final String CANT_FIND_TYPE_ARG_TYPE = "cftArgType";
public static final String CANT_FIND_PARENT_TYPE = "cantFindParentType";
public static final String CANT_FIND_PARENT_TYPE_NO_SUB = "cantFindParentTypeNoSub";
public static final String CANT_FIND_TYPE_FIELDS = "cantFindTypeFields";
public static final String CANT_FIND_TYPE_SUPERCLASS = "cantFindTypeSuperclass";
public static final String CANT_FIND_TYPE_INTERFACES = "cantFindTypeInterfaces";
public static final String CANT_FIND_TYPE_METHODS = "cantFindTypeMethods";
public static final String CANT_FIND_TYPE_POINTCUTS = "cantFindTypePointcuts";
public static final String CANT_FIND_TYPE_MODIFIERS = "cantFindTypeModifiers";
public static final String CANT_FIND_TYPE_ANNOTATION = "cantFindTypeAnnotation";
public static final String CANT_FIND_TYPE_ASSIGNABLE = "cantFindTypeAssignable";
public static final String CANT_FIND_TYPE_COERCEABLE = "cantFindTypeCoerceable";
public static final String CANT_FIND_TYPE_JOINPOINT = "cantFindTypeJoinPoint";
public static final String CANT_FIND_TYPE_INTERFACE_METHODS = "cantFindTypeInterfaceMethods";
public static final String DECP_BINARY_LIMITATION = "decpBinaryLimitation"; public static final String DECP_BINARY_LIMITATION = "decpBinaryLimitation";
public static final String OVERWRITE_JSR45 = "overwriteJSR45"; public static final String OVERWRITE_JSR45 = "overwriteJSR45";
public static final String IF_IN_PERCLAUSE = "ifInPerClause"; public static final String IF_IN_PERCLAUSE = "ifInPerClause";
public static final String AROUND_ON_PREINIT = "aroundOnPreInit"; public static final String AROUND_ON_PREINIT = "aroundOnPreInit";
public static final String AROUND_ON_INIT = "aroundOnInit"; public static final String AROUND_ON_INIT = "aroundOnInit";
public static final String AROUND_ON_INTERFACE_STATICINIT = "aroundOnInterfaceStaticInit"; public static final String AROUND_ON_INTERFACE_STATICINIT = "aroundOnInterfaceStaticInit";
public static final String PROBLEM_GENERATING_METHOD = "problemGeneratingMethod"; public static final String PROBLEM_GENERATING_METHOD = "problemGeneratingMethod";
public static final String CLASS_TOO_BIG = "classTooBig"; public static final String CLASS_TOO_BIG = "classTooBig";
public static final String ZIPFILE_ENTRY_MISSING = "zipfileEntryMissing"; public static final String ZIPFILE_ENTRY_MISSING = "zipfileEntryMissing";
public static final String ZIPFILE_ENTRY_INVALID = "zipfileEntryInvalid"; public static final String ZIPFILE_ENTRY_INVALID = "zipfileEntryInvalid";
public static final String DIRECTORY_ENTRY_MISSING = "directoryEntryMissing"; public static final String DIRECTORY_ENTRY_MISSING = "directoryEntryMissing";
public static final String OUTJAR_IN_INPUT_PATH = "outjarInInputPath"; public static final String OUTJAR_IN_INPUT_PATH = "outjarInInputPath";

public static final String XLINT_LOAD_ERROR = "problemLoadingXLint"; public static final String XLINT_LOAD_ERROR = "problemLoadingXLint";
public static final String XLINTDEFAULT_LOAD_ERROR = "unableToLoadXLintDefault"; public static final String XLINTDEFAULT_LOAD_ERROR = "unableToLoadXLintDefault";
public static final String XLINTDEFAULT_LOAD_PROBLEM = "errorLoadingXLintDefault"; public static final String XLINTDEFAULT_LOAD_PROBLEM = "errorLoadingXLintDefault";
public static final String XLINT_KEY_ERROR = "invalidXLintKey"; public static final String XLINT_KEY_ERROR = "invalidXLintKey";
public static final String XLINT_VALUE_ERROR = "invalidXLintMessageKind"; public static final String XLINT_VALUE_ERROR = "invalidXLintMessageKind";
public static final String UNBOUND_FORMAL = "unboundFormalInPC"; public static final String UNBOUND_FORMAL = "unboundFormalInPC";
public static final String AMBIGUOUS_BINDING = "ambiguousBindingInPC"; public static final String AMBIGUOUS_BINDING = "ambiguousBindingInPC";
public static final String AMBIGUOUS_BINDING_IN_OR = "ambiguousBindingInOrPC"; public static final String AMBIGUOUS_BINDING_IN_OR = "ambiguousBindingInOrPC";
public static final String NEGATION_DOESNT_ALLOW_BINDING = "negationDoesntAllowBinding"; public static final String NEGATION_DOESNT_ALLOW_BINDING = "negationDoesntAllowBinding";
// Java5 messages
// Java5 messages
public static final String ITDC_ON_ENUM_NOT_ALLOWED = "itdcOnEnumNotAllowed"; public static final String ITDC_ON_ENUM_NOT_ALLOWED = "itdcOnEnumNotAllowed";
public static final String ITDM_ON_ENUM_NOT_ALLOWED = "itdmOnEnumNotAllowed"; public static final String ITDM_ON_ENUM_NOT_ALLOWED = "itdmOnEnumNotAllowed";
public static final String ITDF_ON_ENUM_NOT_ALLOWED = "itdfOnEnumNotAllowed"; public static final String ITDF_ON_ENUM_NOT_ALLOWED = "itdfOnEnumNotAllowed";
public static final String CANT_DECP_TO_MAKE_ANNOTATION_SUPERTYPE = "cantDecpToMakeAnnotationSupertype"; public static final String CANT_DECP_TO_MAKE_ANNOTATION_SUPERTYPE = "cantDecpToMakeAnnotationSupertype";
public static final String REFERENCE_TO_NON_ANNOTATION_TYPE = "referenceToNonAnnotationType"; public static final String REFERENCE_TO_NON_ANNOTATION_TYPE = "referenceToNonAnnotationType";
public static final String BINDING_NON_RUNTIME_RETENTION_ANNOTATION = "bindingNonRuntimeRetentionAnnotation"; public static final String BINDING_NON_RUNTIME_RETENTION_ANNOTATION = "bindingNonRuntimeRetentionAnnotation";
public static final String INCORRECT_TARGET_FOR_DECLARE_ANNOTATION = "incorrectTargetForDeclareAnnotation"; public static final String INCORRECT_TARGET_FOR_DECLARE_ANNOTATION = "incorrectTargetForDeclareAnnotation";
public static final String NO_MATCH_BECAUSE_SOURCE_RETENTION = "noMatchBecauseSourceRetention"; public static final String NO_MATCH_BECAUSE_SOURCE_RETENTION = "noMatchBecauseSourceRetention";
// Annotation Value messages // Annotation Value messages
public static final String INVALID_ANNOTATION_VALUE = "invalidAnnotationValue"; public static final String INVALID_ANNOTATION_VALUE = "invalidAnnotationValue";
public static final String UNKNOWN_ANNOTATION_VALUE = "unknownAnnotationValue"; public static final String UNKNOWN_ANNOTATION_VALUE = "unknownAnnotationValue";
// < Java5 messages // < Java5 messages
public static final String ATANNOTATION_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atannotationNeedsJava5"; public static final String ATANNOTATION_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atannotationNeedsJava5";
public static final String ATWITHIN_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atwithinNeedsJava5"; public static final String ATWITHIN_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atwithinNeedsJava5";
public static final String DECLARE_ATFIELD_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "declareAtFieldNeedsJava5"; public static final String DECLARE_ATFIELD_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "declareAtFieldNeedsJava5";
public static final String DECLARE_ATCONS_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "declareAtConsNeedsJava5"; public static final String DECLARE_ATCONS_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "declareAtConsNeedsJava5";
public static final String ANNOTATIONS_NEED_JAVA5 = "annotationsRequireJava5"; public static final String ANNOTATIONS_NEED_JAVA5 = "annotationsRequireJava5";
// Generics // Generics
public static final String CANT_DECP_MULTIPLE_PARAMETERIZATIONS="cantDecpMultipleParameterizations";
public static final String HANDLER_PCD_DOESNT_SUPPORT_PARAMETERS="noParameterizedTypePatternInHandler";
public static final String CANT_DECP_MULTIPLE_PARAMETERIZATIONS = "cantDecpMultipleParameterizations";
public static final String HANDLER_PCD_DOESNT_SUPPORT_PARAMETERS = "noParameterizedTypePatternInHandler";
public static final String INCORRECT_NUMBER_OF_TYPE_ARGUMENTS = "incorrectNumberOfTypeArguments"; public static final String INCORRECT_NUMBER_OF_TYPE_ARGUMENTS = "incorrectNumberOfTypeArguments";
public static final String VIOLATES_TYPE_VARIABLE_BOUNDS = "violatesTypeVariableBounds"; public static final String VIOLATES_TYPE_VARIABLE_BOUNDS = "violatesTypeVariableBounds";
public static final String NO_STATIC_INIT_JPS_FOR_PARAMETERIZED_TYPES = "noStaticInitJPsForParameterizedTypes"; public static final String NO_STATIC_INIT_JPS_FOR_PARAMETERIZED_TYPES = "noStaticInitJPsForParameterizedTypes";
public static final String NOT_A_GENERIC_TYPE="notAGenericType";
public static final String WITHIN_PCD_DOESNT_SUPPORT_PARAMETERS="noParameterizedTypePatternInWithin";
public static final String THIS_AND_TARGET_DONT_SUPPORT_PARAMETERS="noParameterizedTypesInThisAndTarget";
public static final String GET_AND_SET_DONT_SUPPORT_DEC_TYPE_PARAMETERS="noParameterizedTypesInGetAndSet";
public static final String NOT_A_GENERIC_TYPE = "notAGenericType";
public static final String WITHIN_PCD_DOESNT_SUPPORT_PARAMETERS = "noParameterizedTypePatternInWithin";
public static final String THIS_AND_TARGET_DONT_SUPPORT_PARAMETERS = "noParameterizedTypesInThisAndTarget";
public static final String GET_AND_SET_DONT_SUPPORT_DEC_TYPE_PARAMETERS = "noParameterizedTypesInGetAndSet";
public static final String NO_INIT_JPS_FOR_PARAMETERIZED_TYPES = "noInitJPsForParameterizedTypes"; public static final String NO_INIT_JPS_FOR_PARAMETERIZED_TYPES = "noInitJPsForParameterizedTypes";
public static final String NO_GENERIC_THROWABLES = "noGenericThrowables"; public static final String NO_GENERIC_THROWABLES = "noGenericThrowables";
public static final String WITHINCODE_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES="noParameterizedDeclaringTypesWithinCode";
public static final String EXECUTION_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES="noParameterizedDeclaringTypesInExecution";
public static final String CALL_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES="noParameterizedDeclaringTypesInCall";
public static final String CANT_REFERENCE_POINTCUT_IN_RAW_TYPE="noRawTypePointcutReferences";
public static final String HAS_MEMBER_NOT_ENABLED="hasMemberNotEnabled";
public static final String WITHINCODE_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES = "noParameterizedDeclaringTypesWithinCode";
public static final String EXECUTION_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES = "noParameterizedDeclaringTypesInExecution";
public static final String CALL_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES = "noParameterizedDeclaringTypesInCall";
public static final String CANT_REFERENCE_POINTCUT_IN_RAW_TYPE = "noRawTypePointcutReferences";
public static final String HAS_MEMBER_NOT_ENABLED = "hasMemberNotEnabled";
// @AspectJ // @AspectJ
public static final String RETURNING_FORMAL_NOT_DECLARED_IN_ADVICE = "returningFormalNotDeclaredInAdvice"; public static final String RETURNING_FORMAL_NOT_DECLARED_IN_ADVICE = "returningFormalNotDeclaredInAdvice";
public static final String THROWN_FORMAL_NOT_DECLARED_IN_ADVICE = "thrownFormalNotDeclaredInAdvice"; public static final String THROWN_FORMAL_NOT_DECLARED_IN_ADVICE = "thrownFormalNotDeclaredInAdvice";
public static String format(String key) { public static String format(String key) {
return bundle.getString(key); return bundle.getString(key);
} }
public static String format(String key, Object insert) { public static String format(String key, Object insert) {
return MessageFormat.format(bundle.getString(key),new Object[] {insert});
return MessageFormat.format(bundle.getString(key), new Object[] { insert });
} }


public static String format(String key, Object insert1, Object insert2) { public static String format(String key, Object insert1, Object insert2) {
return MessageFormat.format(bundle.getString(key),new Object[] {insert1,insert2});
return MessageFormat.format(bundle.getString(key), new Object[] { insert1, insert2 });
} }


public static String format(String key, Object insert1, Object insert2, Object insert3) { public static String format(String key, Object insert1, Object insert2, Object insert3) {
return MessageFormat.format(bundle.getString(key),new Object[] {insert1, insert2, insert3});
return MessageFormat.format(bundle.getString(key), new Object[] { insert1, insert2, insert3 });
} }


public static String format(String key, Object insert1, Object insert2, Object insert3, Object insert4) { public static String format(String key, Object insert1, Object insert2, Object insert3, Object insert4) {
return MessageFormat.format(bundle.getString(key),new Object[] {insert1, insert2, insert3, insert4});
return MessageFormat.format(bundle.getString(key), new Object[] { insert1, insert2, insert3, insert4 });
} }


} }

+ 37
- 36
org.aspectj.matcher/src/org/aspectj/weaver/WildcardedUnresolvedType.java View File

package org.aspectj.weaver; package org.aspectj.weaver;


/** /**
* Represents a wildcarded bound for a generic type, this can be unbounded '?' or bounded via extends '? extends Foo' or
* super '? super Foo'. The signature for a ? is in fact "*" and the erasure signature is the upper bound which defaults
* to java.lang.Object if nothing is specified. On resolution, this becomes a BoundedReferenceType
* Represents a wildcarded bound for a generic type, this can be unbounded '?' or bounded via extends '? extends Foo' or super '?
* super Foo'. The signature for a ? is in fact "*" and the erasure signature is the upper bound which defaults to java.lang.Object
* if nothing is specified. On resolution, this becomes a BoundedReferenceType
* *
* @author Andy Clement * @author Andy Clement
*/ */
public class WildcardedUnresolvedType extends UnresolvedType { public class WildcardedUnresolvedType extends UnresolvedType {


// TODO does not cope with extra bounds '? extends A & B & C'
public static final int UNBOUND = 0;
// TODO does not cope with extra bounds '? extends A & B & C'


public static final int EXTENDS = 1;
public static final int UNBOUND = 0;


public static final int SUPER = 2;
public static final WildcardedUnresolvedType QUESTIONMARK = new WildcardedUnresolvedType("*", UnresolvedType.OBJECT, null);
public static final int EXTENDS = 1;


private int boundKind = UNBOUND; // UNBOUND, EXTENDS, SUPER
public static final int SUPER = 2;


private UnresolvedType lowerBound;
public static final WildcardedUnresolvedType QUESTIONMARK = new WildcardedUnresolvedType("*", UnresolvedType.OBJECT, null);


private UnresolvedType upperBound;
private int boundKind = UNBOUND; // UNBOUND, EXTENDS, SUPER


public WildcardedUnresolvedType(String signature, UnresolvedType upperBound, UnresolvedType lowerBound) {
super(signature, (upperBound == null ? UnresolvedType.OBJECT.signature : upperBound.signatureErasure));
this.typeKind = TypeKind.WILDCARD;
this.upperBound = upperBound;
this.lowerBound = lowerBound;
if (signature.charAt(0) == '-') boundKind = SUPER;
if (signature.charAt(0) == '+') boundKind = EXTENDS;
}
private UnresolvedType lowerBound;


public UnresolvedType getUpperBound() {
return upperBound;
}
private UnresolvedType upperBound;


public UnresolvedType getLowerBound() {
return lowerBound;
}
public WildcardedUnresolvedType(String signature, UnresolvedType upperBound, UnresolvedType lowerBound) {
super(signature, (upperBound == null ? UnresolvedType.OBJECT.signature : upperBound.signatureErasure));
this.typeKind = TypeKind.WILDCARD;
this.upperBound = upperBound;
this.lowerBound = lowerBound;
if (signature.charAt(0) == '-')
boundKind = SUPER;
if (signature.charAt(0) == '+')
boundKind = EXTENDS;
}


public boolean isExtends() {
return boundKind == EXTENDS;
}
public UnresolvedType getUpperBound() {
return upperBound;
}


public boolean isSuper() {
return boundKind == SUPER;
}
public UnresolvedType getLowerBound() {
return lowerBound;
}


public boolean isUnbound() {
return boundKind == UNBOUND;
}
public boolean isExtends() {
return boundKind == EXTENDS;
}


public boolean isSuper() {
return boundKind == SUPER;
}

public boolean isUnbound() {
return boundKind == UNBOUND;
}


} }

+ 2
- 4
org.aspectj.matcher/src/org/aspectj/weaver/World.java View File

protected boolean isExpendable(ResolvedType type) { protected boolean isExpendable(ResolvedType type) {
return (!type.equals(UnresolvedType.OBJECT) && (!type.isExposedToWeaver()) && (!type.isPrimitiveType())); return (!type.equals(UnresolvedType.OBJECT) && (!type.isExposedToWeaver()) && (!type.isPrimitiveType()));
} }


// map from aspect > excluded types // map from aspect > excluded types
// memory issue here? // memory issue here?
private Map<ResolvedType,Set<ResolvedType>> exclusionMap = new HashMap<ResolvedType,Set<ResolvedType>>();
private Map<ResolvedType, Set<ResolvedType>> exclusionMap = new HashMap<ResolvedType, Set<ResolvedType>>();



public Map<ResolvedType,Set<ResolvedType>> getExclusionMap() {
public Map<ResolvedType, Set<ResolvedType>> getExclusionMap() {
return exclusionMap; return exclusionMap;
} }



Loading…
Cancel
Save