diff options
author | acolyer <acolyer> | 2005-11-04 13:06:27 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-11-04 13:06:27 +0000 |
commit | 590f81aacbd8fdc9cb3aebef76a3f2da1034a7f8 (patch) | |
tree | 166328d7302d4c30a4adf68445b751e5f0258ab8 /bcel-builder/src | |
parent | f74be5e86f34b9ced867c4687da11caf390532a0 (diff) | |
download | aspectj-590f81aacbd8fdc9cb3aebef76a3f2da1034a7f8.tar.gz aspectj-590f81aacbd8fdc9cb3aebef76a3f2da1034a7f8.zip |
add support and tests for isAnonymous in JavaClass
Diffstat (limited to 'bcel-builder/src')
-rw-r--r-- | bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java index e92f6a798..2a1bf1526 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java @@ -77,7 +77,7 @@ import java.util.StringTokenizer; * class file. Those interested in programatically generating classes * should see the <a href="../generic/ClassGen.html">ClassGen</a> class. - * @version $Id: JavaClass.java,v 1.7 2005/09/21 15:02:05 acolyer Exp $ + * @version $Id: JavaClass.java,v 1.8 2005/11/04 13:06:27 acolyer Exp $ * @see org.aspectj.apache.bcel.generic.ClassGen * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ @@ -723,6 +723,24 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { return (access_flags & Constants.ACC_INTERFACE) == 0; } + public final boolean isAnonymous() { + for (int i = 0; i < this.attributes.length; i++) { + if (this.attributes[i] instanceof InnerClasses) { + InnerClass[] innerClasses = ((InnerClasses) this.attributes[i]).getInnerClasses(); + for (int j = 0; j < innerClasses.length; j++) { + if (innerClasses[j].getInnerNameIndex() == 0) { + // this is an anonymous class, but is it me, or a class contained in me?? + String inner_class_name = constant_pool.getConstantString(innerClasses[j].getInnerClassIndex(), + Constants.CONSTANT_Class); + inner_class_name = Utility.compactClassName(inner_class_name); + if (inner_class_name.equals(getClassName())) return true; + } + } + } + } + return false; + } + // J5SUPPORT: /** * Returns true if this class represents an annotation, i.e. it was a |