Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ArrayReferenceType.java 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* *******************************************************************
  2. * Copyright (c) 2008 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * Contributors:
  10. * Andy Clement initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver;
  13. import java.lang.reflect.Modifier;
  14. /**
  15. * Represents a resolved array type
  16. *
  17. * @author Andy Clement
  18. */
  19. public class ArrayReferenceType extends ReferenceType {
  20. private final ResolvedType componentType;
  21. public ArrayReferenceType(String sig, String erasureSig, World world, ResolvedType componentType) {
  22. super(sig, erasureSig, world);
  23. this.componentType = componentType;
  24. }
  25. // These methods are from the original implementation when Array was a ResolvedType and not a ReferenceType
  26. public final ResolvedMember[] getDeclaredFields() {
  27. return ResolvedMember.NONE;
  28. }
  29. public final ResolvedMember[] getDeclaredMethods() {
  30. // ??? should this return clone? Probably not...
  31. // If it ever does, here is the code:
  32. // ResolvedMember cloneMethod =
  33. // new ResolvedMember(Member.METHOD,this,Modifier.PUBLIC,UnresolvedType.OBJECT,"clone",new UnresolvedType[]{});
  34. // return new ResolvedMember[]{cloneMethod};
  35. return ResolvedMember.NONE;
  36. }
  37. public final ResolvedType[] getDeclaredInterfaces() {
  38. return new ResolvedType[] { world.getCoreType(CLONEABLE), world.getCoreType(SERIALIZABLE) };
  39. }
  40. public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) {
  41. return null;
  42. }
  43. public AnnotationAJ[] getAnnotations() {
  44. return AnnotationAJ.EMPTY_ARRAY;
  45. }
  46. public ResolvedType[] getAnnotationTypes() {
  47. return ResolvedType.NONE;
  48. }
  49. public final ResolvedMember[] getDeclaredPointcuts() {
  50. return ResolvedMember.NONE;
  51. }
  52. public boolean hasAnnotation(UnresolvedType ofType) {
  53. return false;
  54. }
  55. public final ResolvedType getSuperclass() {
  56. return world.getCoreType(OBJECT);
  57. }
  58. public final boolean isAssignableFrom(ResolvedType o) {
  59. if (!o.isArray())
  60. return false;
  61. if (o.getComponentType().isPrimitiveType()) {
  62. return o.equals(this);
  63. } else {
  64. return getComponentType().resolve(world).isAssignableFrom(o.getComponentType().resolve(world));
  65. }
  66. }
  67. public boolean isAssignableFrom(ResolvedType o, boolean allowMissing) {
  68. return isAssignableFrom(o);
  69. }
  70. public final boolean isCoerceableFrom(ResolvedType o) {
  71. if (o.equals(UnresolvedType.OBJECT) || o.equals(UnresolvedType.SERIALIZABLE) || o.equals(UnresolvedType.CLONEABLE)) {
  72. return true;
  73. }
  74. if (!o.isArray())
  75. return false;
  76. if (o.getComponentType().isPrimitiveType()) {
  77. return o.equals(this);
  78. } else {
  79. return getComponentType().resolve(world).isCoerceableFrom(o.getComponentType().resolve(world));
  80. }
  81. }
  82. public final int getModifiers() {
  83. int mask = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED;
  84. return (componentType.getModifiers() & mask) | Modifier.FINAL;
  85. }
  86. public UnresolvedType getComponentType() {
  87. return componentType;
  88. }
  89. public ResolvedType getResolvedComponentType() {
  90. return componentType;
  91. }
  92. public ISourceContext getSourceContext() {
  93. return getResolvedComponentType().getSourceContext();
  94. }
  95. // Methods overridden from ReferenceType follow
  96. public TypeVariable[] getTypeVariables() {
  97. if (this.typeVariables == null && componentType.getTypeVariables() != null) {
  98. this.typeVariables = componentType.getTypeVariables();
  99. for (TypeVariable typeVariable : this.typeVariables) {
  100. typeVariable.resolve(world);
  101. }
  102. }
  103. return this.typeVariables;
  104. }
  105. public boolean isAnnotation() {
  106. return false;
  107. }
  108. public boolean isAnonymous() {
  109. return false;
  110. }
  111. public boolean isAnnotationStyleAspect() {
  112. return false;
  113. }
  114. public boolean isAspect() {
  115. return false;
  116. }
  117. public boolean isPrimitiveType() {
  118. return typeKind == TypeKind.PRIMITIVE;
  119. }
  120. public boolean isSimpleType() {
  121. return typeKind == TypeKind.SIMPLE;
  122. }
  123. public boolean isRawType() {
  124. return typeKind == TypeKind.RAW;
  125. }
  126. public boolean isGenericType() {
  127. return typeKind == TypeKind.GENERIC;
  128. }
  129. public boolean isParameterizedType() {
  130. return typeKind == TypeKind.PARAMETERIZED;
  131. }
  132. public boolean isTypeVariableReference() {
  133. return typeKind == TypeKind.TYPE_VARIABLE;
  134. }
  135. public boolean isGenericWildcard() {
  136. return typeKind == TypeKind.WILDCARD;
  137. }
  138. public boolean isEnum() {
  139. return false;
  140. }
  141. public boolean isNested() {
  142. return false;
  143. }
  144. public boolean isClass() {
  145. return false;
  146. }
  147. @Override
  148. public boolean isExposedToWeaver() {
  149. return false;
  150. }
  151. public boolean canAnnotationTargetType() {
  152. return false;
  153. }
  154. public AnnotationTargetKind[] getAnnotationTargetKinds() {
  155. return null;
  156. }
  157. public boolean isAnnotationWithRuntimeRetention() {
  158. return false;
  159. }
  160. public boolean isPrimitiveArray() {
  161. if (componentType.isPrimitiveType()) {
  162. return true;
  163. } else if (componentType.isArray()) {
  164. return componentType.isPrimitiveArray();
  165. } else {
  166. return false;
  167. }
  168. }
  169. }