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

@@ -102,7 +102,9 @@ public abstract class AbstractReferenceTypeDelegate implements ReferenceTypeDele
List typeParameters = new ArrayList();
ResolvedType outerClassType = getOuterClass();
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;
ReferenceTypeDelegate outerDelegate = outer.getDelegate();

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

@@ -10,7 +10,6 @@
* PARC initial implementation
* ******************************************************************/


package org.aspectj.weaver;

import java.io.IOException;
@@ -27,74 +26,95 @@ public class AdviceKind extends TypeSafeEnum {
private int precedence;
private boolean isAfter;
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() {
return this.isAfter;
}
public boolean isCflow() {
return this.isCflow;
}
@@ -104,12 +124,10 @@ public class AdviceKind extends TypeSafeEnum {
}

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() {
return this == PerThisEntry || this == PerTargetEntry;
}

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

@@ -27,14 +27,12 @@ import org.aspectj.weaver.patterns.PerClause;
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>
* 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 Jim Hugunin
@@ -137,14 +135,11 @@ public abstract class AjAttribute {
// ----

/**
* 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 final String AttributeName = "org.aspectj.weaver.AjSynthetic";
@@ -478,9 +473,8 @@ public abstract class AjAttribute {
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,
ISourceContext sourceContext) {

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

@@ -91,8 +91,8 @@ public interface AnnotationAJ {
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
* @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

@@ -9,25 +9,25 @@
* Contributors:
* Andy Clement IBM initial implementation
* ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;

public class AnnotationAnnotationValue extends AnnotationValue {

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

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

@@ -9,37 +9,37 @@
* Contributors:
* Andy Clement IBM initial implementation
* ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;

public class AnnotationNameValuePair {
private String name;
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();
sb.append(name+"="+val.toString());
sb.append(name + "=" + val.toString());
return sb.toString();
}

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

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

@@ -39,8 +39,7 @@ public class AnnotationOnTypeMunger extends ResolvedTypeMunger {
return false;
AnnotationOnTypeMunger o = (AnnotationOnTypeMunger) other;
// 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;

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

@@ -23,21 +23,29 @@ public class AnnotationTargetKind extends TypeSafeEnum {
public AnnotationTargetKind(String name, int 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 CONSTRUCTOR = new AnnotationTargetKind("CONSTRUCTOR", 2);

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

@@ -9,11 +9,10 @@
* Contributors:
* Andy Clement IBM initial implementation
* ******************************************************************/
package org.aspectj.weaver;

package org.aspectj.weaver;

public abstract class AnnotationValue {
protected int valueKind;

public static final int STRING = 's';
@@ -21,52 +20,52 @@ public abstract class AnnotationValue {
public static final int CLASS = 'c';
public static final int ANNOTATION = '@';
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_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 AnnotationValue(int kind) {
valueKind = kind;
}
public static String whatKindIsThis(int 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

@@ -9,46 +9,48 @@
* Contributors:
* Andy Clement IBM initial implementation
* ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;

public class ArrayAnnotationValue extends AnnotationValue {

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

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

@@ -10,7 +10,6 @@
* PARC initial implementation
* ******************************************************************/


package org.aspectj.weaver;

import java.io.PrintStream;
@@ -22,37 +21,42 @@ import org.aspectj.bridge.context.CompilationAndWeavingContext;
* Exception to use inside the bcweaver.
*/
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

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

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

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

@@ -9,21 +9,21 @@
* Contributors:
* Andy Clement IBM initial implementation
* ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;

public class ClassAnnotationValue extends AnnotationValue {

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

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

@@ -11,20 +11,18 @@
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 final static int ACC_BRIDGE = 0x0040;
public final static int ACC_BRIDGE = 0x0040;
public final static int ACC_VARARGS = 0x0080;
public final static String RUNTIME_LEVEL_12 = "1.2";
public final static String RUNTIME_LEVEL_15 = "1.5";
// Default for 1.5.0
public final static String RUNTIME_LEVEL_DEFAULT = RUNTIME_LEVEL_15;
}

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

@@ -19,18 +19,16 @@ import java.util.Collection;
* This interface is introduced to support tools like PointcutDoctor.
* </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>
* 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>
*
* @author lintonye
*
*/
@@ -38,20 +36,16 @@ public interface CustomMungerFactory {

/**
* @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
* @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/* ConcreteTypeMunger */getAllCreatedCustomTypeMungers();

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

@@ -34,9 +34,8 @@ import org.aspectj.weaver.tools.Traceable;

/**
* @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 {

@@ -45,14 +44,14 @@ public class Dump {

/* Format for unique filename based on date & time */
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";
public static final String UNKNOWN_FILENAME = "Unknown";
public static final String DUMP_EXCLUDED = "Excluded";
public static final String NULL_OR_EMPTY = "Empty";
private static Class exceptionClass;
private static IMessage.Kind conditionKind = IMessage.ABORT;
private static File directory = new File(".");
@@ -60,129 +59,133 @@ public class Dump {
private String reason;
private String fileName;
private PrintStream print;
private static String[] savedCommandLine;
private static List savedFullClasspath;
private static IMessageHolder savedMessageHolder;
private static Map nodes = new WeakHashMap();
private static String lastDumpFileName = UNKNOWN_FILENAME;
private static boolean preserveOnNextReset = false;
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() {
preserveOnNextReset = true;
preserveOnNextReset = true;
}
public static void reset() {
if (preserveOnNextReset) {
preserveOnNextReset = false;
return;
}
else {
} else {
nodes.clear();
savedMessageHolder = null;
}
}

/*
* Dump methods
*/
public static String dump (String reason) {
public static String dump(String reason) {
String fileName = UNKNOWN_FILENAME;
Dump dump = null;
try {
dump = new Dump(reason);
fileName = dump.getFileName();
dump.dumpDefault();
}
finally {
if (dump != null) dump.close();
} finally {
if (dump != null)
dump.close();
}
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;
Dump dump = null;
try {
dump = new Dump(th.getClass().getName());
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;
}

public static String dumpOnExit () {
public static String dumpOnExit() {
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;
if (!shouldDumpOnExit(messageHolder)) {
fileName = DUMP_EXCLUDED;
}
else {
} else {
Dump dump = null;
try {
dump = new Dump(conditionKind.toString());
fileName = dump.getFileName();
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;
}

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;
}

/*
* Dump configuration
*/
public static void setDumpOnException (boolean b) {
public static void setDumpOnException(boolean b) {
if (b) {
exceptionClass = java.lang.Throwable.class;
}
else {
} else {
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;

File newDirectory = new File(directoryName);
@@ -190,94 +193,100 @@ public class Dump {
directory = newDirectory;
success = true;
}
if (trace.isTraceEnabled()) trace.exit("setDumpDirectory",success);

if (trace.isTraceEnabled())
trace.exit("setDumpDirectory", success);
return success;
}
public static boolean getDumpOnException () {
public static boolean getDumpOnException() {
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;
return true;
}

public static boolean setDumpOnExit (String condition) {
public static boolean setDumpOnExit(String condition) {
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)) {
return setDumpOnExit(kind);
}
}
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;
}

/*
* Dump registration
*/
public static void saveCommandLine (String[] args) {
public static void saveCommandLine(String[] args) {
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;
}

public static void saveMessageHolder (IMessageHolder holder) {
public static void saveMessageHolder(IMessageHolder 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
*/
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;
openDump();
dumpAspectJProperties();
dumpDumpConfiguration();
if (trace.isTraceEnabled()) trace.exit("<init>",this);

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

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

@@ -288,79 +297,78 @@ public class Dump {
*/
IVisitor dumpVisitor = new IVisitor() {

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

public void visitList (List list) {
public void visitList(List list) {
println(list);
}
};
Set keys = nodes.keySet();
for (Iterator i = keys.iterator(); i.hasNext();) {
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) + " ----");
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(th);
dumpDefault(messageHolder);
}
private void dumpAspectJProperties () {
private void dumpAspectJProperties() {
println("---- AspectJ Properties ---");
println("AspectJ Compiler " + Version.text + " built on " + Version.time_text);
}
private void dumpDumpConfiguration () {
private void dumpDumpConfiguration() {
println("---- Dump Properties ---");
println("Dump file: " + fileName);
println("Dump reason: " + reason);
println("Dump on exception: " + (exceptionClass != null));
println("Dump at exit condition: " + conditionKind);
}
private void dumpFullClasspath () {
private void dumpFullClasspath() {
println("---- Full Classpath ---");
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);
println(file);
}
}
else {
} else {
println(NULL_OR_EMPTY);
}
}
private void dumpSytemProperties () {
private void dumpSytemProperties() {
println("---- System Properties ---");
Properties props = System.getProperties();
println(props);
}
private void dumpCommandLine () {
private void dumpCommandLine() {
println("---- Command Line ---");
println(savedCommandLine);
}
private void dumpCompilerMessages (IMessageHolder messageHolder) {
private void dumpCompilerMessages(IMessageHolder messageHolder) {
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 {
println(NULL_OR_EMPTY);
}
@@ -368,139 +376,136 @@ public class Dump {

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

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 {
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());
}
catch (Exception ex) {
} catch (Exception ex) {
print = System.err;
trace.info("Dumping to stderr");
fileName = UNKNOWN_FILENAME;
}
lastDumpFileName = fileName;
}
public void close () {
public void close() {
print.close();
}
private void println (Object obj) {
private void println(Object obj) {
print.println(obj);
}
private void println (Object[] array) {
private void println(Object[] array) {
if (array == null) {
println(NULL_OR_EMPTY);
return;
}
for (int i = 0; i < array.length; i++) {
print.println(array[i]);
}
}
private void println (Properties props) {
private void println(Properties props) {
Iterator iter = props.keySet().iterator();
while (iter.hasNext()) {
String key = (String)iter.next();
String key = (String) iter.next();
String value = props.getProperty(key);
print.println(key + "=" + value);
}
}
private void println (Throwable th) {
private void println(Throwable th) {
th.printStackTrace(print);
}
private void println (File file) {
private void println(File file) {
print.print(file.getAbsolutePath());
if (!file.exists()) {
println("(missing)");
}
else if (file.isDirectory()) {
println("(missing)");
} else if (file.isDirectory()) {
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) {
/* 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 {
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);
if (conditionName != null) setDumpOnExit(conditionName);
if (conditionName != null)
setDumpOnExit(conditionName);

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

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

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

@@ -9,27 +9,27 @@
* Contributors:
* Andy Clement IBM initial implementation
* ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;

public class EnumAnnotationValue extends AnnotationValue {

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

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

@@ -17,11 +17,12 @@ package org.aspectj.weaver;
public class ExposeTypeMunger extends PrivilegedAccessMunger {

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() {
return "ExposeTypeMunger("+getSignature().getDeclaringType().getName()+")";
return "ExposeTypeMunger(" + getSignature().getDeclaringType().getName() + ")";
}

public String getExposedTypeSignature() {

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

@@ -26,6 +26,7 @@ public class GeneratedReferenceTypeDelegate extends AbstractReferenceTypeDelegat
public GeneratedReferenceTypeDelegate(ReferenceType backing) {
super(backing, false);
}

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

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

@@ -14,30 +14,29 @@ import java.util.Iterator;

/**
* @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 {
/**
* 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.
*/
Iterator getClassFileIterator();
/**
* The client to which the woven results should be returned.
*/
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

@@ -10,20 +10,19 @@
* PARC initial implementation
* ******************************************************************/


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 {
/** 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

@@ -10,7 +10,6 @@
*******************************************************************/
package org.aspectj.weaver;


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

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

@@ -10,24 +10,23 @@
* PARC initial implementation
* ******************************************************************/


package org.aspectj.weaver;

public interface IHasPosition {
/**
* 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

@@ -10,12 +10,12 @@
* PARC initial implementation
* ******************************************************************/


package org.aspectj.weaver;

import org.aspectj.bridge.ISourceLocation;

public interface IHasSourceLocation extends IHasPosition {
ISourceContext getSourceContext();

ISourceLocation getSourceLocation();
}

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

@@ -11,6 +11,7 @@ package org.aspectj.weaver;

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

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

@@ -10,7 +10,6 @@
*******************************************************************************/
package org.aspectj.weaver;


/**
* @author colyer
*

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

@@ -17,23 +17,20 @@ import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;

public class LintMessage extends Message {
// private Lint.Kind 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();
}
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();
}

@@ -43,5 +40,5 @@ public class LintMessage extends Message {
public String getLintKind() {
return lintKind;
}
}

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

@@ -24,17 +24,13 @@ public interface Member extends Comparable {
public static final Member[] NONE = new Member[0];
public static final MemberKind METHOD = new MemberKind("METHOD", 1);
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 ADVICE = new MemberKind("ADVICE", 6);
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 ResolvedType[][] NO_PARAMETER_ANNOTATION_TYPES = new ResolvedType[][] {};
@@ -60,9 +56,8 @@ public interface Member extends Comparable {
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();

@@ -71,9 +66,8 @@ public interface Member extends Comparable {
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();


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

@@ -35,13 +35,11 @@ public class MemberImpl implements Member {
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;

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.declaringType = declaringType;
this.modifiers = modifiers;
@@ -60,8 +58,7 @@ public class MemberImpl implements Member {
}
}

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) {
this.kind = kind;
this.declaringType = declaringType;
@@ -83,10 +80,9 @@ public class MemberImpl implements Member {
// ---- 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>
*
@@ -98,15 +94,11 @@ public class MemberImpl implements Member {
*
* </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
public static String typesToSignature(UnresolvedType returnType,
UnresolvedType[] paramTypes, boolean useRawTypes) {
public static String typesToSignature(UnresolvedType returnType, UnresolvedType[] paramTypes, boolean useRawTypes) {
StringBuffer buf = new StringBuffer();
buf.append("(");
for (int i = 0, len = paramTypes.length; i < len; i++) {
@@ -128,9 +120,8 @@ public class MemberImpl implements Member {
}

/**
* 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) {
StringBuffer buf = new StringBuffer();
@@ -143,10 +134,9 @@ public class MemberImpl implements Member {
}

/**
* 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>
*
@@ -158,14 +148,10 @@ public class MemberImpl implements Member {
*
* </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) != ')';
if (hasParameters) {
List l = new ArrayList();
@@ -180,13 +166,10 @@ public class MemberImpl implements Member {
c = sig.charAt(++i);
if (c == 'L' || c == 'P') {
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;
l.add(UnresolvedType.forSignature(sig.substring(start,
i)));
l.add(UnresolvedType.forSignature(sig.substring(start, i)));
} else {
// generics generics generics
// Have to skip to the *correct* ';'
@@ -211,11 +194,10 @@ public class MemberImpl implements Member {
}
// posn now points to the correct nextSemicolon :)
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
// variable, so just "Tname;"
// variable, so just "Tname;"
int nextSemicolon = sig.indexOf(';', start);
String nextbit = sig.substring(start, nextSemicolon);
l.add(UnresolvedType.forSignature(nextbit));
@@ -225,23 +207,18 @@ public class MemberImpl implements Member {
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 };
} else {
UnresolvedType returnType = UnresolvedType.forSignature(sig
.substring(2));
UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(2));
return new Object[] { returnType, UnresolvedType.NONE };
}
}

// ---- 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
@@ -252,70 +229,55 @@ public class MemberImpl implements Member {
// OPTIMIZE do we need to call this? unless necessary the signatureToTypes()
// call smacks of laziness on the behalf of the caller
// 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);
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() {
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);
}

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);
}

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);
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(
// ??? 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);
}

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) {
if (!(other instanceof Member))
return false;
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()));
}

/**
* 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;

@@ -343,7 +305,7 @@ public class MemberImpl implements Member {
StringBuffer buf = new StringBuffer();
buf.append(returnType.getName());
buf.append(' ');
if (declaringType==null) {
if (declaringType == null) {
buf.append("<NULL>");
} else {
buf.append(declaringType.getName());
@@ -461,9 +423,8 @@ public class MemberImpl implements Member {
}

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
@@ -533,8 +494,7 @@ public class MemberImpl implements Member {
}

/**
* 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) {
if (joinPointSignatures == null) {
@@ -545,17 +505,15 @@ public class MemberImpl implements Member {
}

/**
* 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) {
if (reportedCantFindDeclaringType || reportedUnresolvableMember)
return;
ResolvedType rType = getDeclaringType().resolve(world);
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;
} else {
world.getLint().unresolvableMember.signal(getName(), null);

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

@@ -10,28 +10,39 @@
* PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver;
import java.io.DataInputStream;
import java.io.IOException;

import org.aspectj.util.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

@@ -18,12 +18,10 @@ import org.aspectj.bridge.ISourceLocation;
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 {

@@ -32,7 +30,7 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
private boolean issuedCantFindTypeError = false;
private boolean issuedJoinPointWarning = false;
private boolean issuedMissingInterfaceWarning = false;
/**
* @param signature
* @param world
@@ -41,19 +39,22 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
super(signature, world);
}

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

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

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getDeclaredFields()
*/
public ResolvedMember[] getDeclaredFields() {
@@ -61,7 +62,9 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
return NO_MEMBERS;
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getDeclaredMethods()
*/
public ResolvedMember[] getDeclaredMethods() {
@@ -69,7 +72,9 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
return NO_MEMBERS;
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getDeclaredInterfaces()
*/
public ResolvedType[] getDeclaredInterfaces() {
@@ -77,7 +82,9 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
return NO_TYPES;
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getDeclaredPointcuts()
*/
public ResolvedMember[] getDeclaredPointcuts() {
@@ -85,7 +92,9 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
return NO_MEMBERS;
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getSuperclass()
*/
public ResolvedType getSuperclass() {
@@ -93,7 +102,9 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
return ResolvedType.MISSING;
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getModifiers()
*/
public int getModifiers() {
@@ -101,7 +112,9 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
return 0;
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#getSourceContext()
*/
public ISourceContext getSourceContext() {
@@ -118,94 +131,107 @@ public class MissingResolvedTypeWithKnownSignature extends ResolvedType {
public int getOffset() {
return 0;
}
public void tidy() {}

public void tidy() {
}

};
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.ResolvedType#isAssignableFrom(org.aspectj.weaver.ResolvedType)
*/
public boolean isAssignableFrom(ResolvedType other) {
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_ASSIGNABLE,other.getName());
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_ASSIGNABLE, other.getName());
return false;
}
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)
*/
public boolean isCoerceableFrom(ResolvedType other) {
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_COERCEABLE,other.getName());
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_COERCEABLE, other.getName());
return false;
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.AnnotatedElement#hasAnnotation(org.aspectj.weaver.UnresolvedType)
*/
public boolean hasAnnotation(UnresolvedType ofType) {
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_ANNOTATION);
return false;
}
public List getInterTypeMungers() {
return Collections.EMPTY_LIST;
}
public List getInterTypeMungersIncludingSupers() {
return Collections.EMPTY_LIST;
}
public List getInterTypeParentMungers() {
return Collections.EMPTY_LIST;
}
public List getInterTypeParentMungersIncludingSupers() {
return Collections.EMPTY_LIST;
}
protected void collectInterTypeMungers(List collector) {
return;
}
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();
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() {
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();
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) {
if (issuedCantFindTypeError) return;
String message = WeaverMessages.format(key,getName());
if (issuedCantFindTypeError)
return;
String message = WeaverMessages.format(key, getName());
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;
}

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();
world.getLint().cantFindType.signal(message,null);
// MessageUtil.error(world.getMessageHandler(),message);
world.getLint().cantFindType.signal(message, null);
// MessageUtil.error(world.getMessageHandler(),message);
issuedCantFindTypeError = true;
}


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

@@ -23,69 +23,73 @@ import java.io.IOException;

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

@@ -26,32 +26,34 @@ public class PerTypeWithinTargetTypeMunger extends ResolvedTypeMunger {

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

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;

public int hashCode() {
if (hashCode == 0) {
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 {
throw new RuntimeException("shouldn't be serialized");
}
public UnresolvedType getAspectType() {
return aspectType;
}
@@ -59,15 +61,14 @@ public class PerTypeWithinTargetTypeMunger extends ResolvedTypeMunger {
public Pointcut getTestPointcut() {
return testPointcut;
}
// 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
// Does not match if the target is an interface
public boolean matches(ResolvedType matchType, ResolvedType aspectType) {
return isWithinType(matchType).alwaysTrue() &&
!matchType.isInterface();
return isWithinType(matchType).alwaysTrue() && !matchType.isInterface();
}
private FuzzyBoolean isWithinType(ResolvedType type) {
while (type != null) {
if (testPointcut.getTypePattern().matchesStatically(type)) {

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

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

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

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

@@ -10,12 +10,11 @@
* PARC initial implementation
* ******************************************************************/


package org.aspectj.weaver;

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

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

@@ -10,7 +10,6 @@
* PARC initial implementation
* ******************************************************************/


package org.aspectj.weaver;

import java.io.DataOutputStream;
@@ -20,7 +19,6 @@ public class PrivilegedAccessMunger extends ResolvedTypeMunger {
public PrivilegedAccessMunger(ResolvedMember member) {
super(PrivilegedAccess, member);
}

public void write(DataOutputStream s) throws IOException {
throw new RuntimeException("shouldn't be serialized");
@@ -34,36 +32,41 @@ public class PrivilegedAccessMunger extends ResolvedTypeMunger {
ResolvedMember ret;
if (getSignature().getKind() == Member.FIELD) {
ret = AjcMemberMaker.privilegedAccessMethodForFieldGet(aspectType, getSignature());
if (ResolvedType.matches(ret, member)) return getSignature();
if (ResolvedType.matches(ret, member))
return getSignature();
ret = AjcMemberMaker.privilegedAccessMethodForFieldSet(aspectType, getSignature());
if (ResolvedType.matches(ret, member)) return getSignature();
if (ResolvedType.matches(ret, member))
return getSignature();
} else {
//System.err.println("sig: " + getSignature());
// System.err.println("sig: " + getSignature());
ret = AjcMemberMaker.privilegedAccessMethodForMethod(aspectType, getSignature());
if (ResolvedType.matches(ret, member)) return getSignature();
if (ResolvedType.matches(ret, member))
return getSignature();
}
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;
}
}

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

@@ -72,7 +72,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
this.end = end;
this.sourceContext = sourceContext;
}
/**
* All overriding methods should call super
*/
@@ -80,24 +80,26 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
if (world.isXmlConfigured() && world.isAspectIncluded(declaringType)) {
TypePattern scoped = world.getAspectScope(declaringType);
if (scoped != null) {
// Check the 'cached' exclusion map
// Check the 'cached' exclusion map
Set<ResolvedType> excludedTypes = world.getExclusionMap().get(declaringType);
ResolvedType type = shadow.getEnclosingType().resolve(world);
if (excludedTypes!=null && excludedTypes.contains(type)) {
if (excludedTypes != null && excludedTypes.contains(type)) {
return false;
}
boolean b = scoped.matches(type, TypePattern.STATIC).alwaysTrue();
if (!b) {
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.add(type);
world.getExclusionMap().put(declaringType,excludedTypes);
world.getExclusionMap().put(declaringType, excludedTypes);
} else {
excludedTypes.add(type);
}
}
return false;
}
}

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

@@ -16,231 +16,225 @@ import java.lang.reflect.Modifier;

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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
return Integer.toString(i, 16);
}

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) {
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) {
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

@@ -9,7 +9,7 @@
* Contributors:
* Andy Clement IBM initial implementation
* ******************************************************************/
package org.aspectj.weaver;
package org.aspectj.weaver;

public class SimpleAnnotationValue extends AnnotationValue {

@@ -18,65 +18,93 @@ public class SimpleAnnotationValue extends AnnotationValue {
}

public SimpleAnnotationValue(int kind, Object value) {
super(kind);
super(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 char theChar;
private int theInt;
private int theInt;
private String theString;
private double theDouble;
private float theFloat;
private long theLong;
private short theShort;
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() {
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() {
return stringify();
}


}

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

@@ -10,47 +10,45 @@
* PARC initial implementation
* ******************************************************************/


package org.aspectj.weaver;


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

@@ -12,11 +12,9 @@

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 TypeVariable getTypeVariableNamed(String name);

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

@@ -13,10 +13,10 @@ package org.aspectj.weaver;

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

TypeVariable getTypeVariable();
}

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

@@ -15,70 +15,68 @@ import java.io.DataOutputStream;
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 {

private TypeVariable typeVariable;
// constructor used as place-holder when dealing with circular refs such as Enum
public UnresolvedTypeVariableReferenceType() {
super("Ljava/lang/Object;");
}
public UnresolvedTypeVariableReferenceType(TypeVariable aTypeVariable) {
super(aTypeVariable.getFirstBound().getSignature());
this.typeVariable = aTypeVariable;
}
// only used when resolving circular refs...
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.typeKind=TypeKind.TYPE_VARIABLE;
this.typeKind = TypeKind.TYPE_VARIABLE;
}
public ResolvedType resolve(World world) {
TypeVariableDeclaringElement typeVariableScope = world.getTypeVariableLookupScope();
TypeVariable resolvedTypeVariable = null;
TypeVariableReferenceType tvrt = null;
TypeVariableReferenceType tvrt = null;
if (typeVariableScope == null) {
// 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
resolvedTypeVariable = typeVariable.resolve(world);
tvrt = new TypeVariableReferenceType(resolvedTypeVariable,world);
tvrt = new TypeVariableReferenceType(resolvedTypeVariable, world);
} else {
boolean foundOK = false;
boolean foundOK = false;
resolvedTypeVariable = typeVariableScope.getTypeVariableNamed(typeVariable.getName());
// FIXME asc remove this when the shared type var stuff is sorted
if (resolvedTypeVariable == null) {
resolvedTypeVariable = typeVariable.resolve(world);
} else {
foundOK = true;
foundOK = true;
}
tvrt = new TypeVariableReferenceType(resolvedTypeVariable,world);
tvrt = new TypeVariableReferenceType(resolvedTypeVariable, world);
tvrt.fixedUp = foundOK;
}
return tvrt;
}

public boolean isTypeVariableReference() {
return true;
}
public TypeVariable getTypeVariable() {
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() {
if (typeVariable == null) {
return "<type variable not set!>";
@@ -86,11 +84,11 @@ public class UnresolvedTypeVariableReferenceType extends UnresolvedType implemen
return "T" + typeVariable.getName() + ";";
}
}
public String toDebugString() {
return typeVariable.getName();
}
public void write(DataOutputStream s) throws IOException {
super.write(s);
}
@@ -98,5 +96,5 @@ public class UnresolvedTypeVariableReferenceType extends UnresolvedType implemen
public String getErasureSignature() {
return typeVariable.getFirstBound().getSignature();
}
}

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

@@ -10,7 +10,7 @@
* Andy Clement initial implementation
* ******************************************************************/

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

import java.io.DataInputStream;
import java.io.InputStream;
@@ -22,11 +22,24 @@ import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
*/
public class VersionedDataInputStream extends DataInputStream {
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

@@ -13,9 +13,8 @@ package org.aspectj.weaver;
import java.text.MessageFormat;
import java.util.ResourceBundle;


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

public static final String ARGS_IN_DECLARE = "argsInDeclare";
@@ -35,19 +34,19 @@ public class WeaverMessages {
public static final String NO_NEWARRAY_JOINPOINTS_BY_DEFAULT = "noNewArrayJoinpointsByDefault";
public static final String UNSUPPORTED_POINTCUT_PRIMITIVE = "unsupportedPointcutPrimitive";
public static final String MISSING_TYPE_PREVENTS_MATCH = "missingTypePreventsMatch";
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 MULTIPLE_MATCHES_IN_PRECEDENCE = "multipleMatchesInPrecedence";
public static final String TWO_STARS_IN_PRECEDENCE = "circularityInPrecedenceStar";
public static final String CLASSES_IN_PRECEDENCE = "nonAspectTypesInPrecedence";
public static final String TWO_PATTERN_MATCHES_IN_PRECEDENCE = "circularityInPrecedenceTwo";
public static final String NOT_THROWABLE = "notThrowable";
public static final String ITD_CONS_ON_ASPECT = "itdConsOnAspect";
public static final String ITD_RETURN_TYPE_MISMATCH = "returnTypeMismatch";
public static final String ITD_PARAM_TYPE_MISMATCH = "paramTypeMismatch";
@@ -60,44 +59,44 @@ public class WeaverMessages {
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 CANT_OVERRIDE_FINAL_MEMBER = "cantOverrideFinalMember";
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 CIRCULAR_DEPENDENCY = "circularDependency";
public static final String MISSING_PER_CLAUSE = "missingPerClause";
public static final String WRONG_PER_CLAUSE = "wrongPerClause";
public static final String ALREADY_WOVEN = "alreadyWoven";
public static final String REWEAVABLE_MODE = "reweavableMode";
public static final String PROCESSING_REWEAVABLE = "processingReweavable";
public static final String MISSING_REWEAVABLE_TYPE = "missingReweavableType";
public static final String VERIFIED_REWEAVABLE_TYPE = "verifiedReweavableType";
public static final String ASPECT_NEEDED = "aspectNeeded";
public static final String 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_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 OVERWRITE_JSR45 = "overwriteJSR45";
public static final String IF_IN_PERCLAUSE = "ifInPerClause";
@@ -107,28 +106,27 @@ public class WeaverMessages {
public static final String AROUND_ON_PREINIT = "aroundOnPreInit";
public static final String AROUND_ON_INIT = "aroundOnInit";
public static final String AROUND_ON_INTERFACE_STATICINIT = "aroundOnInterfaceStaticInit";
public static final String PROBLEM_GENERATING_METHOD = "problemGeneratingMethod";
public static final String CLASS_TOO_BIG = "classTooBig";
public static final String ZIPFILE_ENTRY_MISSING = "zipfileEntryMissing";
public static final String ZIPFILE_ENTRY_INVALID = "zipfileEntryInvalid";
public static final String DIRECTORY_ENTRY_MISSING = "directoryEntryMissing";
public static final String OUTJAR_IN_INPUT_PATH = "outjarInInputPath";

public static final String XLINT_LOAD_ERROR = "problemLoadingXLint";
public static final String XLINTDEFAULT_LOAD_ERROR = "unableToLoadXLintDefault";
public static final String XLINTDEFAULT_LOAD_PROBLEM = "errorLoadingXLintDefault";
public static final String XLINT_KEY_ERROR = "invalidXLintKey";
public static final String XLINT_VALUE_ERROR = "invalidXLintMessageKind";
public static final String UNBOUND_FORMAL = "unboundFormalInPC";
public static final String AMBIGUOUS_BINDING = "ambiguousBindingInPC";
public static final String AMBIGUOUS_BINDING_IN_OR = "ambiguousBindingInOrPC";
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 ITDM_ON_ENUM_NOT_ALLOWED = "itdmOnEnumNotAllowed";
public static final String ITDF_ON_ENUM_NOT_ALLOWED = "itdfOnEnumNotAllowed";
@@ -143,14 +141,14 @@ public class WeaverMessages {
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 BINDING_NON_RUNTIME_RETENTION_ANNOTATION = "bindingNonRuntimeRetentionAnnotation";
public static final String INCORRECT_TARGET_FOR_DECLARE_ANNOTATION = "incorrectTargetForDeclareAnnotation";
public static final String NO_MATCH_BECAUSE_SOURCE_RETENTION = "noMatchBecauseSourceRetention";
// Annotation Value messages
public static final String INVALID_ANNOTATION_VALUE = "invalidAnnotationValue";
public static final String UNKNOWN_ANNOTATION_VALUE = "unknownAnnotationValue";
// < Java5 messages
public static final String ATANNOTATION_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atannotationNeedsJava5";
public static final String ATWITHIN_ONLY_SUPPORTED_AT_JAVA5_LEVEL = "atwithinNeedsJava5";
@@ -163,48 +161,48 @@ public class WeaverMessages {
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 ANNOTATIONS_NEED_JAVA5 = "annotationsRequireJava5";
// 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 VIOLATES_TYPE_VARIABLE_BOUNDS = "violatesTypeVariableBounds";
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_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
public static final String RETURNING_FORMAL_NOT_DECLARED_IN_ADVICE = "returningFormalNotDeclaredInAdvice";
public static final String THROWN_FORMAL_NOT_DECLARED_IN_ADVICE = "thrownFormalNotDeclaredInAdvice";
public static String format(String key) {
return bundle.getString(key);
}
public static String format(String key, Object insert) {
return MessageFormat.format(bundle.getString(key),new Object[] {insert});
return MessageFormat.format(bundle.getString(key), new Object[] { insert });
}

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

public static String format(String key, Object insert1, Object insert2, Object insert3) {
return MessageFormat.format(bundle.getString(key),new Object[] {insert1, insert2, insert3});
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) {
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

@@ -12,58 +12,59 @@
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
*/
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

@@ -1396,14 +1396,12 @@ public abstract class World implements Dump.INode {
protected boolean isExpendable(ResolvedType type) {
return (!type.equals(UnresolvedType.OBJECT) && (!type.isExposedToWeaver()) && (!type.isPrimitiveType()));
}

// map from aspect > excluded types
// 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;
}


Loading…
Cancel
Save