diff options
author | aclement <aclement> | 2005-06-01 14:55:44 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-06-01 14:55:44 +0000 |
commit | a2face5f02864185f69466416034c1530af8a275 (patch) | |
tree | 58fbb3452f0775306a71b4f409d2f5a350e72e9e /bcel-builder | |
parent | f800dc9be1d6f90cfb8085e38a380dc2e447d1d4 (diff) | |
download | aspectj-a2face5f02864185f69466416034c1530af8a275.tar.gz aspectj-a2face5f02864185f69466416034c1530af8a275.zip |
GenericsWork: Members now recognize that they can have a signature attribute attached that records the signature pre-erasure. It is accessible through 'getDeclaredSignature()' and is resolved lazily.
Diffstat (limited to 'bcel-builder')
-rw-r--r-- | bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java index 2780e7c44..58a535571 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java @@ -64,7 +64,7 @@ import java.util.List; /** * Abstract super class for fields and methods. * - * @version $Id: FieldOrMethod.java,v 1.3 2005/03/10 12:15:04 aclement Exp $ + * @version $Id: FieldOrMethod.java,v 1.4 2005/06/01 14:55:44 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node { @@ -74,6 +74,9 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No protected Attribute[] attributes; // Collection of attributes private Annotation[] annotations; // annotations defined on the field or method protected ConstantPool constant_pool; + + private String signatureAttributeString = null; + private boolean searchedForSignatureAttribute = false; // Annotations are collected from certain attributes, don't do it more than necessary! @@ -213,6 +216,16 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No } /** + * This will return the contents of a signature attribute attached to a member, or if there + * is none it will return the same as 'getSignature()'. Signature attributes are attached + * to members that were declared generic. + */ + public final String getDeclaredSignature() { + if (getRealSignatureFromAttribute()!=null) return getRealSignatureFromAttribute(); + return getSignature(); + } + + /** * @return deep copy of this field */ protected FieldOrMethod copy_(ConstantPool constant_pool) { @@ -267,4 +280,25 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No newAnnotations[len] = a; annotations = newAnnotations; } + + + /** + * Hunts for a signature attribute on the member and returns its contents. So where the 'regular' signature + * may be (Ljava/util/Vector;)V the signature attribute may in fact say '(Ljava/util/Vector<Ljava/lang/String;>;)V' + * Coded for performance - searches for the attribute only when requested - only searches for it once. + */ + public final String getRealSignatureFromAttribute() { + if (!searchedForSignatureAttribute) { + boolean found=false; + for(int i=0; !found && i < attributes_count; i++) { + if(attributes[i] instanceof Signature) { + signatureAttributeString = ((Signature)attributes[i]).getSignature(); + found=true; + } + } + searchedForSignatureAttribute=true; + } + return signatureAttributeString; + } + } |