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.

ReferenceType.java 39KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. /* *******************************************************************
  2. * Copyright (c) 2002 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. * PARC initial implementation
  11. * Andy Clement - June 2005 - separated out from ResolvedType
  12. * ******************************************************************/
  13. package org.aspectj.weaver;
  14. import java.lang.ref.WeakReference;
  15. import java.util.ArrayList;
  16. import java.util.Collection;
  17. import java.util.List;
  18. import java.util.Map;
  19. import org.aspectj.bridge.ISourceLocation;
  20. import org.aspectj.weaver.World.TypeMap;
  21. import org.aspectj.weaver.patterns.Declare;
  22. import org.aspectj.weaver.patterns.PerClause;
  23. /**
  24. * A reference type represents some 'real' type, not a primitive, not an array -
  25. * but a real type, for example java.util.List. Each ReferenceType has a
  26. * delegate that is the underlying artifact - either an eclipse artifact or a
  27. * bcel artifact. If the type represents a raw type (i.e. there is a generic
  28. * form) then the genericType field is set to point to the generic type. If it
  29. * is for a parameterized type then the generic type is also set to point to the
  30. * generic form.
  31. */
  32. public class ReferenceType extends ResolvedType {
  33. public static final ReferenceType[] EMPTY_ARRAY = new ReferenceType[0];
  34. /**
  35. * For generic types, this list holds references to all the derived raw and
  36. * parameterized versions. We need this so that if the generic delegate is
  37. * swapped during incremental compilation, the delegate of the derivatives
  38. * is swapped also.
  39. */
  40. private final List<WeakReference<ReferenceType>> derivativeTypes = new ArrayList<WeakReference<ReferenceType>>();
  41. /**
  42. * For parameterized types (or the raw type) - this field points to the
  43. * actual reference type from which they are derived.
  44. */
  45. ReferenceType genericType = null;
  46. ReferenceType rawType = null; // generic types have a pointer back to their
  47. // raw variant (prevents GC of the raw from
  48. // the typemap!)
  49. ReferenceTypeDelegate delegate = null;
  50. int startPos = 0;
  51. int endPos = 0;
  52. // cached values for members
  53. ResolvedMember[] parameterizedMethods = null;
  54. ResolvedMember[] parameterizedFields = null;
  55. ResolvedMember[] parameterizedPointcuts = null;
  56. WeakReference<ResolvedType[]> parameterizedInterfaces = new WeakReference<ResolvedType[]>(
  57. null);
  58. Collection<Declare> parameterizedDeclares = null;
  59. // Collection parameterizedTypeMungers = null;
  60. // During matching it can be necessary to temporary mark types as annotated.
  61. // For example
  62. // a declare @type may trigger a separate declare parents to match, and so
  63. // the annotation
  64. // is temporarily held against the referencetype, the annotation will be
  65. // properly
  66. // added to the class during weaving.
  67. private ResolvedType[] annotationTypes = null;
  68. private AnnotationAJ[] annotations = null;
  69. // Similarly these are temporary replacements and additions for the
  70. // superclass and
  71. // superinterfaces
  72. private ResolvedType newSuperclass;
  73. private ResolvedType[] newInterfaces;
  74. public ReferenceType(String signature, World world) {
  75. super(signature, world);
  76. }
  77. public ReferenceType(String signature, String signatureErasure, World world) {
  78. super(signature, signatureErasure, world);
  79. }
  80. public static ReferenceType fromTypeX(UnresolvedType tx, World world) {
  81. ReferenceType rt = new ReferenceType(tx.getErasureSignature(), world);
  82. rt.typeKind = tx.typeKind;
  83. return rt;
  84. }
  85. /**
  86. * Constructor used when creating a parameterized type.
  87. */
  88. public ReferenceType(ResolvedType theGenericType,
  89. ResolvedType[] theParameters, World aWorld) {
  90. super(makeParameterizedSignature(theGenericType, theParameters),
  91. theGenericType.signatureErasure, aWorld);
  92. ReferenceType genericReferenceType = (ReferenceType) theGenericType;
  93. this.typeParameters = theParameters;
  94. this.genericType = genericReferenceType;
  95. this.typeKind = TypeKind.PARAMETERIZED;
  96. this.delegate = genericReferenceType.getDelegate();
  97. genericReferenceType.addDependentType(this);
  98. }
  99. synchronized void addDependentType(ReferenceType dependent) {
  100. // checkDuplicates(dependent);
  101. synchronized (derivativeTypes) {
  102. this.derivativeTypes
  103. .add(new WeakReference<ReferenceType>(dependent));
  104. }
  105. }
  106. public void checkDuplicates(ReferenceType newRt) {
  107. synchronized (derivativeTypes) {
  108. List<WeakReference<ReferenceType>> forRemoval = new ArrayList<WeakReference<ReferenceType>>();
  109. for (WeakReference<ReferenceType> derivativeTypeReference : derivativeTypes) {
  110. ReferenceType derivativeType = derivativeTypeReference.get();
  111. if (derivativeType == null) {
  112. forRemoval.add(derivativeTypeReference);
  113. } else {
  114. if (derivativeType.getTypekind() != newRt.getTypekind()) {
  115. continue; // cannot be this one
  116. }
  117. if (equal2(newRt.getTypeParameters(),
  118. derivativeType.getTypeParameters())) {
  119. if (TypeMap.useExpendableMap) {
  120. throw new IllegalStateException();
  121. }
  122. }
  123. }
  124. }
  125. derivativeTypes.removeAll(forRemoval);
  126. }
  127. }
  128. private boolean equal2(UnresolvedType[] typeParameters,
  129. UnresolvedType[] resolvedParameters) {
  130. if (typeParameters.length != resolvedParameters.length) {
  131. return false;
  132. }
  133. int len = typeParameters.length;
  134. for (int p = 0; p < len; p++) {
  135. if (!typeParameters[p].equals(resolvedParameters[p])) {
  136. return false;
  137. }
  138. }
  139. return true;
  140. }
  141. @Override
  142. public String getSignatureForAttribute() {
  143. if (genericType == null || typeParameters == null) {
  144. return getSignature();
  145. }
  146. return makeDeclaredSignature(genericType, typeParameters);
  147. }
  148. /**
  149. * Create a reference type for a generic type
  150. */
  151. public ReferenceType(UnresolvedType genericType, World world) {
  152. super(genericType.getSignature(), world);
  153. typeKind = TypeKind.GENERIC;
  154. this.typeVariables = genericType.typeVariables;
  155. }
  156. @Override
  157. public boolean isClass() {
  158. return getDelegate().isClass();
  159. }
  160. @Override
  161. public int getCompilerVersion() {
  162. return getDelegate().getCompilerVersion();
  163. }
  164. @Override
  165. public boolean isGenericType() {
  166. return !isParameterizedType() && !isRawType()
  167. && getDelegate().isGeneric();
  168. }
  169. public String getGenericSignature() {
  170. String sig = getDelegate().getDeclaredGenericSignature();
  171. return (sig == null) ? "" : sig;
  172. }
  173. @Override
  174. public AnnotationAJ[] getAnnotations() {
  175. return getDelegate().getAnnotations();
  176. }
  177. @Override
  178. public boolean hasAnnotations() {
  179. return getDelegate().hasAnnotations();
  180. }
  181. @Override
  182. public void addAnnotation(AnnotationAJ annotationX) {
  183. if (annotations == null) {
  184. annotations = new AnnotationAJ[] { annotationX };
  185. } else {
  186. AnnotationAJ[] newAnnotations = new AnnotationAJ[annotations.length + 1];
  187. System.arraycopy(annotations, 0, newAnnotations, 1,
  188. annotations.length);
  189. newAnnotations[0] = annotationX;
  190. annotations = newAnnotations;
  191. }
  192. addAnnotationType(annotationX.getType());
  193. }
  194. public boolean hasAnnotation(UnresolvedType ofType) {
  195. boolean onDelegate = getDelegate().hasAnnotation(ofType);
  196. if (onDelegate) {
  197. return true;
  198. }
  199. if (annotationTypes != null) {
  200. for (int i = 0; i < annotationTypes.length; i++) {
  201. if (annotationTypes[i].equals(ofType)) {
  202. return true;
  203. }
  204. }
  205. }
  206. return false;
  207. }
  208. private void addAnnotationType(ResolvedType ofType) {
  209. if (annotationTypes == null) {
  210. annotationTypes = new ResolvedType[1];
  211. annotationTypes[0] = ofType;
  212. } else {
  213. ResolvedType[] newAnnotationTypes = new ResolvedType[annotationTypes.length + 1];
  214. System.arraycopy(annotationTypes, 0, newAnnotationTypes, 1,
  215. annotationTypes.length);
  216. newAnnotationTypes[0] = ofType;
  217. annotationTypes = newAnnotationTypes;
  218. }
  219. }
  220. @Override
  221. public ResolvedType[] getAnnotationTypes() {
  222. if (getDelegate() == null) {
  223. throw new BCException("Unexpected null delegate for type "
  224. + this.getName());
  225. }
  226. if (annotationTypes == null) {
  227. // there are no extras:
  228. return getDelegate().getAnnotationTypes();
  229. } else {
  230. ResolvedType[] delegateAnnotationTypes = getDelegate()
  231. .getAnnotationTypes();
  232. ResolvedType[] result = new ResolvedType[annotationTypes.length
  233. + delegateAnnotationTypes.length];
  234. System.arraycopy(delegateAnnotationTypes, 0, result, 0,
  235. delegateAnnotationTypes.length);
  236. System.arraycopy(annotationTypes, 0, result,
  237. delegateAnnotationTypes.length, annotationTypes.length);
  238. return result;
  239. }
  240. }
  241. @Override
  242. public String getNameAsIdentifier() {
  243. return getRawName().replace('.', '_');
  244. }
  245. @Override
  246. public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) {
  247. AnnotationAJ[] axs = getDelegate().getAnnotations();
  248. if (axs != null) {
  249. for (int i = 0; i < axs.length; i++) {
  250. if (axs[i].getTypeSignature().equals(ofType.getSignature())) {
  251. return axs[i];
  252. }
  253. }
  254. }
  255. if (annotations != null) {
  256. String searchSig = ofType.getSignature();
  257. for (int i = 0; i < annotations.length; i++) {
  258. if (annotations[i].getTypeSignature().equals(searchSig)) {
  259. return annotations[i];
  260. }
  261. }
  262. }
  263. return null;
  264. }
  265. @Override
  266. public boolean isAspect() {
  267. return getDelegate().isAspect();
  268. }
  269. @Override
  270. public boolean isAnnotationStyleAspect() {
  271. return getDelegate().isAnnotationStyleAspect();
  272. }
  273. @Override
  274. public boolean isEnum() {
  275. return getDelegate().isEnum();
  276. }
  277. @Override
  278. public boolean isAnnotation() {
  279. return getDelegate().isAnnotation();
  280. }
  281. @Override
  282. public boolean isAnonymous() {
  283. return getDelegate().isAnonymous();
  284. }
  285. @Override
  286. public boolean isNested() {
  287. return getDelegate().isNested();
  288. }
  289. public ResolvedType getOuterClass() {
  290. return getDelegate().getOuterClass();
  291. }
  292. public String getRetentionPolicy() {
  293. return getDelegate().getRetentionPolicy();
  294. }
  295. @Override
  296. public boolean isAnnotationWithRuntimeRetention() {
  297. return getDelegate().isAnnotationWithRuntimeRetention();
  298. }
  299. @Override
  300. public boolean canAnnotationTargetType() {
  301. return getDelegate().canAnnotationTargetType();
  302. }
  303. @Override
  304. public AnnotationTargetKind[] getAnnotationTargetKinds() {
  305. return getDelegate().getAnnotationTargetKinds();
  306. }
  307. // true iff the statement "this = (ThisType) other" would compile
  308. @Override
  309. public boolean isCoerceableFrom(ResolvedType o) {
  310. ResolvedType other = o.resolve(world);
  311. if (this.isAssignableFrom(other) || other.isAssignableFrom(this)) {
  312. return true;
  313. }
  314. if (this.isParameterizedType() && other.isParameterizedType()) {
  315. return isCoerceableFromParameterizedType(other);
  316. }
  317. if (this.isParameterizedType() && other.isRawType()) {
  318. return ((ReferenceType) this.getRawType()).isCoerceableFrom(other
  319. .getGenericType());
  320. }
  321. if (this.isRawType() && other.isParameterizedType()) {
  322. return this.getGenericType().isCoerceableFrom((other.getRawType()));
  323. }
  324. if (!this.isInterface() && !other.isInterface()) {
  325. return false;
  326. }
  327. if (this.isFinal() || other.isFinal()) {
  328. return false;
  329. }
  330. // ??? needs to be Methods, not just declared methods? JLS 5.5 unclear
  331. ResolvedMember[] a = getDeclaredMethods();
  332. ResolvedMember[] b = other.getDeclaredMethods(); // ??? is this cast
  333. // always safe
  334. for (int ai = 0, alen = a.length; ai < alen; ai++) {
  335. for (int bi = 0, blen = b.length; bi < blen; bi++) {
  336. if (!b[bi].isCompatibleWith(a[ai])) {
  337. return false;
  338. }
  339. }
  340. }
  341. return true;
  342. }
  343. private final boolean isCoerceableFromParameterizedType(ResolvedType other) {
  344. if (!other.isParameterizedType()) {
  345. return false;
  346. }
  347. ResolvedType myRawType = getRawType();
  348. ResolvedType theirRawType = other.getRawType();
  349. if (myRawType == theirRawType
  350. || myRawType.isCoerceableFrom(theirRawType)) {
  351. if (getTypeParameters().length == other.getTypeParameters().length) {
  352. // there's a chance it can be done
  353. ResolvedType[] myTypeParameters = getResolvedTypeParameters();
  354. ResolvedType[] theirTypeParameters = other
  355. .getResolvedTypeParameters();
  356. for (int i = 0; i < myTypeParameters.length; i++) {
  357. if (myTypeParameters[i] != theirTypeParameters[i]) {
  358. // thin ice now... but List<String> may still be
  359. // coerceable from e.g. List<T>
  360. if (myTypeParameters[i].isGenericWildcard()) {
  361. BoundedReferenceType wildcard = (BoundedReferenceType) myTypeParameters[i];
  362. if (!wildcard
  363. .canBeCoercedTo(theirTypeParameters[i])) {
  364. return false;
  365. }
  366. } else if (myTypeParameters[i]
  367. .isTypeVariableReference()) {
  368. TypeVariableReferenceType tvrt = (TypeVariableReferenceType) myTypeParameters[i];
  369. TypeVariable tv = tvrt.getTypeVariable();
  370. tv.resolve(world);
  371. if (!tv.canBeBoundTo(theirTypeParameters[i])) {
  372. return false;
  373. }
  374. } else if (theirTypeParameters[i]
  375. .isTypeVariableReference()) {
  376. TypeVariableReferenceType tvrt = (TypeVariableReferenceType) theirTypeParameters[i];
  377. TypeVariable tv = tvrt.getTypeVariable();
  378. tv.resolve(world);
  379. if (!tv.canBeBoundTo(myTypeParameters[i])) {
  380. return false;
  381. }
  382. } else if (theirTypeParameters[i].isGenericWildcard()) {
  383. BoundedReferenceType wildcard = (BoundedReferenceType) theirTypeParameters[i];
  384. if (!wildcard.canBeCoercedTo(myTypeParameters[i])) {
  385. return false;
  386. }
  387. } else {
  388. return false;
  389. }
  390. }
  391. }
  392. return true;
  393. }
  394. // } else {
  395. // // we do this walk for situations like the following:
  396. // // Base<T>, Sub<S,T> extends Base<S>
  397. // // is Sub<Y,Z> coerceable from Base<X> ???
  398. // for (Iterator i = getDirectSupertypes(); i.hasNext();) {
  399. // ReferenceType parent = (ReferenceType) i.next();
  400. // if (parent.isCoerceableFromParameterizedType(other))
  401. // return true;
  402. // }
  403. }
  404. return false;
  405. }
  406. @Override
  407. public boolean isAssignableFrom(ResolvedType other) {
  408. return isAssignableFrom(other, false);
  409. }
  410. // TODO rewrite this method - it is a terrible mess
  411. // true iff the statement "this = other" would compile.
  412. @Override
  413. public boolean isAssignableFrom(ResolvedType other, boolean allowMissing) {
  414. if (other.isPrimitiveType()) {
  415. if (!world.isInJava5Mode()) {
  416. return false;
  417. }
  418. if (ResolvedType.validBoxing.contains(this.getSignature()
  419. + other.getSignature())) {
  420. return true;
  421. }
  422. }
  423. if (this == other) {
  424. return true;
  425. }
  426. if (this.getSignature().equals("Ljava/lang/Object;")) {
  427. return true;
  428. }
  429. if (!isTypeVariableReference()
  430. && other.getSignature().equals("Ljava/lang/Object;")) {
  431. return false;
  432. }
  433. boolean thisRaw = this.isRawType();
  434. if (thisRaw && other.isParameterizedOrGenericType()) {
  435. return isAssignableFrom(other.getRawType());
  436. }
  437. boolean thisGeneric = this.isGenericType();
  438. if (thisGeneric && other.isParameterizedOrRawType()) {
  439. return isAssignableFrom(other.getGenericType());
  440. }
  441. if (this.isParameterizedType()) {
  442. // look at wildcards...
  443. if (((ReferenceType) this.getRawType()).isAssignableFrom(other)) {
  444. boolean wildcardsAllTheWay = true;
  445. ResolvedType[] myParameters = this.getResolvedTypeParameters();
  446. for (int i = 0; i < myParameters.length; i++) {
  447. if (!myParameters[i].isGenericWildcard()) {
  448. wildcardsAllTheWay = false;
  449. } else {
  450. BoundedReferenceType boundedRT = (BoundedReferenceType) myParameters[i];
  451. if (boundedRT.isExtends() || boundedRT.isSuper()) {
  452. wildcardsAllTheWay = false;
  453. }
  454. }
  455. }
  456. if (wildcardsAllTheWay && !other.isParameterizedType()) {
  457. return true;
  458. }
  459. // we have to match by parameters one at a time
  460. ResolvedType[] theirParameters = other
  461. .getResolvedTypeParameters();
  462. boolean parametersAssignable = true;
  463. if (myParameters.length == theirParameters.length) {
  464. for (int i = 0; i < myParameters.length
  465. && parametersAssignable; i++) {
  466. if (myParameters[i] == theirParameters[i]) {
  467. continue;
  468. }
  469. // dont do this: pr253109
  470. // if
  471. // (myParameters[i].isAssignableFrom(theirParameters[i],
  472. // allowMissing)) {
  473. // continue;
  474. // }
  475. ResolvedType mp = myParameters[i];
  476. ResolvedType tp = theirParameters[i];
  477. if (mp.isParameterizedType()
  478. && tp.isParameterizedType()) {
  479. if (mp.getGenericType().equals(tp.getGenericType())) {
  480. UnresolvedType[] mtps = mp.getTypeParameters();
  481. UnresolvedType[] ttps = tp.getTypeParameters();
  482. for (int ii = 0; ii < mtps.length; ii++) {
  483. if (mtps[ii].isTypeVariableReference()
  484. && ttps[ii]
  485. .isTypeVariableReference()) {
  486. TypeVariable mtv = ((TypeVariableReferenceType) mtps[ii])
  487. .getTypeVariable();
  488. boolean b = mtv
  489. .canBeBoundTo((ResolvedType) ttps[ii]);
  490. if (!b) {// TODO incomplete testing here
  491. // I think
  492. parametersAssignable = false;
  493. break;
  494. }
  495. } else {
  496. parametersAssignable = false;
  497. break;
  498. }
  499. }
  500. continue;
  501. } else {
  502. parametersAssignable = false;
  503. break;
  504. }
  505. }
  506. if (myParameters[i].isTypeVariableReference()
  507. && theirParameters[i].isTypeVariableReference()) {
  508. TypeVariable myTV = ((TypeVariableReferenceType) myParameters[i])
  509. .getTypeVariable();
  510. // TypeVariable theirTV =
  511. // ((TypeVariableReferenceType)
  512. // theirParameters[i]).getTypeVariable();
  513. boolean b = myTV.canBeBoundTo(theirParameters[i]);
  514. if (!b) {// TODO incomplete testing here I think
  515. parametersAssignable = false;
  516. break;
  517. } else {
  518. continue;
  519. }
  520. }
  521. if (!myParameters[i].isGenericWildcard()) {
  522. parametersAssignable = false;
  523. break;
  524. } else {
  525. BoundedReferenceType wildcardType = (BoundedReferenceType) myParameters[i];
  526. if (!wildcardType.alwaysMatches(theirParameters[i])) {
  527. parametersAssignable = false;
  528. break;
  529. }
  530. }
  531. }
  532. } else {
  533. parametersAssignable = false;
  534. }
  535. if (parametersAssignable) {
  536. return true;
  537. }
  538. }
  539. }
  540. // eg this=T other=Ljava/lang/Object;
  541. if (isTypeVariableReference() && !other.isTypeVariableReference()) {
  542. TypeVariable aVar = ((TypeVariableReference) this)
  543. .getTypeVariable();
  544. return aVar.resolve(world).canBeBoundTo(other);
  545. }
  546. if (other.isTypeVariableReference()) {
  547. TypeVariableReferenceType otherType = (TypeVariableReferenceType) other;
  548. if (this instanceof TypeVariableReference) {
  549. return ((TypeVariableReference) this)
  550. .getTypeVariable()
  551. .resolve(world)
  552. .canBeBoundTo(
  553. otherType.getTypeVariable().getFirstBound()
  554. .resolve(world));// pr171952
  555. // return
  556. // ((TypeVariableReference)this).getTypeVariable()==otherType
  557. // .getTypeVariable();
  558. } else {
  559. // FIXME asc should this say canBeBoundTo??
  560. return this.isAssignableFrom(otherType.getTypeVariable()
  561. .getFirstBound().resolve(world));
  562. }
  563. }
  564. if (allowMissing && other.isMissing()) {
  565. return false;
  566. }
  567. ResolvedType[] interfaces = other.getDeclaredInterfaces();
  568. for (ResolvedType intface : interfaces) {
  569. boolean b;
  570. if (thisRaw && intface.isParameterizedOrGenericType()) {
  571. b = this.isAssignableFrom(intface.getRawType(), allowMissing);
  572. } else {
  573. b = this.isAssignableFrom(intface, allowMissing);
  574. }
  575. if (b) {
  576. return true;
  577. }
  578. }
  579. ResolvedType superclass = other.getSuperclass();
  580. if (superclass != null) {
  581. boolean b;
  582. if (thisRaw && superclass.isParameterizedOrGenericType()) {
  583. b = this.isAssignableFrom(superclass.getRawType(), allowMissing);
  584. } else {
  585. b = this.isAssignableFrom(superclass, allowMissing);
  586. }
  587. if (b) {
  588. return true;
  589. }
  590. }
  591. return false;
  592. }
  593. @Override
  594. public ISourceContext getSourceContext() {
  595. return getDelegate().getSourceContext();
  596. }
  597. @Override
  598. public ISourceLocation getSourceLocation() {
  599. ISourceContext isc = getDelegate().getSourceContext();
  600. return isc.makeSourceLocation(new Position(startPos, endPos));
  601. }
  602. @Override
  603. public boolean isExposedToWeaver() {
  604. return (getDelegate() == null) || delegate.isExposedToWeaver();
  605. }
  606. @Override
  607. public WeaverStateInfo getWeaverState() {
  608. return getDelegate().getWeaverState();
  609. }
  610. @Override
  611. public ResolvedMember[] getDeclaredFields() {
  612. if (parameterizedFields != null) {
  613. return parameterizedFields;
  614. }
  615. if (isParameterizedType() || isRawType()) {
  616. ResolvedMember[] delegateFields = getDelegate().getDeclaredFields();
  617. parameterizedFields = new ResolvedMember[delegateFields.length];
  618. for (int i = 0; i < delegateFields.length; i++) {
  619. parameterizedFields[i] = delegateFields[i].parameterizedWith(
  620. getTypesForMemberParameterization(), this,
  621. isParameterizedType());
  622. }
  623. return parameterizedFields;
  624. } else {
  625. return getDelegate().getDeclaredFields();
  626. }
  627. }
  628. /**
  629. * Find out from the generic signature the true signature of any interfaces
  630. * I implement. If I am parameterized, these may then need to be
  631. * parameterized before returning.
  632. */
  633. @Override
  634. public ResolvedType[] getDeclaredInterfaces() {
  635. ResolvedType[] interfaces = parameterizedInterfaces.get();
  636. if (interfaces != null) {
  637. return interfaces;
  638. }
  639. ResolvedType[] delegateInterfaces = getDelegate()
  640. .getDeclaredInterfaces();
  641. if (isRawType()) {
  642. if (newInterfaces != null) {// debug 375777
  643. throw new IllegalStateException(
  644. "The raw type should never be accumulating new interfaces, they should be on the generic type. Type is "
  645. + this.getName());
  646. }
  647. ResolvedType[] newInterfacesFromGenericType = genericType.newInterfaces;
  648. if (newInterfacesFromGenericType != null) {
  649. ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length
  650. + newInterfacesFromGenericType.length];
  651. System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0,
  652. delegateInterfaces.length);
  653. System.arraycopy(newInterfacesFromGenericType, 0,
  654. extraInterfaces, delegateInterfaces.length,
  655. newInterfacesFromGenericType.length);
  656. delegateInterfaces = extraInterfaces;
  657. }
  658. } else if (newInterfaces != null) {
  659. // OPTIMIZE does this part of the method trigger often?
  660. ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length
  661. + newInterfaces.length];
  662. System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0,
  663. delegateInterfaces.length);
  664. System.arraycopy(newInterfaces, 0, extraInterfaces,
  665. delegateInterfaces.length, newInterfaces.length);
  666. delegateInterfaces = extraInterfaces;
  667. }
  668. if (isParameterizedType()) {
  669. // UnresolvedType[] paramTypes =
  670. // getTypesForMemberParameterization();
  671. interfaces = new ResolvedType[delegateInterfaces.length];
  672. for (int i = 0; i < delegateInterfaces.length; i++) {
  673. // We may have to sub/super set the set of parametertypes if the
  674. // implemented interface
  675. // needs more or less than this type does. (pr124803/pr125080)
  676. if (delegateInterfaces[i].isParameterizedType()) {
  677. interfaces[i] = delegateInterfaces[i].parameterize(
  678. getMemberParameterizationMap()).resolve(world);
  679. } else {
  680. interfaces[i] = delegateInterfaces[i];
  681. }
  682. }
  683. parameterizedInterfaces = new WeakReference<ResolvedType[]>(
  684. interfaces);
  685. return interfaces;
  686. } else if (isRawType()) {
  687. UnresolvedType[] paramTypes = getTypesForMemberParameterization();
  688. interfaces = new ResolvedType[delegateInterfaces.length];
  689. for (int i = 0, max = interfaces.length; i < max; i++) {
  690. interfaces[i] = delegateInterfaces[i];
  691. if (interfaces[i].isGenericType()) {
  692. // a generic supertype of a raw type is replaced by its raw
  693. // equivalent
  694. interfaces[i] = interfaces[i].getRawType().resolve(
  695. getWorld());
  696. } else if (interfaces[i].isParameterizedType()) {
  697. // a parameterized supertype collapses any type vars to
  698. // their upper bounds
  699. UnresolvedType[] toUseForParameterization = determineThoseTypesToUse(
  700. interfaces[i], paramTypes);
  701. interfaces[i] = interfaces[i]
  702. .parameterizedWith(toUseForParameterization);
  703. }
  704. }
  705. parameterizedInterfaces = new WeakReference<ResolvedType[]>(
  706. interfaces);
  707. return interfaces;
  708. }
  709. if (getDelegate().isCacheable()) {
  710. parameterizedInterfaces = new WeakReference<ResolvedType[]>(
  711. delegateInterfaces);
  712. }
  713. return delegateInterfaces;
  714. }
  715. /**
  716. * It is possible this type has multiple type variables but the interface we
  717. * are about to parameterize only uses a subset - this method determines the
  718. * subset to use by looking at the type variable names used. For example:
  719. * <code>
  720. * class Foo<T extends String,E extends Number> implements SuperInterface<T> {}
  721. * </code> where <code>
  722. * interface SuperInterface<Z> {}
  723. * </code> In that example, a use of the 'Foo' raw type should know that it
  724. * implements the SuperInterface<String>.
  725. */
  726. private UnresolvedType[] determineThoseTypesToUse(
  727. ResolvedType parameterizedInterface, UnresolvedType[] paramTypes) {
  728. // What are the type parameters for the supertype?
  729. UnresolvedType[] tParms = parameterizedInterface.getTypeParameters();
  730. UnresolvedType[] retVal = new UnresolvedType[tParms.length];
  731. // Go through the supertypes type parameters, if any of them is a type
  732. // variable, use the
  733. // real type variable on the declaring type.
  734. // it is possibly overkill to look up the type variable - ideally the
  735. // entry in the type parameter list for the
  736. // interface should be the a ref to the type variable in the current
  737. // type ... but I'm not 100% confident right now.
  738. for (int i = 0; i < tParms.length; i++) {
  739. UnresolvedType tParm = tParms[i];
  740. if (tParm.isTypeVariableReference()) {
  741. TypeVariableReference tvrt = (TypeVariableReference) tParm;
  742. TypeVariable tv = tvrt.getTypeVariable();
  743. int rank = getRank(tv.getName());
  744. // -1 probably means it is a reference to a type variable on the
  745. // outer generic type (see pr129566)
  746. if (rank != -1) {
  747. retVal[i] = paramTypes[rank];
  748. } else {
  749. retVal[i] = tParms[i];
  750. }
  751. } else {
  752. retVal[i] = tParms[i];
  753. }
  754. }
  755. return retVal;
  756. }
  757. /**
  758. * Returns the position within the set of type variables for this type for
  759. * the specified type variable name. Returns -1 if there is no type variable
  760. * with the specified name.
  761. */
  762. private int getRank(String tvname) {
  763. TypeVariable[] thisTypesTVars = getGenericType().getTypeVariables();
  764. for (int i = 0; i < thisTypesTVars.length; i++) {
  765. TypeVariable tv = thisTypesTVars[i];
  766. if (tv.getName().equals(tvname)) {
  767. return i;
  768. }
  769. }
  770. return -1;
  771. }
  772. @Override
  773. public ResolvedMember[] getDeclaredMethods() {
  774. if (parameterizedMethods != null) {
  775. return parameterizedMethods;
  776. }
  777. if (isParameterizedType() || isRawType()) {
  778. ResolvedMember[] delegateMethods = getDelegate()
  779. .getDeclaredMethods();
  780. UnresolvedType[] parameters = getTypesForMemberParameterization();
  781. parameterizedMethods = new ResolvedMember[delegateMethods.length];
  782. for (int i = 0; i < delegateMethods.length; i++) {
  783. parameterizedMethods[i] = delegateMethods[i].parameterizedWith(
  784. parameters, this, isParameterizedType());
  785. }
  786. return parameterizedMethods;
  787. } else {
  788. return getDelegate().getDeclaredMethods();
  789. }
  790. }
  791. @Override
  792. public ResolvedMember[] getDeclaredPointcuts() {
  793. if (parameterizedPointcuts != null) {
  794. return parameterizedPointcuts;
  795. }
  796. if (isParameterizedType()) {
  797. ResolvedMember[] delegatePointcuts = getDelegate()
  798. .getDeclaredPointcuts();
  799. parameterizedPointcuts = new ResolvedMember[delegatePointcuts.length];
  800. for (int i = 0; i < delegatePointcuts.length; i++) {
  801. parameterizedPointcuts[i] = delegatePointcuts[i]
  802. .parameterizedWith(getTypesForMemberParameterization(),
  803. this, isParameterizedType());
  804. }
  805. return parameterizedPointcuts;
  806. } else {
  807. return getDelegate().getDeclaredPointcuts();
  808. }
  809. }
  810. private UnresolvedType[] getTypesForMemberParameterization() {
  811. UnresolvedType[] parameters = null;
  812. if (isParameterizedType()) {
  813. parameters = getTypeParameters();
  814. } else if (isRawType()) {
  815. // raw type, use upper bounds of type variables on generic type
  816. TypeVariable[] tvs = getGenericType().getTypeVariables();
  817. parameters = new UnresolvedType[tvs.length];
  818. for (int i = 0; i < tvs.length; i++) {
  819. parameters[i] = tvs[i].getFirstBound();
  820. }
  821. }
  822. return parameters;
  823. }
  824. @Override
  825. public TypeVariable[] getTypeVariables() {
  826. if (typeVariables == null) {
  827. typeVariables = getDelegate().getTypeVariables();
  828. for (int i = 0; i < this.typeVariables.length; i++) {
  829. typeVariables[i].resolve(world);
  830. }
  831. }
  832. return typeVariables;
  833. }
  834. @Override
  835. public PerClause getPerClause() {
  836. PerClause pclause = getDelegate().getPerClause();
  837. if (pclause != null && isParameterizedType()) { // could cache the
  838. // result here...
  839. Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap();
  840. pclause = (PerClause) pclause.parameterizeWith(parameterizationMap,
  841. world);
  842. }
  843. return pclause;
  844. }
  845. @Override
  846. public Collection<Declare> getDeclares() {
  847. if (parameterizedDeclares != null) {
  848. return parameterizedDeclares;
  849. }
  850. Collection<Declare> declares = null;
  851. if (ajMembersNeedParameterization()) {
  852. Collection<Declare> genericDeclares = getDelegate().getDeclares();
  853. parameterizedDeclares = new ArrayList<Declare>();
  854. Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap();
  855. for (Declare declareStatement : genericDeclares) {
  856. parameterizedDeclares.add(declareStatement.parameterizeWith(
  857. parameterizationMap, world));
  858. }
  859. declares = parameterizedDeclares;
  860. } else {
  861. declares = getDelegate().getDeclares();
  862. }
  863. for (Declare d : declares) {
  864. d.setDeclaringType(this);
  865. }
  866. return declares;
  867. }
  868. @Override
  869. public Collection<ConcreteTypeMunger> getTypeMungers() {
  870. return getDelegate().getTypeMungers();
  871. }
  872. @Override
  873. public Collection<ResolvedMember> getPrivilegedAccesses() {
  874. return getDelegate().getPrivilegedAccesses();
  875. }
  876. @Override
  877. public int getModifiers() {
  878. return getDelegate().getModifiers();
  879. }
  880. WeakReference<ResolvedType> superclassReference = new WeakReference<ResolvedType>(
  881. null);
  882. @Override
  883. public ResolvedType getSuperclass() {
  884. ResolvedType ret = null;// superclassReference.get();
  885. // if (ret != null) {
  886. // return ret;
  887. // }
  888. if (newSuperclass != null) {
  889. if (this.isParameterizedType()
  890. && newSuperclass.isParameterizedType()) {
  891. return newSuperclass.parameterize(
  892. getMemberParameterizationMap()).resolve(getWorld());
  893. }
  894. if (getDelegate().isCacheable()) {
  895. superclassReference = new WeakReference<ResolvedType>(ret);
  896. }
  897. return newSuperclass;
  898. }
  899. try {
  900. world.setTypeVariableLookupScope(this);
  901. ret = getDelegate().getSuperclass();
  902. } finally {
  903. world.setTypeVariableLookupScope(null);
  904. }
  905. if (this.isParameterizedType() && ret.isParameterizedType()) {
  906. ret = ret.parameterize(getMemberParameterizationMap()).resolve(
  907. getWorld());
  908. }
  909. if (getDelegate().isCacheable()) {
  910. superclassReference = new WeakReference<ResolvedType>(ret);
  911. }
  912. return ret;
  913. }
  914. public ReferenceTypeDelegate getDelegate() {
  915. return delegate;
  916. }
  917. public void setDelegate(ReferenceTypeDelegate delegate) {
  918. // Don't copy from BcelObjectType to EclipseSourceType - the context may
  919. // be tidied (result null'd) after previous weaving
  920. if (this.delegate != null
  921. && this.delegate.copySourceContext()
  922. && this.delegate.getSourceContext() != SourceContextImpl.UNKNOWN_SOURCE_CONTEXT) {
  923. ((AbstractReferenceTypeDelegate) delegate)
  924. .setSourceContext(this.delegate.getSourceContext());
  925. }
  926. this.delegate = delegate;
  927. synchronized (derivativeTypes) {
  928. List<WeakReference<ReferenceType>> forRemoval = new ArrayList<WeakReference<ReferenceType>>();
  929. for (WeakReference<ReferenceType> derivativeRef : derivativeTypes) {
  930. ReferenceType derivative = derivativeRef.get();
  931. if (derivative != null) {
  932. derivative.setDelegate(delegate);
  933. } else {
  934. forRemoval.add(derivativeRef);
  935. }
  936. }
  937. derivativeTypes.removeAll(forRemoval);
  938. }
  939. // If we are raw, we have a generic type - we should ensure it uses the
  940. // same delegate
  941. if (isRawType() && getGenericType() != null) {
  942. ReferenceType genType = (ReferenceType) getGenericType();
  943. if (genType.getDelegate() != delegate) { // avoids circular updates
  944. genType.setDelegate(delegate);
  945. }
  946. }
  947. clearParameterizationCaches();
  948. ensureConsistent();
  949. }
  950. private void clearParameterizationCaches() {
  951. parameterizedFields = null;
  952. parameterizedInterfaces.clear();
  953. parameterizedMethods = null;
  954. parameterizedPointcuts = null;
  955. superclassReference = new WeakReference<ResolvedType>(null);
  956. }
  957. public int getEndPos() {
  958. return endPos;
  959. }
  960. public int getStartPos() {
  961. return startPos;
  962. }
  963. public void setEndPos(int endPos) {
  964. this.endPos = endPos;
  965. }
  966. public void setStartPos(int startPos) {
  967. this.startPos = startPos;
  968. }
  969. @Override
  970. public boolean doesNotExposeShadowMungers() {
  971. return getDelegate().doesNotExposeShadowMungers();
  972. }
  973. public String getDeclaredGenericSignature() {
  974. return getDelegate().getDeclaredGenericSignature();
  975. }
  976. public void setGenericType(ReferenceType rt) {
  977. genericType = rt;
  978. // Should we 'promote' this reference type from simple to raw?
  979. // makes sense if someone is specifying that it has a generic form
  980. if (typeKind == TypeKind.SIMPLE) {
  981. typeKind = TypeKind.RAW;
  982. signatureErasure = signature;
  983. if (newInterfaces != null) { // debug 375777
  984. throw new IllegalStateException(
  985. "Simple type promoted to raw, but simple type had new interfaces/superclass. Type is "
  986. + this.getName());
  987. }
  988. }
  989. if (typeKind == TypeKind.RAW) {
  990. genericType.addDependentType(this);
  991. }
  992. if (isRawType()) {
  993. genericType.rawType = this;
  994. }
  995. if (this.isRawType() && rt.isRawType()) {
  996. new RuntimeException(
  997. "PR341926 diagnostics: Incorrect setup for a generic type, raw type should not point to raw: "
  998. + this.getName()).printStackTrace();
  999. }
  1000. }
  1001. public void demoteToSimpleType() {
  1002. genericType = null;
  1003. typeKind = TypeKind.SIMPLE;
  1004. signatureErasure = null;
  1005. }
  1006. @Override
  1007. public ReferenceType getGenericType() {
  1008. if (isGenericType()) {
  1009. return this;
  1010. }
  1011. return genericType;
  1012. }
  1013. /**
  1014. * a parameterized signature starts with a "P" in place of the "L", see the
  1015. * comment on signatures in UnresolvedType.
  1016. *
  1017. * @param aGenericType
  1018. * @param someParameters
  1019. * @return
  1020. */
  1021. private static String makeParameterizedSignature(ResolvedType aGenericType,
  1022. ResolvedType[] someParameters) {
  1023. String rawSignature = aGenericType.getErasureSignature();
  1024. StringBuffer ret = new StringBuffer();
  1025. ret.append(PARAMETERIZED_TYPE_IDENTIFIER);
  1026. ret.append(rawSignature.substring(1, rawSignature.length() - 1));
  1027. ret.append("<");
  1028. for (int i = 0; i < someParameters.length; i++) {
  1029. ret.append(someParameters[i].getSignature());
  1030. }
  1031. ret.append(">;");
  1032. return ret.toString();
  1033. }
  1034. private static String makeDeclaredSignature(ResolvedType aGenericType,
  1035. UnresolvedType[] someParameters) {
  1036. StringBuffer ret = new StringBuffer();
  1037. String rawSig = aGenericType.getErasureSignature();
  1038. ret.append(rawSig.substring(0, rawSig.length() - 1));
  1039. ret.append("<");
  1040. for (int i = 0; i < someParameters.length; i++) {
  1041. if (someParameters[i] instanceof ReferenceType) {
  1042. ret.append(((ReferenceType) someParameters[i])
  1043. .getSignatureForAttribute());
  1044. } else if (someParameters[i] instanceof Primitive) {
  1045. ret.append(((Primitive) someParameters[i])
  1046. .getSignatureForAttribute());
  1047. } else {
  1048. throw new IllegalStateException(
  1049. "DebugFor325731: expected a ReferenceType or Primitive but was "
  1050. + someParameters[i] + " of type "
  1051. + someParameters[i].getClass().getName());
  1052. }
  1053. }
  1054. ret.append(">;");
  1055. return ret.toString();
  1056. }
  1057. @Override
  1058. public void ensureConsistent() {
  1059. annotations = null;
  1060. annotationTypes = null;
  1061. newSuperclass = null;
  1062. newInterfaces = null;
  1063. typeVariables = null;
  1064. parameterizedInterfaces.clear();
  1065. superclassReference = new WeakReference<ResolvedType>(null);
  1066. if (getDelegate() != null) {
  1067. delegate.ensureConsistent();
  1068. }
  1069. if (isRawType()) {
  1070. ReferenceType genericType = getGenericType();
  1071. if (genericType != null) {
  1072. genericType.ensureConsistent();
  1073. }
  1074. }
  1075. }
  1076. @Override
  1077. public void addParent(ResolvedType newParent) {
  1078. if (this.isRawType()) {
  1079. throw new IllegalStateException(
  1080. "The raw type should never be accumulating new interfaces, they should be on the generic type. Type is "
  1081. + this.getName());
  1082. }
  1083. if (newParent.isClass()) {
  1084. newSuperclass = newParent;
  1085. superclassReference = new WeakReference<ResolvedType>(null);
  1086. } else {
  1087. if (newInterfaces == null) {
  1088. newInterfaces = new ResolvedType[1];
  1089. newInterfaces[0] = newParent;
  1090. } else {
  1091. ResolvedType[] existing = getDelegate().getDeclaredInterfaces();
  1092. if (existing != null) {
  1093. for (int i = 0; i < existing.length; i++) {
  1094. if (existing[i].equals(newParent)) {
  1095. return; // already has this interface
  1096. }
  1097. }
  1098. }
  1099. ResolvedType[] newNewInterfaces = new ResolvedType[newInterfaces.length + 1];
  1100. System.arraycopy(newInterfaces, 0, newNewInterfaces, 1,
  1101. newInterfaces.length);
  1102. newNewInterfaces[0] = newParent;
  1103. newInterfaces = newNewInterfaces;
  1104. }
  1105. if (this.isGenericType()) {
  1106. synchronized (derivativeTypes) {
  1107. for (WeakReference<ReferenceType> derivativeTypeRef : derivativeTypes) {
  1108. ReferenceType derivativeType = derivativeTypeRef.get();
  1109. if (derivativeType != null) {
  1110. derivativeType.parameterizedInterfaces.clear();
  1111. }
  1112. }
  1113. }
  1114. }
  1115. parameterizedInterfaces.clear();
  1116. }
  1117. }
  1118. private boolean equal(UnresolvedType[] typeParameters,
  1119. ResolvedType[] resolvedParameters) {
  1120. if (typeParameters.length != resolvedParameters.length) {
  1121. return false;
  1122. }
  1123. int len = typeParameters.length;
  1124. for (int p = 0; p < len; p++) {
  1125. if (!typeParameters[p].equals(resolvedParameters[p])) {
  1126. return false;
  1127. }
  1128. }
  1129. return true;
  1130. }
  1131. /**
  1132. * Look for a derivative type with the specified type parameters. This can
  1133. * avoid creating an unnecessary new (duplicate) with the same information
  1134. * in it. This method also cleans up any reference entries that have been
  1135. * null'd by a GC.
  1136. *
  1137. * @param typeParameters
  1138. * the type parameters to use when searching for the derivative
  1139. * type.
  1140. * @return an existing derivative type or null if there isn't one
  1141. */
  1142. public ReferenceType findDerivativeType(ResolvedType[] typeParameters) {
  1143. synchronized (derivativeTypes) {
  1144. List<WeakReference<ReferenceType>> forRemoval = new ArrayList<WeakReference<ReferenceType>>();
  1145. for (WeakReference<ReferenceType> derivativeTypeRef : derivativeTypes) {
  1146. ReferenceType derivativeType = derivativeTypeRef.get();
  1147. if (derivativeType == null) {
  1148. forRemoval.add(derivativeTypeRef);
  1149. } else {
  1150. if (derivativeType.isRawType()) {
  1151. continue;
  1152. }
  1153. if (equal(derivativeType.typeParameters, typeParameters)) {
  1154. return derivativeType; // this escape route wont remove
  1155. // the empty refs
  1156. }
  1157. }
  1158. }
  1159. derivativeTypes.removeAll(forRemoval);
  1160. }
  1161. return null;
  1162. }
  1163. public boolean hasNewInterfaces() {
  1164. return newInterfaces != null;
  1165. }
  1166. }