Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

NewConstructorTypeMunger.java 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver;
  13. import java.io.DataInputStream;
  14. import java.io.DataOutputStream;
  15. import java.io.IOException;
  16. import java.util.Set;
  17. import org.aspectj.bridge.IMessage;
  18. public class NewConstructorTypeMunger extends ResolvedTypeMunger {
  19. private ResolvedMember syntheticConstructor;
  20. private ResolvedMember explicitConstructor;
  21. public NewConstructorTypeMunger(
  22. ResolvedMember signature,
  23. ResolvedMember syntheticConstructor,
  24. ResolvedMember explicitConstructor,
  25. Set superMethodsCalled)
  26. {
  27. super(Constructor, signature);
  28. this.syntheticConstructor = syntheticConstructor;
  29. this.explicitConstructor = explicitConstructor;
  30. this.setSuperMethodsCalled(superMethodsCalled);
  31. }
  32. //XXX horrible name clash here
  33. public ResolvedMember getDispatchMethod(TypeX aspectType) {
  34. return AjcMemberMaker.interMethodBody(signature, aspectType);
  35. }
  36. public void write(DataOutputStream s) throws IOException {
  37. kind.write(s);
  38. signature.write(s);
  39. syntheticConstructor.write(s);
  40. explicitConstructor.write(s);
  41. writeSuperMethodsCalled(s);
  42. if (ResolvedTypeMunger.persistSourceLocation) writeSourceLocation(s);
  43. }
  44. public static ResolvedTypeMunger readConstructor(DataInputStream s, ISourceContext context) throws IOException {
  45. ResolvedTypeMunger munger = new NewConstructorTypeMunger(
  46. ResolvedMember.readResolvedMember(s, context),
  47. ResolvedMember.readResolvedMember(s, context),
  48. ResolvedMember.readResolvedMember(s, context),
  49. readSuperMethodsCalled(s));
  50. if (ResolvedTypeMunger.persistSourceLocation) munger.setSourceLocation(readSourceLocation(s));
  51. return munger;
  52. }
  53. public ResolvedMember getExplicitConstructor() {
  54. return explicitConstructor;
  55. }
  56. public ResolvedMember getSyntheticConstructor() {
  57. return syntheticConstructor;
  58. }
  59. public void setExplicitConstructor(ResolvedMember explicitConstructor) {
  60. this.explicitConstructor = explicitConstructor;
  61. }
  62. public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedTypeX aspectType) {
  63. ResolvedMember ret = getSyntheticConstructor();
  64. if (ResolvedTypeX.matches(ret, member)) return getSignature();
  65. return super.getMatchingSyntheticMember(member, aspectType);
  66. }
  67. public void check(World world) {
  68. if (getSignature().getDeclaringType().isAspect(world)) {
  69. world.showMessage(IMessage.ERROR,
  70. WeaverMessages.format(WeaverMessages.ITD_CONS_ON_ASPECT),
  71. getSignature().getSourceLocation(), null);
  72. }
  73. }
  74. }