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.

AjAttribute.java 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  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. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver;
  13. import java.io.ByteArrayInputStream;
  14. import java.io.ByteArrayOutputStream;
  15. import java.io.DataOutputStream;
  16. import java.io.EOFException;
  17. import java.io.IOException;
  18. import org.aspectj.bridge.MessageUtil;
  19. import org.aspectj.bridge.Version;
  20. import org.aspectj.util.FileUtil;
  21. import org.aspectj.weaver.patterns.Declare;
  22. import org.aspectj.weaver.patterns.IScope;
  23. import org.aspectj.weaver.patterns.PerClause;
  24. import org.aspectj.weaver.patterns.Pointcut;
  25. /**
  26. * These attributes are written to and read from .class files (see the JVM spec).
  27. *
  28. * <p>
  29. * Each member or type can have a number of AjAttributes. Each such attribute is in 1-1 correspondence with an Unknown bcel
  30. * attribute. Creating one of these does NOTHING to the underlying thing, so if you really want to add an attribute to a particular
  31. * thing, well, you'd better actually do that.
  32. *
  33. * @author Erik Hilsdale
  34. * @author Jim Hugunin
  35. */
  36. public abstract class AjAttribute {
  37. public static final String AttributePrefix = "org.aspectj.weaver";
  38. protected abstract void write(CompressingDataOutputStream s) throws IOException;
  39. public abstract String getNameString();
  40. public char[] getNameChars() {
  41. return getNameString().toCharArray();
  42. }
  43. /**
  44. * Just writes the contents
  45. */
  46. public byte[] getBytes(ConstantPoolWriter compressor) {
  47. try {
  48. ByteArrayOutputStream b0 = new ByteArrayOutputStream();
  49. CompressingDataOutputStream s0 = new CompressingDataOutputStream(b0, compressor);
  50. write(s0);
  51. s0.close();
  52. return b0.toByteArray();
  53. } catch (IOException e) {
  54. // shouldn't happen with ByteArrayOutputStreams
  55. throw new RuntimeException("sanity check");
  56. }
  57. }
  58. /**
  59. * Writes the full attribute, i.e. name_index, length, and contents
  60. *
  61. * @param dataCompressor
  62. */
  63. public byte[] getAllBytes(short nameIndex, ConstantPoolWriter dataCompressor) {
  64. try {
  65. byte[] bytes = getBytes(dataCompressor);
  66. ByteArrayOutputStream b0 = new ByteArrayOutputStream();
  67. DataOutputStream s0 = new DataOutputStream(b0);
  68. s0.writeShort(nameIndex);
  69. s0.writeInt(bytes.length);
  70. s0.write(bytes);
  71. s0.close();
  72. return b0.toByteArray();
  73. } catch (IOException e) {
  74. // shouldn't happen with ByteArrayOutputStreams
  75. throw new RuntimeException("sanity check");
  76. }
  77. }
  78. public static AjAttribute read(AjAttribute.WeaverVersionInfo v, String name, byte[] bytes, ISourceContext context, World w,
  79. ConstantPoolReader dataDecompressor) {
  80. try {
  81. if (bytes == null) {
  82. bytes = new byte[0];
  83. }
  84. VersionedDataInputStream s = new VersionedDataInputStream(new ByteArrayInputStream(bytes), dataDecompressor);
  85. s.setVersion(v);
  86. if (name.equals(Aspect.AttributeName)) {
  87. return new Aspect(PerClause.readPerClause(s, context));
  88. } else if (name.equals(MethodDeclarationLineNumberAttribute.AttributeName)) {
  89. return MethodDeclarationLineNumberAttribute.read(s);
  90. } else if (name.equals(WeaverState.AttributeName)) {
  91. return new WeaverState(WeaverStateInfo.read(s, context));
  92. } else if (name.equals(WeaverVersionInfo.AttributeName)) {
  93. return WeaverVersionInfo.read(s);
  94. } else if (name.equals(AdviceAttribute.AttributeName)) {
  95. AdviceAttribute aa = AdviceAttribute.read(s, context);
  96. aa.getPointcut().check(context, w);
  97. return aa;
  98. } else if (name.equals(PointcutDeclarationAttribute.AttributeName)) {
  99. PointcutDeclarationAttribute pda = new PointcutDeclarationAttribute(ResolvedPointcutDefinition.read(s, context));
  100. pda.pointcutDef.getPointcut().check(context, w);
  101. return pda;
  102. } else if (name.equals(TypeMunger.AttributeName)) {
  103. return new TypeMunger(ResolvedTypeMunger.read(s, context));
  104. } else if (name.equals(AjSynthetic.AttributeName)) {
  105. return new AjSynthetic();
  106. } else if (name.equals(DeclareAttribute.AttributeName)) {
  107. return new DeclareAttribute(Declare.read(s, context));
  108. } else if (name.equals(PrivilegedAttribute.AttributeName)) {
  109. return PrivilegedAttribute.read(s, context);
  110. } else if (name.equals(SourceContextAttribute.AttributeName)) {
  111. return SourceContextAttribute.read(s);
  112. } else if (name.equals(EffectiveSignatureAttribute.AttributeName)) {
  113. return EffectiveSignatureAttribute.read(s, context);
  114. } else {
  115. // We have to tell the user about this...
  116. if (w == null || w.getMessageHandler() == null) {
  117. throw new BCException("unknown attribute" + name);
  118. }
  119. w.getMessageHandler().handleMessage(MessageUtil.warn("unknown attribute encountered " + name));
  120. return null;
  121. }
  122. } catch (BCException e) {
  123. throw new BCException("malformed " + name + " attribute (length:" + bytes.length + ")" + e);
  124. } catch (IOException e) {
  125. throw new BCException("malformed " + name + " attribute (length:" + bytes.length + ")" + e);
  126. }
  127. }
  128. // ----
  129. /**
  130. * Synthetic members should have NO advice put on them or on their contents. This attribute is currently unused as we consider
  131. * all members starting with NameMangler.PREFIX to automatically be synthetic. As we use this we might find that we want
  132. * multiple kinds of synthetic. In particular, if we want to treat the call to a synthetic getter (say, of an introduced field)
  133. * as a field reference itself, then a method might want a particular kind of AjSynthetic attribute that also includes a
  134. * signature of what it stands for.
  135. */
  136. public static class AjSynthetic extends AjAttribute {
  137. public static final String AttributeName = "org.aspectj.weaver.AjSynthetic";
  138. @Override
  139. public String getNameString() {
  140. return AttributeName;
  141. }
  142. // private ResolvedTypeMunger munger;
  143. public AjSynthetic() {
  144. }
  145. @Override
  146. public void write(CompressingDataOutputStream s) throws IOException {
  147. }
  148. }
  149. public static class TypeMunger extends AjAttribute {
  150. public static final String AttributeName = "org.aspectj.weaver.TypeMunger";
  151. @Override
  152. public String getNameString() {
  153. return AttributeName;
  154. }
  155. private final ResolvedTypeMunger munger;
  156. public TypeMunger(ResolvedTypeMunger munger) {
  157. this.munger = munger;
  158. }
  159. @Override
  160. public void write(CompressingDataOutputStream s) throws IOException {
  161. munger.write(s);
  162. }
  163. public ConcreteTypeMunger reify(World world, ResolvedType aspectType) {
  164. return world.getWeavingSupport().concreteTypeMunger(munger, aspectType);
  165. }
  166. }
  167. public static class WeaverState extends AjAttribute {
  168. public static final String AttributeName = "org.aspectj.weaver.WeaverState";
  169. @Override
  170. public String getNameString() {
  171. return AttributeName;
  172. }
  173. private final WeaverStateInfo kind;
  174. public WeaverState(WeaverStateInfo kind) {
  175. this.kind = kind;
  176. }
  177. @Override
  178. public void write(CompressingDataOutputStream s) throws IOException {
  179. kind.write(s);
  180. }
  181. public WeaverStateInfo reify() {
  182. return kind;
  183. }
  184. }
  185. public static class WeaverVersionInfo extends AjAttribute {
  186. public static final String AttributeName = "org.aspectj.weaver.WeaverVersion";
  187. // If you change the format of an AspectJ class file, you have two
  188. // options:
  189. // - changing the minor version means you have not added anything that
  190. // prevents
  191. // previous versions of the weaver from operating (e.g.
  192. // MethodDeclarationLineNumber attribute)
  193. // - changing the major version means you have added something that
  194. // prevents previous
  195. // versions of the weaver from operating correctly.
  196. //
  197. // The user will get a warning for any org.aspectj.weaver attributes the
  198. // weaver does
  199. // not recognize.
  200. // When we don't know ... (i.e. pre 1.2.1)
  201. public final static short WEAVER_VERSION_MAJOR_UNKNOWN = 0;
  202. public final static short WEAVER_VERSION_MINOR_UNKNOWN = 0;
  203. // These are the weaver major/minor numbers for AspectJ 1.2.1
  204. public final static short WEAVER_VERSION_MAJOR_AJ121 = 1;
  205. public final static short WEAVER_VERSION_MINOR_AJ121 = 0;
  206. // These are the weaver major/minor numbers for AspectJ 1.5.0
  207. public final static short WEAVER_VERSION_MAJOR_AJ150M4 = 3;
  208. public final static short WEAVER_VERSION_MAJOR_AJ150 = 2;
  209. public final static short WEAVER_VERSION_MINOR_AJ150 = 0;
  210. // These are the weaver major/minor numbers for AspectJ 1.6.0
  211. public final static short WEAVER_VERSION_MAJOR_AJ160M2 = 5;
  212. public final static short WEAVER_VERSION_MAJOR_AJ160 = 4;
  213. public final static short WEAVER_VERSION_MINOR_AJ160 = 0;
  214. // These are the weaver major/minor numbers for AspectJ 1.6.1
  215. // added annotation value binding
  216. public final static short WEAVER_VERSION_MAJOR_AJ161 = 6;
  217. public final static short WEAVER_VERSION_MINOR_AJ161 = 0;
  218. // 1.6.9 adds new style ITDs. This is used to see what version of AJ was used to
  219. // build the ITDs so we know id the generated get/set dispatchers are using old
  220. // or new style (new style will be get/setters for private ITD fields)
  221. public final static short WEAVER_VERSION_AJ169 = 7;
  222. // These are the weaver major/minor versions for *this* weaver
  223. private final static short CURRENT_VERSION_MAJOR = WEAVER_VERSION_AJ169;
  224. private final static short CURRENT_VERSION_MINOR = 0;
  225. public final static WeaverVersionInfo UNKNOWN = new WeaverVersionInfo(WEAVER_VERSION_MAJOR_UNKNOWN,
  226. WEAVER_VERSION_MINOR_UNKNOWN);
  227. public final static WeaverVersionInfo CURRENT = new WeaverVersionInfo(CURRENT_VERSION_MAJOR, CURRENT_VERSION_MINOR);
  228. // These are the versions read in from a particular class file.
  229. private final short major_version;
  230. private final short minor_version;
  231. private long buildstamp = Version.NOTIME;
  232. @Override
  233. public String getNameString() {
  234. return AttributeName;
  235. }
  236. // Default ctor uses the current version numbers
  237. public WeaverVersionInfo() {
  238. major_version = CURRENT_VERSION_MAJOR;
  239. minor_version = CURRENT_VERSION_MINOR;
  240. }
  241. public WeaverVersionInfo(short major, short minor) {
  242. major_version = major;
  243. minor_version = minor;
  244. }
  245. @Override
  246. public void write(CompressingDataOutputStream s) throws IOException {
  247. s.writeShort(CURRENT_VERSION_MAJOR);
  248. s.writeShort(CURRENT_VERSION_MINOR);
  249. s.writeLong(Version.getTime()); // build used to construct the
  250. // class...
  251. }
  252. public static WeaverVersionInfo read(VersionedDataInputStream s) throws IOException {
  253. short major = s.readShort();
  254. short minor = s.readShort();
  255. WeaverVersionInfo wvi = new WeaverVersionInfo(major, minor);
  256. if (s.getMajorVersion() >= WEAVER_VERSION_MAJOR_AJ150M4) {
  257. long stamp = 0;
  258. try {
  259. stamp = s.readLong();
  260. wvi.setBuildstamp(stamp);
  261. } catch (EOFException eof) {
  262. // didnt find that build stamp - its not the end of the
  263. // world
  264. }
  265. }
  266. return wvi;
  267. }
  268. public short getMajorVersion() {
  269. return major_version;
  270. }
  271. public short getMinorVersion() {
  272. return minor_version;
  273. }
  274. public static short getCurrentWeaverMajorVersion() {
  275. return CURRENT_VERSION_MAJOR;
  276. }
  277. public static short getCurrentWeaverMinorVersion() {
  278. return CURRENT_VERSION_MINOR;
  279. }
  280. public void setBuildstamp(long stamp) {
  281. buildstamp = stamp;
  282. }
  283. public long getBuildstamp() {
  284. return buildstamp;
  285. }
  286. @Override
  287. public String toString() {
  288. return major_version + "." + minor_version;
  289. }
  290. public static String toCurrentVersionString() {
  291. return CURRENT_VERSION_MAJOR + "." + CURRENT_VERSION_MINOR;
  292. }
  293. }
  294. public static class SourceContextAttribute extends AjAttribute {
  295. public static final String AttributeName = "org.aspectj.weaver.SourceContext";
  296. @Override
  297. public String getNameString() {
  298. return AttributeName;
  299. }
  300. private final String sourceFileName;
  301. private final int[] lineBreaks;
  302. public SourceContextAttribute(String sourceFileName, int[] lineBreaks) {
  303. this.sourceFileName = sourceFileName;
  304. this.lineBreaks = lineBreaks;
  305. }
  306. @Override
  307. public void write(CompressingDataOutputStream s) throws IOException {
  308. if (s.canCompress()) {
  309. s.writeCompressedPath(sourceFileName);
  310. } else {
  311. s.writeUTF(sourceFileName);
  312. }
  313. s.writeInt(lineBreaks.length);
  314. int previous = 0;
  315. for (int lineBreak : lineBreaks) {
  316. s.writeShort(lineBreak - previous);
  317. previous = lineBreak;
  318. }
  319. }
  320. public static SourceContextAttribute read(VersionedDataInputStream s) throws IOException {
  321. String sourceFileName = s.isAtLeast169() ? s.readPath() : s.readUTF();
  322. int lineBreaks = s.readInt();
  323. int[] lines = new int[lineBreaks];
  324. int previous = 0;
  325. for (int i = 0; i < lineBreaks; i++) {
  326. if (s.isAtLeast169()) {
  327. lines[i] = s.readShort() + previous;
  328. previous = lines[i];
  329. } else {
  330. lines[i] = s.readInt();
  331. }
  332. }
  333. return new SourceContextAttribute(sourceFileName, lines);
  334. }
  335. public int[] getLineBreaks() {
  336. return lineBreaks;
  337. }
  338. public String getSourceFileName() {
  339. return sourceFileName;
  340. }
  341. }
  342. public static class MethodDeclarationLineNumberAttribute extends AjAttribute {
  343. public static final String AttributeName = "org.aspectj.weaver.MethodDeclarationLineNumber";
  344. @Override
  345. public String getNameString() {
  346. return AttributeName;
  347. }
  348. private final int lineNumber;
  349. // AV: added in 1.5 M3 thus handling cases where we don't have that
  350. // information
  351. private final int offset;
  352. public MethodDeclarationLineNumberAttribute(int line, int offset) {
  353. lineNumber = line;
  354. this.offset = offset;
  355. }
  356. public int getLineNumber() {
  357. return lineNumber;
  358. }
  359. public int getOffset() {
  360. return offset;
  361. }
  362. @Override
  363. public void write(CompressingDataOutputStream s) throws IOException {
  364. s.writeInt(lineNumber);
  365. s.writeInt(offset);
  366. }
  367. public static MethodDeclarationLineNumberAttribute read(VersionedDataInputStream s) throws IOException {
  368. int line = s.readInt();
  369. int offset = 0;
  370. if (s.available() > 0) {
  371. offset = s.readInt();
  372. }
  373. return new MethodDeclarationLineNumberAttribute(line, offset);
  374. }
  375. @Override
  376. public String toString() {
  377. return AttributeName + ": " + lineNumber + ":" + offset;
  378. }
  379. }
  380. public static class PointcutDeclarationAttribute extends AjAttribute {
  381. public static final String AttributeName = "org.aspectj.weaver.PointcutDeclaration";
  382. @Override
  383. public String getNameString() {
  384. return AttributeName;
  385. }
  386. private final ResolvedPointcutDefinition pointcutDef;
  387. public PointcutDeclarationAttribute(ResolvedPointcutDefinition pointcutDef) {
  388. this.pointcutDef = pointcutDef;
  389. }
  390. @Override
  391. public void write(CompressingDataOutputStream s) throws IOException {
  392. pointcutDef.write(s);
  393. }
  394. public ResolvedPointcutDefinition reify() {
  395. return pointcutDef;
  396. }
  397. }
  398. public static class DeclareAttribute extends AjAttribute {
  399. public static final String AttributeName = "org.aspectj.weaver.Declare";
  400. @Override
  401. public String getNameString() {
  402. return AttributeName;
  403. }
  404. private final Declare declare;
  405. public DeclareAttribute(Declare declare) {
  406. this.declare = declare;
  407. }
  408. @Override
  409. public void write(CompressingDataOutputStream s) throws IOException {
  410. declare.write(s);
  411. }
  412. public Declare getDeclare() {
  413. return declare;
  414. }
  415. }
  416. public static class AdviceAttribute extends AjAttribute {
  417. public static final String AttributeName = "org.aspectj.weaver.Advice";
  418. @Override
  419. public String getNameString() {
  420. return AttributeName;
  421. }
  422. private final AdviceKind kind;
  423. private final Pointcut pointcut;
  424. private final int extraParameterFlags;
  425. private final int start;
  426. private final int end;
  427. private final ISourceContext sourceContext;
  428. // these are only used by around advice
  429. private boolean proceedInInners;
  430. private ResolvedMember[] proceedCallSignatures; // size == # of proceed
  431. // calls in body
  432. private boolean[] formalsUnchangedToProceed; // size == formals.size
  433. private UnresolvedType[] declaredExceptions;
  434. /**
  435. * @param start must be greater than the start of any advice declared before this one in an aspect,
  436. * otherwise, it can be any value.
  437. */
  438. public AdviceAttribute(AdviceKind kind, Pointcut pointcut, int extraArgumentFlags, int start, int end,
  439. ISourceContext sourceContext) {
  440. this.kind = kind;
  441. this.pointcut = pointcut;
  442. extraParameterFlags = extraArgumentFlags;
  443. this.start = start;
  444. this.end = end;
  445. this.sourceContext = sourceContext;
  446. // XXX put this back when testing works better (or fails better)
  447. // if (kind == AdviceKind.Around) throw new
  448. // IllegalArgumentException("not for around");
  449. }
  450. public AdviceAttribute(AdviceKind kind, Pointcut pointcut, int extraArgumentFlags, int start, int end,
  451. ISourceContext sourceContext, boolean proceedInInners, ResolvedMember[] proceedCallSignatures,
  452. boolean[] formalsUnchangedToProceed, UnresolvedType[] declaredExceptions) {
  453. this.kind = kind;
  454. this.pointcut = pointcut;
  455. extraParameterFlags = extraArgumentFlags;
  456. this.start = start;
  457. this.end = end;
  458. this.sourceContext = sourceContext;
  459. if (kind != AdviceKind.Around) {
  460. throw new IllegalArgumentException("only for around");
  461. }
  462. this.proceedInInners = proceedInInners;
  463. this.proceedCallSignatures = proceedCallSignatures;
  464. this.formalsUnchangedToProceed = formalsUnchangedToProceed;
  465. this.declaredExceptions = declaredExceptions;
  466. }
  467. public static AdviceAttribute read(VersionedDataInputStream s, ISourceContext context) throws IOException {
  468. AdviceKind kind = AdviceKind.read(s);
  469. if (kind == AdviceKind.Around) {
  470. return new AdviceAttribute(kind, Pointcut.read(s, context), s.readByte(), s.readInt(), s.readInt(), context,
  471. s.readBoolean(), ResolvedMemberImpl.readResolvedMemberArray(s, context), FileUtil.readBooleanArray(s),
  472. UnresolvedType.readArray(s));
  473. } else {
  474. return new AdviceAttribute(kind, Pointcut.read(s, context), s.readByte(), s.readInt(), s.readInt(), context);
  475. }
  476. }
  477. @Override
  478. public void write(CompressingDataOutputStream s) throws IOException {
  479. kind.write(s);
  480. pointcut.write(s);
  481. s.writeByte(extraParameterFlags);
  482. s.writeInt(start);
  483. s.writeInt(end);
  484. if (kind == AdviceKind.Around) {
  485. s.writeBoolean(proceedInInners);
  486. ResolvedMemberImpl.writeArray(proceedCallSignatures, s);
  487. FileUtil.writeBooleanArray(formalsUnchangedToProceed, s);
  488. UnresolvedType.writeArray(declaredExceptions, s);
  489. }
  490. }
  491. public Advice reify(Member signature, World world, ResolvedType concreteAspect) {
  492. return world.getWeavingSupport().createAdviceMunger(this, pointcut, signature, concreteAspect);
  493. }
  494. @Override
  495. public String toString() {
  496. return "AdviceAttribute(" + kind + ", " + pointcut + ", " + extraParameterFlags + ", " + start + ")";
  497. }
  498. public int getExtraParameterFlags() {
  499. return extraParameterFlags;
  500. }
  501. public AdviceKind getKind() {
  502. return kind;
  503. }
  504. public Pointcut getPointcut() {
  505. return pointcut;
  506. }
  507. public UnresolvedType[] getDeclaredExceptions() {
  508. return declaredExceptions;
  509. }
  510. public boolean[] getFormalsUnchangedToProceed() {
  511. return formalsUnchangedToProceed;
  512. }
  513. public ResolvedMember[] getProceedCallSignatures() {
  514. return proceedCallSignatures;
  515. }
  516. public boolean isProceedInInners() {
  517. return proceedInInners;
  518. }
  519. public int getEnd() {
  520. return end;
  521. }
  522. public ISourceContext getSourceContext() {
  523. return sourceContext;
  524. }
  525. public int getStart() {
  526. return start;
  527. }
  528. }
  529. public static class Aspect extends AjAttribute {
  530. public static final String AttributeName = "org.aspectj.weaver.Aspect";
  531. @Override
  532. public String getNameString() {
  533. return AttributeName;
  534. }
  535. private final PerClause perClause;
  536. private IScope resolutionScope;
  537. public Aspect(PerClause perClause) {
  538. this.perClause = perClause;
  539. }
  540. public PerClause reify(ResolvedType inAspect) {
  541. // XXXperClause.concretize(inAspect);
  542. return perClause;
  543. }
  544. public PerClause reifyFromAtAspectJ(ResolvedType inAspect) {
  545. perClause.resolve(resolutionScope);
  546. return perClause;
  547. }
  548. @Override
  549. public void write(CompressingDataOutputStream s) throws IOException {
  550. perClause.write(s);
  551. }
  552. public void setResolutionScope(IScope binding) {
  553. resolutionScope = binding;
  554. }
  555. }
  556. public static class PrivilegedAttribute extends AjAttribute {
  557. public static final String AttributeName = "org.aspectj.weaver.Privileged";
  558. private final ResolvedMember[] accessedMembers;
  559. public PrivilegedAttribute(ResolvedMember[] accessedMembers) {
  560. this.accessedMembers = accessedMembers;
  561. }
  562. @Override
  563. public void write(CompressingDataOutputStream s) throws IOException {
  564. ResolvedMemberImpl.writeArray(accessedMembers, s);
  565. }
  566. public ResolvedMember[] getAccessedMembers() {
  567. return accessedMembers;
  568. }
  569. public static PrivilegedAttribute read(VersionedDataInputStream stream, ISourceContext context) throws IOException {
  570. PrivilegedAttribute pa = new PrivilegedAttribute(ResolvedMemberImpl.readResolvedMemberArray(stream, context));
  571. return pa;
  572. }
  573. @Override
  574. public String getNameString() {
  575. return AttributeName;
  576. }
  577. }
  578. public static class EffectiveSignatureAttribute extends AjAttribute {
  579. public static final String AttributeName = "org.aspectj.weaver.EffectiveSignature";
  580. @Override
  581. public String getNameString() {
  582. return AttributeName;
  583. }
  584. private final ResolvedMember effectiveSignature;
  585. private final Shadow.Kind shadowKind;
  586. private final boolean weaveBody;
  587. public EffectiveSignatureAttribute(ResolvedMember effectiveSignature, Shadow.Kind shadowKind, boolean weaveBody) {
  588. this.effectiveSignature = effectiveSignature;
  589. this.shadowKind = shadowKind;
  590. this.weaveBody = weaveBody;
  591. }
  592. @Override
  593. public void write(CompressingDataOutputStream s) throws IOException {
  594. effectiveSignature.write(s);
  595. shadowKind.write(s);
  596. s.writeBoolean(weaveBody);
  597. }
  598. public static EffectiveSignatureAttribute read(VersionedDataInputStream s, ISourceContext context) throws IOException {
  599. ResolvedMember member = ResolvedMemberImpl.readResolvedMember(s, context);
  600. return new EffectiveSignatureAttribute(member, Shadow.Kind.read(s), s.readBoolean());
  601. }
  602. public ResolvedMember getEffectiveSignature() {
  603. return effectiveSignature;
  604. }
  605. @Override
  606. public String toString() {
  607. return "EffectiveSignatureAttribute(" + effectiveSignature + ", " + shadowKind + ")";
  608. }
  609. public Shadow.Kind getShadowKind() {
  610. return shadowKind;
  611. }
  612. public boolean isWeaveBody() {
  613. return weaveBody;
  614. }
  615. }
  616. }