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.

BcelField.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.bcel;
  13. import java.util.Iterator;
  14. import java.util.List;
  15. import org.aspectj.apache.bcel.classfile.Attribute;
  16. import org.aspectj.apache.bcel.classfile.Field;
  17. import org.aspectj.apache.bcel.classfile.Synthetic;
  18. import org.aspectj.weaver.AjAttribute;
  19. import org.aspectj.weaver.BCException;
  20. import org.aspectj.weaver.ResolvedMember;
  21. import org.aspectj.weaver.TypeX;
  22. import org.aspectj.weaver.World;
  23. final class BcelField extends ResolvedMember {
  24. private Field field;
  25. private boolean isAjSynthetic;
  26. private boolean isSynthetic = false;
  27. BcelField(BcelObjectType declaringType, Field field) {
  28. super(
  29. FIELD,
  30. declaringType.getResolvedTypeX(),
  31. field.getAccessFlags(),
  32. field.getName(),
  33. field.getSignature());
  34. this.field = field;
  35. unpackAttributes(declaringType.getResolvedTypeX().getWorld());
  36. checkedExceptions = TypeX.NONE;
  37. }
  38. // ----
  39. private void unpackAttributes(World world) {
  40. Attribute[] attrs = field.getAttributes();
  41. List as = BcelAttributes.readAjAttributes(attrs, getSourceContext(world));
  42. for (Iterator iter = as.iterator(); iter.hasNext();) {
  43. AjAttribute a = (AjAttribute) iter.next();
  44. if (a instanceof AjAttribute.AjSynthetic) {
  45. isAjSynthetic = true;
  46. } else {
  47. throw new BCException("weird field attribute " + a);
  48. }
  49. }
  50. isAjSynthetic = false;
  51. for (int i = attrs.length - 1; i >= 0; i--) {
  52. if (attrs[i] instanceof Synthetic) isSynthetic = true;
  53. }
  54. }
  55. public boolean isAjSynthetic() {
  56. return isAjSynthetic; // || getName().startsWith(NameMangler.PREFIX);
  57. }
  58. public boolean isSynthetic() {
  59. return isSynthetic;
  60. }
  61. }