You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AsmDelegate.java 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /* *******************************************************************
  2. * Copyright (c) 2006 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Andy Clement IBM initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver.asm;
  13. import java.io.IOException;
  14. import java.io.InputStream;
  15. import java.util.ArrayList;
  16. import java.util.Collection;
  17. import java.util.Collections;
  18. import java.util.Iterator;
  19. import java.util.List;
  20. import org.aspectj.apache.bcel.classfile.GenericSignatureParser;
  21. import org.aspectj.apache.bcel.classfile.Signature;
  22. import org.aspectj.org.objectweb.asm.Attribute;
  23. import org.aspectj.org.objectweb.asm.ClassReader;
  24. import org.aspectj.org.objectweb.asm.Opcodes;
  25. import org.aspectj.weaver.AbstractReferenceTypeDelegate;
  26. import org.aspectj.weaver.AjAttribute;
  27. import org.aspectj.weaver.AnnotationAJ;
  28. import org.aspectj.weaver.AnnotationTargetKind;
  29. import org.aspectj.weaver.AnnotationX;
  30. import org.aspectj.weaver.ISourceContext;
  31. import org.aspectj.weaver.ReferenceType;
  32. import org.aspectj.weaver.ResolvedMember;
  33. import org.aspectj.weaver.ResolvedMemberImpl;
  34. import org.aspectj.weaver.ResolvedPointcutDefinition;
  35. import org.aspectj.weaver.ResolvedType;
  36. import org.aspectj.weaver.SourceContextImpl;
  37. import org.aspectj.weaver.TypeVariable;
  38. import org.aspectj.weaver.UnresolvedType;
  39. import org.aspectj.weaver.WeaverStateInfo;
  40. import org.aspectj.weaver.World;
  41. import org.aspectj.weaver.AjAttribute.DeclareAttribute;
  42. import org.aspectj.weaver.AjAttribute.PointcutDeclarationAttribute;
  43. import org.aspectj.weaver.AjAttribute.PrivilegedAttribute;
  44. import org.aspectj.weaver.AjAttribute.SourceContextAttribute;
  45. import org.aspectj.weaver.AjAttribute.TypeMunger;
  46. import org.aspectj.weaver.AjAttribute.WeaverState;
  47. import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
  48. import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter;
  49. import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.GenericSignatureFormatException;
  50. import org.aspectj.weaver.patterns.PerClause;
  51. /**
  52. * A lightweight fast delegate that is an alternative to a BCEL delegate.
  53. * The type being represented is being referenced during a compile
  54. * or weave but is not exposed to the weaver, for example java.lang.String.
  55. * Unnecessary information is not processed - for example the linenumbertable.
  56. *
  57. * What might need visiting that currently isnt?
  58. * - methods so we can get their annotations
  59. *
  60. * Implementation:
  61. * The state in this type is populated by an ASM ClassVisitor, attributes and
  62. * annotations are mostly unpacked lazily.
  63. *
  64. * @author AndyClement
  65. */
  66. public class AsmDelegate extends AbstractReferenceTypeDelegate {
  67. public static boolean careAboutMemberAnnotationsAndAttributes = true;
  68. private World w;
  69. int classModifiers;
  70. ResolvedPointcutDefinition[] pointcuts = null;
  71. TypeVariable[] typeVariables; // filled in when signature is parsed
  72. ResolvedType[] annotationTypes;
  73. AnnotationX[] annotationXs;
  74. List annotations = Collections.EMPTY_LIST;
  75. ResolvedMember[] methods;
  76. ResolvedMember[] fields;
  77. List attributes = Collections.EMPTY_LIST;
  78. Collection /*of Declare*/ declares = null;
  79. Collection /*of ConcreteTypeMunger*/ typeMungers = null;
  80. Collection /*of ResolvedMember*/ privilegedAccesses = null;
  81. private int bitflag = 0; // see below for the relevant bits
  82. private final static int DISCOVERED_POINTCUTS = 0x0001;// guard for lazy initialization of pointcuts
  83. private final static int DISCOVERED_DECLARES = 0x0002;// guard for lazy initialization of declares
  84. private final static int DISCOVERED_TYPEMUNGERS = 0x0004;// guard for lazy initialization of type mungers
  85. private final static int DISCOVERED_PRIVILEGEDACCESSES = 0x0008;// guard for lazy initialization of privileged access list
  86. private final static int DISCOVERED_SOURCECONTEXT = 0x0010;// Sourcecontext is actually held in supertype
  87. private final static int DISCOVERED_WEAVERSTATEINFO = 0x0020;
  88. private final static int SIGNATURE_UNPACKED = 0x0040;
  89. private final static int ANNOTATION_TYPES_CORRECT = 0x0080;
  90. private final static int ANNOTATIONX_CORRECT = 0x0100;
  91. private final static int SUPERSET = 0x0200;
  92. private final static int FIELDSFIXEDUP = 0x0400;
  93. private final static int METHODSFIXEDUP = 0x0800;
  94. private ResolvedType superclassType = null;
  95. String superclassName = null;
  96. private ResolvedType[] interfaceTypes = null;
  97. String[] interfaceNames = null;
  98. // For the fields below, which are set based on attribute or annotation values,
  99. // some are 'eager' and set as the visitor goes through the type. Some are
  100. // lazy and only set when someone requests their value
  101. // eager: populated from the 'Aspect' attribute
  102. boolean isAspect = false;
  103. PerClause perClause = null;
  104. // eager: populated from the 'WeaverVersionInfo' attribute
  105. WeaverVersionInfo weaverVersion = AjAttribute.WeaverVersionInfo.UNKNOWN;
  106. // lazy: populated from the 'WeaverStateInfo' attribute
  107. WeaverStateInfo weaverStateInfo = null;
  108. // eager: populated from the visitInnerClass method in the TypeVisitor
  109. boolean isAnonymous = false;
  110. boolean isNested = false;
  111. // eager: populated from the visit method in the TypeVisitor
  112. boolean isGenericType = false;
  113. String declaredSignature = null;
  114. // eager: populated from the 'Retention' annotation
  115. boolean isRuntimeRetention = false;
  116. String retentionPolicy = null;
  117. // eager: populated from the 'Target' annotation
  118. boolean canAnnotationTargetType = true; // true unless we learn otherwise
  119. AnnotationTargetKind[] targetKinds = null;
  120. // -----
  121. public AsmDelegate(ReferenceType rt,InputStream inputStream) {
  122. super(rt,false);
  123. w = rt.getWorld();
  124. try {
  125. new ClassReader(inputStream).accept(new TypeVisitor(this),AsmConstants.ajAttributes,true);
  126. inputStream.close();
  127. // why-o-why-o-why ?
  128. if ((classModifiers&4096)>0) classModifiers-=4096; // remove SYNTHETIC
  129. if ((classModifiers&131072)>0) classModifiers-=131072; // remove DEPRECATED
  130. } catch (IOException ioe) {
  131. ioe.printStackTrace();
  132. }
  133. setSourceContext(new SourceContextImpl(this));
  134. }
  135. public boolean isAnnotationStyleAspect() {
  136. return false;
  137. }
  138. public boolean canAnnotationTargetType() {
  139. return canAnnotationTargetType;
  140. }
  141. public AnnotationTargetKind[] getAnnotationTargetKinds() {
  142. return targetKinds;
  143. }
  144. public boolean isGeneric() {
  145. return isGenericType;
  146. }
  147. public boolean isAnonymous() {
  148. return isAnonymous;
  149. }
  150. public boolean isNested() {
  151. return isNested;
  152. }
  153. public boolean hasAnnotation(UnresolvedType ofType) {
  154. ensureAnnotationsUnpacked();
  155. for (int i = 0; i < annotationTypes.length; i++) {
  156. if (annotationTypes[i].equals(ofType)) return true;
  157. }
  158. return false;
  159. }
  160. public AnnotationX[] getAnnotations() {
  161. ensureAnnotationXsUnpacked();
  162. return annotationXs;
  163. }
  164. public ResolvedType[] getAnnotationTypes() {
  165. ensureAnnotationsUnpacked();
  166. return annotationTypes;
  167. }
  168. private void ensureAnnotationXsUnpacked() {
  169. if ( (bitflag&ANNOTATION_TYPES_CORRECT)!=0 && (bitflag&ANNOTATIONX_CORRECT)!=0) return;
  170. ensureAnnotationsUnpacked();
  171. if (annotations.size()==0) {
  172. annotationXs = AnnotationX.NONE;
  173. } else {
  174. annotationXs = new AnnotationX[annotations.size()];
  175. int pos = 0;
  176. for (Iterator iter = annotations.iterator(); iter.hasNext();) {
  177. AnnotationAJ element = (AnnotationAJ) iter.next();
  178. annotationXs[pos++] = new AnnotationX(element,w);
  179. }
  180. annotations = null; // dont need them any more!
  181. }
  182. bitflag|=ANNOTATIONX_CORRECT;
  183. }
  184. private void ensureAnnotationsUnpacked() {
  185. if ((bitflag&ANNOTATION_TYPES_CORRECT)!=0) return;
  186. if (annotations.size()==0) {
  187. annotationTypes = ResolvedType.NONE;
  188. } else {
  189. annotationTypes = new ResolvedType[annotations.size()];
  190. int pos = 0;
  191. for (Iterator iter = annotations.iterator(); iter.hasNext();) {
  192. AnnotationAJ element = (AnnotationAJ) iter.next();
  193. annotationTypes[pos++] = w.resolve(UnresolvedType.forSignature(element.getTypeSignature()));
  194. }
  195. }
  196. bitflag|=ANNOTATION_TYPES_CORRECT;
  197. }
  198. public Signature.FormalTypeParameter[] getAllFormals() {
  199. ensureSignatureUnpacked();
  200. if (formalsForResolution == null) {
  201. return new Signature.FormalTypeParameter[0];
  202. } else {
  203. return formalsForResolution;
  204. }
  205. }
  206. // for testing - if we have this attribute, return it - will return null if it doesnt know anything
  207. public AjAttribute[] getAttributes(String name) {
  208. List results = new ArrayList();
  209. for (Iterator iter = attributes.iterator(); iter.hasNext();) {
  210. Attribute element = (Attribute) iter.next();
  211. if (element.type.equals(name) && (element instanceof AjASMAttribute)) {
  212. results.add(((AjASMAttribute)element).unpack(this));
  213. }
  214. }
  215. if (results.size()>0) {
  216. return (AjAttribute[])results.toArray(new AjAttribute[]{});
  217. }
  218. return null;
  219. }
  220. // for testing - use with the method above
  221. public String[] getAttributeNames() {
  222. String[] strs = new String[attributes.size()];
  223. int i = 0;
  224. for (Iterator iter = attributes.iterator(); iter.hasNext();) {
  225. Attribute element = (Attribute) iter.next();
  226. strs[i++] = element.type;
  227. }
  228. return strs;
  229. }
  230. public ISourceContext getSourceContext() {
  231. if ((bitflag&DISCOVERED_SOURCECONTEXT)==0) {
  232. bitflag|=DISCOVERED_SOURCECONTEXT;
  233. Attribute foundIt = null;
  234. for (Iterator iter = attributes.iterator(); iter.hasNext();) {
  235. Object o = iter.next();
  236. if (o instanceof AjASMAttribute) {
  237. AjASMAttribute element = (AjASMAttribute) o;
  238. if (element.type.equals(AjAttribute.SourceContextAttribute.AttributeName)) {
  239. foundIt = element;
  240. SourceContextAttribute sca = (SourceContextAttribute)((AjASMAttribute)element).unpack(this);
  241. if (super.getSourceContext()==SourceContextImpl.UNKNOWN_SOURCE_CONTEXT) {
  242. super.setSourceContext(new SourceContextImpl(this));
  243. }
  244. ((SourceContextImpl)super.getSourceContext()).configureFromAttribute(sca.getSourceFileName(),sca.getLineBreaks());
  245. break;
  246. }
  247. }
  248. }
  249. if (foundIt!=null) attributes.remove(foundIt); // Save space
  250. }
  251. return super.getSourceContext();
  252. }
  253. public WeaverStateInfo getWeaverState() {
  254. if ((bitflag&DISCOVERED_WEAVERSTATEINFO)==0) {
  255. for (Iterator iter = attributes.iterator(); iter.hasNext();) {
  256. Object o = iter.next();
  257. if (o instanceof AjASMAttribute) {
  258. AjASMAttribute element = (AjASMAttribute) o;
  259. if (element.type.equals(AjAttribute.WeaverState.AttributeName)) {
  260. WeaverState wsInfo = (WeaverState)((AjASMAttribute)element).unpack(this);
  261. weaverStateInfo = wsInfo.reify();
  262. break;
  263. }
  264. }
  265. }
  266. bitflag|=DISCOVERED_WEAVERSTATEINFO;
  267. }
  268. return weaverStateInfo;
  269. }
  270. public String getDeclaredGenericSignature() {
  271. return declaredSignature;
  272. }
  273. public Collection getTypeMungers() {
  274. if ((bitflag&DISCOVERED_TYPEMUNGERS)==0) {
  275. typeMungers = new ArrayList();
  276. for (Iterator iter = attributes.iterator(); iter.hasNext();) {
  277. Object o = iter.next();
  278. if (o instanceof AjASMAttribute) {
  279. AjASMAttribute element = (AjASMAttribute) o;
  280. if (element.type.equals(AjAttribute.TypeMunger.AttributeName)) {
  281. TypeMunger typeMunger = (TypeMunger)((AjASMAttribute)element).unpack(this);
  282. typeMungers.add(typeMunger.reify(w,getResolvedTypeX()));
  283. }
  284. }
  285. }
  286. bitflag|=DISCOVERED_TYPEMUNGERS;
  287. }
  288. return typeMungers;
  289. }
  290. public Collection getPrivilegedAccesses() {
  291. if ((bitflag&DISCOVERED_PRIVILEGEDACCESSES)==0) {
  292. privilegedAccesses = new ArrayList();
  293. for (Iterator iter = attributes.iterator(); iter.hasNext();) {
  294. Object o = iter.next();
  295. if (o instanceof AjASMAttribute) {
  296. AjASMAttribute element = (AjASMAttribute) o;
  297. if (element.type.equals(AjAttribute.PrivilegedAttribute.AttributeName)) {
  298. PrivilegedAttribute privilegedAttribute = (PrivilegedAttribute)((AjASMAttribute)element).unpack(this);
  299. ResolvedMember[] pas =privilegedAttribute.getAccessedMembers();
  300. for (int i = 0; i < pas.length; i++) {
  301. privilegedAccesses.add(pas[i]);
  302. }
  303. }
  304. }
  305. }
  306. bitflag|=DISCOVERED_PRIVILEGEDACCESSES;
  307. }
  308. return privilegedAccesses;
  309. }
  310. public TypeVariable[] getTypeVariables() {
  311. ensureSignatureUnpacked();
  312. return typeVariables;
  313. }
  314. private Signature.FormalTypeParameter[] formalsForResolution = null;
  315. private void ensureSignatureUnpacked() {
  316. if ((bitflag&SIGNATURE_UNPACKED)!=0) return;
  317. typeVariables=TypeVariable.NONE;
  318. if (!getResolvedTypeX().getWorld().isInJava5Mode()) {
  319. bitflag|=SIGNATURE_UNPACKED;
  320. return;
  321. }
  322. if (declaredSignature!=null) {
  323. GenericSignatureParser parser = new GenericSignatureParser();
  324. Signature.ClassSignature cSig = parser.parseAsClassSignature(declaredSignature);
  325. typeVariables = new TypeVariable[cSig.formalTypeParameters.length];
  326. for (int i = 0; i < typeVariables.length; i++) {
  327. Signature.FormalTypeParameter ftp = cSig.formalTypeParameters[i];
  328. try {
  329. typeVariables[i] = BcelGenericSignatureToTypeXConverter.formalTypeParameter2TypeVariable(
  330. ftp,
  331. cSig.formalTypeParameters,
  332. getResolvedTypeX().getWorld());
  333. } catch (GenericSignatureFormatException e) {
  334. // this is a development bug, so fail fast with good info
  335. throw new IllegalStateException(
  336. "While getting the type variables for type " + this.toString()
  337. + " with generic signature " + cSig +
  338. " the following error condition was detected: " + e.getMessage());
  339. }
  340. }
  341. if (cSig != null) {
  342. formalsForResolution = cSig.formalTypeParameters;
  343. if (isNested()) {
  344. // we have to find any type variables from the outer type before proceeding with resolution.
  345. Signature.FormalTypeParameter[] extraFormals = getFormalTypeParametersFromOuterClass();
  346. if (extraFormals.length > 0) {
  347. List allFormals = new ArrayList();
  348. for (int i = 0; i < formalsForResolution.length; i++) {
  349. allFormals.add(formalsForResolution[i]);
  350. }
  351. for (int i = 0; i < extraFormals.length; i++) {
  352. allFormals.add(extraFormals[i]);
  353. }
  354. formalsForResolution = new Signature.FormalTypeParameter[allFormals.size()];
  355. allFormals.toArray(formalsForResolution);
  356. }
  357. }
  358. Signature.ClassTypeSignature superSig = cSig.superclassSignature;
  359. try {
  360. this.superclassType =
  361. BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
  362. superSig, formalsForResolution, getResolvedTypeX().getWorld());
  363. bitflag|=SUPERSET;
  364. } catch (GenericSignatureFormatException e) {
  365. // development bug, fail fast with good info
  366. throw new IllegalStateException(
  367. "While determing the generic superclass of " + getResolvedTypeX()
  368. + " with generic signature " + declaredSignature + " the following error was detected: "
  369. + e.getMessage());
  370. }
  371. this.interfaceTypes = new ResolvedType[cSig.superInterfaceSignatures.length];
  372. for (int i = 0; i < cSig.superInterfaceSignatures.length; i++) {
  373. try {
  374. this.interfaceTypes[i] =
  375. BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
  376. cSig.superInterfaceSignatures[i],
  377. formalsForResolution,
  378. getResolvedTypeX().getWorld());
  379. } catch (GenericSignatureFormatException e) {
  380. // development bug, fail fast with good info
  381. throw new IllegalStateException(
  382. "While determing the generic superinterfaces of " + getResolvedTypeX()
  383. + " with generic signature " + declaredSignature + " the following error was detected: "
  384. + e.getMessage());
  385. }
  386. }
  387. if (isGeneric()) {
  388. // update resolved typex to point at generic type not raw type.
  389. ReferenceType genericType = (ReferenceType) this.resolvedTypeX.getGenericType();
  390. //genericType.setSourceContext(this.resolvedTypeX.getSourceContext());
  391. genericType.setStartPos(this.resolvedTypeX.getStartPos());
  392. this.resolvedTypeX = genericType;
  393. }
  394. }
  395. }
  396. bitflag|=SIGNATURE_UNPACKED;
  397. }
  398. public ResolvedType getOuterClass() {
  399. if (!isNested()) throw new IllegalStateException("Can't get the outer class of a non-nested type");
  400. int lastDollar = getResolvedTypeX().getName().lastIndexOf('$');
  401. String superClassName = getResolvedTypeX().getName().substring(0,lastDollar);
  402. UnresolvedType outer = UnresolvedType.forName(superClassName);
  403. return (ReferenceType) outer.resolve(getResolvedTypeX().getWorld());
  404. }
  405. public boolean isInterface() {
  406. return (classModifiers & Opcodes.ACC_INTERFACE)!=0;
  407. }
  408. public String getRetentionPolicy() {
  409. return retentionPolicy;
  410. }
  411. public boolean isAnnotationWithRuntimeRetention() {
  412. return isRuntimeRetention;
  413. }
  414. public boolean isAnnotation() {
  415. return (classModifiers & Opcodes.ACC_ANNOTATION)!=0;
  416. }
  417. public boolean isEnum() {
  418. return(classModifiers & Opcodes.ACC_ENUM)!=0;
  419. }
  420. public int getModifiers() {
  421. return classModifiers;
  422. }
  423. public ResolvedMember[] getDeclaredFields() {
  424. ensureSignatureUnpacked();
  425. if ((bitflag&FIELDSFIXEDUP)==0) {
  426. for (int i = 0; i < fields.length; i++) {
  427. ((ResolvedMemberImpl)fields[i]).setDeclaringType(getResolvedTypeX());
  428. }
  429. bitflag|=FIELDSFIXEDUP;
  430. }
  431. return fields;
  432. }
  433. public ResolvedType[] getDeclaredInterfaces() {
  434. if (interfaceTypes == null) {
  435. if (interfaceNames==null || interfaceNames.length==0) {
  436. interfaceTypes = new ResolvedType[0];
  437. } else {
  438. interfaceTypes = new ResolvedType[interfaceNames.length];
  439. for (int i = 0; i < interfaceNames.length; i++) {
  440. interfaceTypes[i] = w.resolve(interfaceNames[i].replace('/','.'));
  441. }
  442. }
  443. interfaceNames=null;
  444. ensureSignatureUnpacked();
  445. }
  446. return interfaceTypes;
  447. }
  448. public ResolvedMember[] getDeclaredMethods() {
  449. ensureSignatureUnpacked();
  450. if ((bitflag&METHODSFIXEDUP)==0) {
  451. for (int i = 0; i < methods.length; i++) {
  452. ((ResolvedMemberImpl)methods[i]).setDeclaringType(getResolvedTypeX());
  453. }
  454. bitflag|=METHODSFIXEDUP;
  455. }
  456. return methods;
  457. }
  458. public ResolvedMember[] getDeclaredPointcuts() {
  459. if ((bitflag & DISCOVERED_POINTCUTS)==0) {
  460. List pcts = new ArrayList();
  461. List forRemoval = new ArrayList();
  462. for (Iterator iter = attributes.iterator(); iter.hasNext();) {
  463. Object o = iter.next();
  464. if (o instanceof AjASMAttribute) {
  465. AjASMAttribute element = (AjASMAttribute) o;
  466. if (element.type.equals(AjAttribute.PointcutDeclarationAttribute.AttributeName)) {
  467. PointcutDeclarationAttribute pointcut = (PointcutDeclarationAttribute)((AjASMAttribute)element).unpack(this);
  468. pcts.add(pointcut.reify());
  469. forRemoval.add(element);
  470. }
  471. }
  472. }
  473. pointcuts = (ResolvedPointcutDefinition[])pcts.toArray(new ResolvedPointcutDefinition[]{});
  474. attributes.removeAll(forRemoval);
  475. bitflag|=DISCOVERED_POINTCUTS;
  476. }
  477. return pointcuts;
  478. }
  479. public Collection getDeclares() {
  480. if ((bitflag & DISCOVERED_DECLARES)==0) {
  481. declares = new ArrayList();
  482. List forRemoval = new ArrayList();
  483. for (Iterator iter = attributes.iterator(); iter.hasNext();) {
  484. Object o = iter.next();
  485. if (o instanceof AjASMAttribute) {
  486. AjASMAttribute element = (AjASMAttribute) o;
  487. if (element.type.equals(AjAttribute.DeclareAttribute.AttributeName)) {
  488. DeclareAttribute declare = (DeclareAttribute)((AjASMAttribute)element).unpack(this);
  489. declares.add(declare.getDeclare());
  490. forRemoval.add(element);
  491. }
  492. }
  493. }
  494. attributes.removeAll(forRemoval);
  495. bitflag|=DISCOVERED_DECLARES;//discoveredDeclares=true;
  496. }
  497. return declares;
  498. }
  499. public ResolvedType getSuperclass() {
  500. if ((bitflag&SUPERSET)==0) {
  501. if (superclassName == null) {
  502. // this type must be jlObject
  503. superclassType = null;
  504. } else {
  505. superclassType = w.resolve(superclassName.replace('/','.'));
  506. }
  507. ensureSignatureUnpacked();
  508. superclassName=null;
  509. bitflag|=SUPERSET;
  510. }
  511. return superclassType;
  512. }
  513. public PerClause getPerClause() {
  514. return perClause;
  515. }
  516. public boolean isAspect() {
  517. return isAspect;
  518. }
  519. World getWorld() { return w; }
  520. // ---
  521. // 14-Feb-06 the AsmDelegate is only for types that won't be 'woven', so they can't be a target
  522. // to have new annotations added
  523. public void addAnnotation(AnnotationX annotationX) { /* this method left blank on purpose*/ }
  524. public void ensureDelegateConsistent() {
  525. // doesnt need to do anything until methods like addAnnotation() are implemented (i.e. methods that
  526. // modify the delegate such that it differs from the on-disk contents)
  527. }
  528. }