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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280
  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 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. * 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<>();
  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<>(
  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<>(dependent));
  104. }
  105. }
  106. public void checkDuplicates(ReferenceType newRt) {
  107. synchronized (derivativeTypes) {
  108. List<WeakReference<ReferenceType>> forRemoval = new ArrayList<>();
  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 (ResolvedType annotationType : annotationTypes) {
  201. if (annotationType.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 (AnnotationAJ ax : axs) {
  250. if (ax.getTypeSignature().equals(ofType.getSignature())) {
  251. return ax;
  252. }
  253. }
  254. }
  255. if (annotations != null) {
  256. String searchSig = ofType.getSignature();
  257. for (AnnotationAJ annotation : annotations) {
  258. if (annotation.getTypeSignature().equals(searchSig)) {
  259. return annotation;
  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. // 20170927: What is the block of code for? It mentions jls5.5 which isn't on this topic (old version of jls?)
  331. // Some possible references: http://docs.oracle.com/javase/specs/jls/se9/jls9.pdf 5.1.6 (narrowing reference conversion)
  332. // On Java 9 the test GenericsTests.testAfterReturningWithWildcardVar will fail because this code below
  333. // used to find Set and List were the same, but now finds they are not. (so it doesn't put out the unchecked
  334. // conversion message). However the code "List l = (List)someSet;" still compiles on 9 - so is this code bogus?
  335. // ??? needs to be Methods, not just declared methods? JLS 5.5 unclear
  336. ResolvedMember[] a = getDeclaredMethods();
  337. ResolvedMember[] b = other.getDeclaredMethods();
  338. for (ResolvedMember member : a) {
  339. for (ResolvedMember resolvedMember : b) {
  340. if (!resolvedMember.isCompatibleWith(member)) {
  341. return false;
  342. }
  343. }
  344. }
  345. return true;
  346. }
  347. private final boolean isCoerceableFromParameterizedType(ResolvedType other) {
  348. if (!other.isParameterizedType()) {
  349. return false;
  350. }
  351. ResolvedType myRawType = getRawType();
  352. ResolvedType theirRawType = other.getRawType();
  353. if (myRawType == theirRawType
  354. || myRawType.isCoerceableFrom(theirRawType)) {
  355. if (getTypeParameters().length == other.getTypeParameters().length) {
  356. // there's a chance it can be done
  357. ResolvedType[] myTypeParameters = getResolvedTypeParameters();
  358. ResolvedType[] theirTypeParameters = other
  359. .getResolvedTypeParameters();
  360. for (int i = 0; i < myTypeParameters.length; i++) {
  361. if (myTypeParameters[i] != theirTypeParameters[i]) {
  362. // thin ice now... but List<String> may still be
  363. // coerceable from e.g. List<T>
  364. if (myTypeParameters[i].isGenericWildcard()) {
  365. BoundedReferenceType wildcard = (BoundedReferenceType) myTypeParameters[i];
  366. if (!wildcard
  367. .canBeCoercedTo(theirTypeParameters[i])) {
  368. return false;
  369. }
  370. } else if (myTypeParameters[i]
  371. .isTypeVariableReference()) {
  372. TypeVariableReferenceType tvrt = (TypeVariableReferenceType) myTypeParameters[i];
  373. TypeVariable tv = tvrt.getTypeVariable();
  374. tv.resolve(world);
  375. if (!tv.canBeBoundTo(theirTypeParameters[i])) {
  376. return false;
  377. }
  378. } else if (theirTypeParameters[i]
  379. .isTypeVariableReference()) {
  380. TypeVariableReferenceType tvrt = (TypeVariableReferenceType) theirTypeParameters[i];
  381. TypeVariable tv = tvrt.getTypeVariable();
  382. tv.resolve(world);
  383. if (!tv.canBeBoundTo(myTypeParameters[i])) {
  384. return false;
  385. }
  386. } else if (theirTypeParameters[i].isGenericWildcard()) {
  387. BoundedReferenceType wildcard = (BoundedReferenceType) theirTypeParameters[i];
  388. if (!wildcard.canBeCoercedTo(myTypeParameters[i])) {
  389. return false;
  390. }
  391. } else {
  392. return false;
  393. }
  394. }
  395. }
  396. return true;
  397. }
  398. // } else {
  399. // // we do this walk for situations like the following:
  400. // // Base<T>, Sub<S,T> extends Base<S>
  401. // // is Sub<Y,Z> coerceable from Base<X> ???
  402. // for (Iterator i = getDirectSupertypes(); i.hasNext();) {
  403. // ReferenceType parent = (ReferenceType) i.next();
  404. // if (parent.isCoerceableFromParameterizedType(other))
  405. // return true;
  406. // }
  407. }
  408. return false;
  409. }
  410. @Override
  411. public boolean isAssignableFrom(ResolvedType other) {
  412. return isAssignableFrom(other, false);
  413. }
  414. // TODO rewrite this method - it is a terrible mess
  415. // true iff the statement "this = other" would compile.
  416. @Override
  417. public boolean isAssignableFrom(ResolvedType other, boolean allowMissing) {
  418. if (other.isPrimitiveType()) {
  419. if (!world.isInJava5Mode()) {
  420. return false;
  421. }
  422. if (ResolvedType.validBoxing.contains(this.getSignature()
  423. + other.getSignature())) {
  424. return true;
  425. }
  426. }
  427. if (this == other) {
  428. return true;
  429. }
  430. if (this.getSignature().equals("Ljava/lang/Object;")) {
  431. return true;
  432. }
  433. if (!isTypeVariableReference()
  434. && other.getSignature().equals("Ljava/lang/Object;")) {
  435. return false;
  436. }
  437. boolean thisRaw = this.isRawType();
  438. if (thisRaw && other.isParameterizedOrGenericType()) {
  439. return isAssignableFrom(other.getRawType());
  440. }
  441. boolean thisGeneric = this.isGenericType();
  442. if (thisGeneric && other.isParameterizedOrRawType()) {
  443. return isAssignableFrom(other.getGenericType());
  444. }
  445. if (this.isParameterizedType()) {
  446. // look at wildcards...
  447. if (((ReferenceType) this.getRawType()).isAssignableFrom(other)) {
  448. boolean wildcardsAllTheWay = true;
  449. ResolvedType[] myParameters = this.getResolvedTypeParameters();
  450. for (ResolvedType myParameter : myParameters) {
  451. if (!myParameter.isGenericWildcard()) {
  452. wildcardsAllTheWay = false;
  453. } else {
  454. BoundedReferenceType boundedRT = (BoundedReferenceType) myParameter;
  455. if (boundedRT.isExtends() || boundedRT.isSuper()) {
  456. wildcardsAllTheWay = false;
  457. }
  458. }
  459. }
  460. if (wildcardsAllTheWay && !other.isParameterizedType()) {
  461. return true;
  462. }
  463. // we have to match by parameters one at a time
  464. ResolvedType[] theirParameters = other
  465. .getResolvedTypeParameters();
  466. boolean parametersAssignable = true;
  467. if (myParameters.length == theirParameters.length) {
  468. for (int i = 0; i < myParameters.length
  469. && parametersAssignable; i++) {
  470. if (myParameters[i] == theirParameters[i]) {
  471. continue;
  472. }
  473. // dont do this: pr253109
  474. // if
  475. // (myParameters[i].isAssignableFrom(theirParameters[i],
  476. // allowMissing)) {
  477. // continue;
  478. // }
  479. ResolvedType mp = myParameters[i];
  480. ResolvedType tp = theirParameters[i];
  481. if (mp.isParameterizedType()
  482. && tp.isParameterizedType()) {
  483. if (mp.getGenericType().equals(tp.getGenericType())) {
  484. UnresolvedType[] mtps = mp.getTypeParameters();
  485. UnresolvedType[] ttps = tp.getTypeParameters();
  486. for (int ii = 0; ii < mtps.length; ii++) {
  487. if (mtps[ii].isTypeVariableReference()
  488. && ttps[ii]
  489. .isTypeVariableReference()) {
  490. TypeVariable mtv = ((TypeVariableReferenceType) mtps[ii])
  491. .getTypeVariable();
  492. boolean b = mtv
  493. .canBeBoundTo((ResolvedType) ttps[ii]);
  494. if (!b) {// TODO incomplete testing here
  495. // I think
  496. parametersAssignable = false;
  497. break;
  498. }
  499. } else {
  500. parametersAssignable = false;
  501. break;
  502. }
  503. }
  504. continue;
  505. } else {
  506. parametersAssignable = false;
  507. break;
  508. }
  509. }
  510. if (myParameters[i].isTypeVariableReference()
  511. && theirParameters[i].isTypeVariableReference()) {
  512. TypeVariable myTV = ((TypeVariableReferenceType) myParameters[i])
  513. .getTypeVariable();
  514. // TypeVariable theirTV =
  515. // ((TypeVariableReferenceType)
  516. // theirParameters[i]).getTypeVariable();
  517. boolean b = myTV.canBeBoundTo(theirParameters[i]);
  518. if (!b) {// TODO incomplete testing here I think
  519. parametersAssignable = false;
  520. break;
  521. } else {
  522. continue;
  523. }
  524. }
  525. if (!myParameters[i].isGenericWildcard()) {
  526. parametersAssignable = false;
  527. break;
  528. } else {
  529. BoundedReferenceType wildcardType = (BoundedReferenceType) myParameters[i];
  530. if (!wildcardType.alwaysMatches(theirParameters[i])) {
  531. parametersAssignable = false;
  532. break;
  533. }
  534. }
  535. }
  536. } else {
  537. parametersAssignable = false;
  538. }
  539. if (parametersAssignable) {
  540. return true;
  541. }
  542. }
  543. }
  544. // eg this=T other=Ljava/lang/Object;
  545. if (isTypeVariableReference() && !other.isTypeVariableReference()) {
  546. TypeVariable aVar = ((TypeVariableReference) this)
  547. .getTypeVariable();
  548. return aVar.resolve(world).canBeBoundTo(other);
  549. }
  550. if (other.isTypeVariableReference()) {
  551. TypeVariableReferenceType otherType = (TypeVariableReferenceType) other;
  552. if (this instanceof TypeVariableReference) {
  553. return ((TypeVariableReference) this)
  554. .getTypeVariable()
  555. .resolve(world)
  556. .canBeBoundTo(
  557. otherType.getTypeVariable().getFirstBound()
  558. .resolve(world));// pr171952
  559. // return
  560. // ((TypeVariableReference)this).getTypeVariable()==otherType
  561. // .getTypeVariable();
  562. } else {
  563. // FIXME asc should this say canBeBoundTo??
  564. return this.isAssignableFrom(otherType.getTypeVariable()
  565. .getFirstBound().resolve(world));
  566. }
  567. }
  568. if (allowMissing && other.isMissing()) {
  569. return false;
  570. }
  571. ResolvedType[] interfaces = other.getDeclaredInterfaces();
  572. for (ResolvedType intface : interfaces) {
  573. boolean b;
  574. if (thisRaw && intface.isParameterizedOrGenericType()) {
  575. b = this.isAssignableFrom(intface.getRawType(), allowMissing);
  576. } else {
  577. b = this.isAssignableFrom(intface, allowMissing);
  578. }
  579. if (b) {
  580. return true;
  581. }
  582. }
  583. ResolvedType superclass = other.getSuperclass();
  584. if (superclass != null) {
  585. boolean b;
  586. if (thisRaw && superclass.isParameterizedOrGenericType()) {
  587. b = this.isAssignableFrom(superclass.getRawType(), allowMissing);
  588. } else {
  589. b = this.isAssignableFrom(superclass, allowMissing);
  590. }
  591. if (b) {
  592. return true;
  593. }
  594. }
  595. return false;
  596. }
  597. @Override
  598. public ISourceContext getSourceContext() {
  599. return getDelegate().getSourceContext();
  600. }
  601. @Override
  602. public ISourceLocation getSourceLocation() {
  603. ISourceContext isc = getDelegate().getSourceContext();
  604. return isc.makeSourceLocation(new Position(startPos, endPos));
  605. }
  606. @Override
  607. public boolean isExposedToWeaver() {
  608. return (getDelegate() == null) || delegate.isExposedToWeaver();
  609. }
  610. @Override
  611. public WeaverStateInfo getWeaverState() {
  612. return getDelegate().getWeaverState();
  613. }
  614. @Override
  615. public ResolvedMember[] getDeclaredFields() {
  616. if (parameterizedFields != null) {
  617. return parameterizedFields;
  618. }
  619. if (isParameterizedType() || isRawType()) {
  620. ResolvedMember[] delegateFields = getDelegate().getDeclaredFields();
  621. parameterizedFields = new ResolvedMember[delegateFields.length];
  622. for (int i = 0; i < delegateFields.length; i++) {
  623. parameterizedFields[i] = delegateFields[i].parameterizedWith(
  624. getTypesForMemberParameterization(), this,
  625. isParameterizedType());
  626. }
  627. return parameterizedFields;
  628. } else {
  629. return getDelegate().getDeclaredFields();
  630. }
  631. }
  632. /**
  633. * Find out from the generic signature the true signature of any interfaces
  634. * I implement. If I am parameterized, these may then need to be
  635. * parameterized before returning.
  636. */
  637. @Override
  638. public ResolvedType[] getDeclaredInterfaces() {
  639. ResolvedType[] interfaces = parameterizedInterfaces.get();
  640. if (interfaces != null) {
  641. return interfaces;
  642. }
  643. ResolvedType[] delegateInterfaces = getDelegate()
  644. .getDeclaredInterfaces();
  645. if (isRawType()) {
  646. if (newInterfaces != null) {// debug 375777
  647. throw new IllegalStateException(
  648. "The raw type should never be accumulating new interfaces, they should be on the generic type. Type is "
  649. + this.getName());
  650. }
  651. ResolvedType[] newInterfacesFromGenericType = genericType.newInterfaces;
  652. if (newInterfacesFromGenericType != null) {
  653. ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length
  654. + newInterfacesFromGenericType.length];
  655. System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0,
  656. delegateInterfaces.length);
  657. System.arraycopy(newInterfacesFromGenericType, 0,
  658. extraInterfaces, delegateInterfaces.length,
  659. newInterfacesFromGenericType.length);
  660. delegateInterfaces = extraInterfaces;
  661. }
  662. } else if (newInterfaces != null) {
  663. // OPTIMIZE does this part of the method trigger often?
  664. ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length
  665. + newInterfaces.length];
  666. System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0,
  667. delegateInterfaces.length);
  668. System.arraycopy(newInterfaces, 0, extraInterfaces,
  669. delegateInterfaces.length, newInterfaces.length);
  670. delegateInterfaces = extraInterfaces;
  671. }
  672. if (isParameterizedType()) {
  673. // UnresolvedType[] paramTypes =
  674. // getTypesForMemberParameterization();
  675. interfaces = new ResolvedType[delegateInterfaces.length];
  676. for (int i = 0; i < delegateInterfaces.length; i++) {
  677. // We may have to sub/super set the set of parametertypes if the
  678. // implemented interface
  679. // needs more or less than this type does. (pr124803/pr125080)
  680. if (delegateInterfaces[i].isParameterizedType()) {
  681. interfaces[i] = delegateInterfaces[i].parameterize(
  682. getMemberParameterizationMap()).resolve(world);
  683. } else {
  684. interfaces[i] = delegateInterfaces[i];
  685. }
  686. }
  687. parameterizedInterfaces = new WeakReference<>(
  688. interfaces);
  689. return interfaces;
  690. } else if (isRawType()) {
  691. UnresolvedType[] paramTypes = getTypesForMemberParameterization();
  692. interfaces = new ResolvedType[delegateInterfaces.length];
  693. for (int i = 0, max = interfaces.length; i < max; i++) {
  694. interfaces[i] = delegateInterfaces[i];
  695. if (interfaces[i].isGenericType()) {
  696. // a generic supertype of a raw type is replaced by its raw
  697. // equivalent
  698. interfaces[i] = interfaces[i].getRawType().resolve(
  699. getWorld());
  700. } else if (interfaces[i].isParameterizedType()) {
  701. // a parameterized supertype collapses any type vars to
  702. // their upper bounds
  703. UnresolvedType[] toUseForParameterization = determineThoseTypesToUse(
  704. interfaces[i], paramTypes);
  705. interfaces[i] = interfaces[i]
  706. .parameterizedWith(toUseForParameterization);
  707. }
  708. }
  709. parameterizedInterfaces = new WeakReference<>(
  710. interfaces);
  711. return interfaces;
  712. }
  713. if (getDelegate().isCacheable()) {
  714. parameterizedInterfaces = new WeakReference<>(
  715. delegateInterfaces);
  716. }
  717. return delegateInterfaces;
  718. }
  719. /**
  720. * It is possible this type has multiple type variables but the interface we
  721. * are about to parameterize only uses a subset - this method determines the
  722. * subset to use by looking at the type variable names used. For example:
  723. * <code>
  724. * class Foo<T extends String,E extends Number> implements SuperInterface<T> {}
  725. * </code> where <code>
  726. * interface SuperInterface<Z> {}
  727. * </code> In that example, a use of the 'Foo' raw type should know that it
  728. * implements the SuperInterface<String>.
  729. */
  730. private UnresolvedType[] determineThoseTypesToUse(
  731. ResolvedType parameterizedInterface, UnresolvedType[] paramTypes) {
  732. // What are the type parameters for the supertype?
  733. UnresolvedType[] tParms = parameterizedInterface.getTypeParameters();
  734. UnresolvedType[] retVal = new UnresolvedType[tParms.length];
  735. // Go through the supertypes type parameters, if any of them is a type
  736. // variable, use the
  737. // real type variable on the declaring type.
  738. // it is possibly overkill to look up the type variable - ideally the
  739. // entry in the type parameter list for the
  740. // interface should be the a ref to the type variable in the current
  741. // type ... but I'm not 100% confident right now.
  742. for (int i = 0; i < tParms.length; i++) {
  743. UnresolvedType tParm = tParms[i];
  744. if (tParm.isTypeVariableReference()) {
  745. TypeVariableReference tvrt = (TypeVariableReference) tParm;
  746. TypeVariable tv = tvrt.getTypeVariable();
  747. int rank = getRank(tv.getName());
  748. // -1 probably means it is a reference to a type variable on the
  749. // outer generic type (see pr129566)
  750. if (rank != -1) {
  751. retVal[i] = paramTypes[rank];
  752. } else {
  753. retVal[i] = tParms[i];
  754. }
  755. } else {
  756. retVal[i] = tParms[i];
  757. }
  758. }
  759. return retVal;
  760. }
  761. /**
  762. * Returns the position within the set of type variables for this type for
  763. * the specified type variable name. Returns -1 if there is no type variable
  764. * with the specified name.
  765. */
  766. private int getRank(String tvname) {
  767. TypeVariable[] thisTypesTVars = getGenericType().getTypeVariables();
  768. for (int i = 0; i < thisTypesTVars.length; i++) {
  769. TypeVariable tv = thisTypesTVars[i];
  770. if (tv.getName().equals(tvname)) {
  771. return i;
  772. }
  773. }
  774. return -1;
  775. }
  776. @Override
  777. public ResolvedMember[] getDeclaredMethods() {
  778. if (parameterizedMethods != null) {
  779. return parameterizedMethods;
  780. }
  781. if (isParameterizedType() || isRawType()) {
  782. ResolvedMember[] delegateMethods = getDelegate()
  783. .getDeclaredMethods();
  784. UnresolvedType[] parameters = getTypesForMemberParameterization();
  785. parameterizedMethods = new ResolvedMember[delegateMethods.length];
  786. for (int i = 0; i < delegateMethods.length; i++) {
  787. parameterizedMethods[i] = delegateMethods[i].parameterizedWith(
  788. parameters, this, isParameterizedType());
  789. }
  790. return parameterizedMethods;
  791. } else {
  792. return getDelegate().getDeclaredMethods();
  793. }
  794. }
  795. @Override
  796. public ResolvedMember[] getDeclaredPointcuts() {
  797. if (parameterizedPointcuts != null) {
  798. return parameterizedPointcuts;
  799. }
  800. if (isParameterizedType()) {
  801. ResolvedMember[] delegatePointcuts = getDelegate()
  802. .getDeclaredPointcuts();
  803. parameterizedPointcuts = new ResolvedMember[delegatePointcuts.length];
  804. for (int i = 0; i < delegatePointcuts.length; i++) {
  805. parameterizedPointcuts[i] = delegatePointcuts[i]
  806. .parameterizedWith(getTypesForMemberParameterization(),
  807. this, isParameterizedType());
  808. }
  809. return parameterizedPointcuts;
  810. } else {
  811. return getDelegate().getDeclaredPointcuts();
  812. }
  813. }
  814. private UnresolvedType[] getTypesForMemberParameterization() {
  815. UnresolvedType[] parameters = null;
  816. if (isParameterizedType()) {
  817. parameters = getTypeParameters();
  818. } else if (isRawType()) {
  819. // raw type, use upper bounds of type variables on generic type
  820. TypeVariable[] tvs = getGenericType().getTypeVariables();
  821. parameters = new UnresolvedType[tvs.length];
  822. for (int i = 0; i < tvs.length; i++) {
  823. parameters[i] = tvs[i].getFirstBound();
  824. }
  825. }
  826. return parameters;
  827. }
  828. @Override
  829. public TypeVariable[] getTypeVariables() {
  830. if (typeVariables == null) {
  831. typeVariables = getDelegate().getTypeVariables();
  832. for (TypeVariable typeVariable : this.typeVariables) {
  833. typeVariable.resolve(world);
  834. }
  835. }
  836. return typeVariables;
  837. }
  838. @Override
  839. public PerClause getPerClause() {
  840. PerClause pclause = getDelegate().getPerClause();
  841. if (pclause != null && isParameterizedType()) { // could cache the
  842. // result here...
  843. Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap();
  844. pclause = (PerClause) pclause.parameterizeWith(parameterizationMap,
  845. world);
  846. }
  847. return pclause;
  848. }
  849. @Override
  850. public Collection<Declare> getDeclares() {
  851. if (parameterizedDeclares != null) {
  852. return parameterizedDeclares;
  853. }
  854. Collection<Declare> declares = null;
  855. if (ajMembersNeedParameterization()) {
  856. Collection<Declare> genericDeclares = getDelegate().getDeclares();
  857. parameterizedDeclares = new ArrayList<>();
  858. Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap();
  859. for (Declare declareStatement : genericDeclares) {
  860. parameterizedDeclares.add(declareStatement.parameterizeWith(
  861. parameterizationMap, world));
  862. }
  863. declares = parameterizedDeclares;
  864. } else {
  865. declares = getDelegate().getDeclares();
  866. }
  867. for (Declare d : declares) {
  868. d.setDeclaringType(this);
  869. }
  870. return declares;
  871. }
  872. @Override
  873. public Collection<ConcreteTypeMunger> getTypeMungers() {
  874. return getDelegate().getTypeMungers();
  875. }
  876. @Override
  877. public Collection<ResolvedMember> getPrivilegedAccesses() {
  878. return getDelegate().getPrivilegedAccesses();
  879. }
  880. @Override
  881. public int getModifiers() {
  882. return getDelegate().getModifiers();
  883. }
  884. WeakReference<ResolvedType> superclassReference = new WeakReference<>(
  885. null);
  886. @Override
  887. public ResolvedType getSuperclass() {
  888. ResolvedType ret = null;// superclassReference.get();
  889. // if (ret != null) {
  890. // return ret;
  891. // }
  892. if (newSuperclass != null) {
  893. if (this.isParameterizedType()
  894. && newSuperclass.isParameterizedType()) {
  895. return newSuperclass.parameterize(
  896. getMemberParameterizationMap()).resolve(getWorld());
  897. }
  898. if (getDelegate().isCacheable()) {
  899. superclassReference = new WeakReference<>(ret);
  900. }
  901. return newSuperclass;
  902. }
  903. try {
  904. world.setTypeVariableLookupScope(this);
  905. ret = getDelegate().getSuperclass();
  906. } finally {
  907. world.setTypeVariableLookupScope(null);
  908. }
  909. if (this.isParameterizedType() && ret.isParameterizedType()) {
  910. ret = ret.parameterize(getMemberParameterizationMap()).resolve(
  911. getWorld());
  912. }
  913. if (getDelegate().isCacheable()) {
  914. superclassReference = new WeakReference<>(ret);
  915. }
  916. return ret;
  917. }
  918. public ReferenceTypeDelegate getDelegate() {
  919. return delegate;
  920. }
  921. public void setDelegate(ReferenceTypeDelegate delegate) {
  922. // Don't copy from BcelObjectType to EclipseSourceType - the context may
  923. // be tidied (result null'd) after previous weaving
  924. if (this.delegate != null
  925. && this.delegate.copySourceContext()
  926. && this.delegate.getSourceContext() != SourceContextImpl.UNKNOWN_SOURCE_CONTEXT) {
  927. ((AbstractReferenceTypeDelegate) delegate)
  928. .setSourceContext(this.delegate.getSourceContext());
  929. }
  930. this.delegate = delegate;
  931. synchronized (derivativeTypes) {
  932. List<WeakReference<ReferenceType>> forRemoval = new ArrayList<>();
  933. for (WeakReference<ReferenceType> derivativeRef : derivativeTypes) {
  934. ReferenceType derivative = derivativeRef.get();
  935. if (derivative != null) {
  936. derivative.setDelegate(delegate);
  937. } else {
  938. forRemoval.add(derivativeRef);
  939. }
  940. }
  941. derivativeTypes.removeAll(forRemoval);
  942. }
  943. // If we are raw, we have a generic type - we should ensure it uses the
  944. // same delegate
  945. if (isRawType() && getGenericType() != null) {
  946. ReferenceType genType = getGenericType();
  947. if (genType.getDelegate() != delegate) { // avoids circular updates
  948. genType.setDelegate(delegate);
  949. }
  950. }
  951. clearParameterizationCaches();
  952. ensureConsistent();
  953. }
  954. private void clearParameterizationCaches() {
  955. parameterizedFields = null;
  956. parameterizedInterfaces.clear();
  957. parameterizedMethods = null;
  958. parameterizedPointcuts = null;
  959. superclassReference = new WeakReference<>(null);
  960. }
  961. public int getEndPos() {
  962. return endPos;
  963. }
  964. public int getStartPos() {
  965. return startPos;
  966. }
  967. public void setEndPos(int endPos) {
  968. this.endPos = endPos;
  969. }
  970. public void setStartPos(int startPos) {
  971. this.startPos = startPos;
  972. }
  973. @Override
  974. public boolean doesNotExposeShadowMungers() {
  975. return getDelegate().doesNotExposeShadowMungers();
  976. }
  977. public String getDeclaredGenericSignature() {
  978. return getDelegate().getDeclaredGenericSignature();
  979. }
  980. public void setGenericType(ReferenceType rt) {
  981. genericType = rt;
  982. // Should we 'promote' this reference type from simple to raw?
  983. // makes sense if someone is specifying that it has a generic form
  984. if (typeKind == TypeKind.SIMPLE) {
  985. typeKind = TypeKind.RAW;
  986. signatureErasure = signature;
  987. if (newInterfaces != null) { // debug 375777
  988. throw new IllegalStateException(
  989. "Simple type promoted to raw, but simple type had new interfaces/superclass. Type is "
  990. + this.getName());
  991. }
  992. }
  993. if (typeKind == TypeKind.RAW) {
  994. genericType.addDependentType(this);
  995. }
  996. if (isRawType()) {
  997. genericType.rawType = this;
  998. }
  999. if (this.isRawType() && rt.isRawType()) {
  1000. new RuntimeException(
  1001. "PR341926 diagnostics: Incorrect setup for a generic type, raw type should not point to raw: "
  1002. + this.getName()).printStackTrace();
  1003. }
  1004. }
  1005. public void demoteToSimpleType() {
  1006. genericType = null;
  1007. typeKind = TypeKind.SIMPLE;
  1008. signatureErasure = null;
  1009. }
  1010. @Override
  1011. public ReferenceType getGenericType() {
  1012. if (isGenericType()) {
  1013. return this;
  1014. }
  1015. return genericType;
  1016. }
  1017. /**
  1018. * a parameterized signature starts with a "P" in place of the "L", see the
  1019. * comment on signatures in UnresolvedType.
  1020. *
  1021. * @param aGenericType
  1022. * @param someParameters
  1023. * @return
  1024. */
  1025. private static String makeParameterizedSignature(ResolvedType aGenericType,
  1026. ResolvedType[] someParameters) {
  1027. String rawSignature = aGenericType.getErasureSignature();
  1028. StringBuilder ret = new StringBuilder();
  1029. ret.append(PARAMETERIZED_TYPE_IDENTIFIER);
  1030. ret.append(rawSignature.substring(1, rawSignature.length() - 1));
  1031. ret.append("<");
  1032. for (ResolvedType someParameter : someParameters) {
  1033. ret.append(someParameter.getSignature());
  1034. }
  1035. ret.append(">;");
  1036. return ret.toString();
  1037. }
  1038. private static String makeDeclaredSignature(ResolvedType aGenericType,
  1039. UnresolvedType[] someParameters) {
  1040. StringBuilder ret = new StringBuilder();
  1041. String rawSig = aGenericType.getErasureSignature();
  1042. ret.append(rawSig.substring(0, rawSig.length() - 1));
  1043. ret.append("<");
  1044. for (UnresolvedType someParameter : someParameters) {
  1045. if (someParameter instanceof ReferenceType) {
  1046. ret.append(((ReferenceType) someParameter)
  1047. .getSignatureForAttribute());
  1048. } else if (someParameter instanceof Primitive) {
  1049. ret.append(((Primitive) someParameter)
  1050. .getSignatureForAttribute());
  1051. } else {
  1052. throw new IllegalStateException(
  1053. "DebugFor325731: expected a ReferenceType or Primitive but was "
  1054. + someParameter + " of type "
  1055. + someParameter.getClass().getName());
  1056. }
  1057. }
  1058. ret.append(">;");
  1059. return ret.toString();
  1060. }
  1061. @Override
  1062. public void ensureConsistent() {
  1063. annotations = null;
  1064. annotationTypes = null;
  1065. newSuperclass = null;
  1066. bits = 0; // clears the hierarchy complete tag (amongst other things)
  1067. newInterfaces = null;
  1068. typeVariables = null;
  1069. parameterizedInterfaces.clear();
  1070. superclassReference = new WeakReference<>(null);
  1071. if (getDelegate() != null) {
  1072. delegate.ensureConsistent();
  1073. }
  1074. if (isParameterizedOrRawType()) {
  1075. ReferenceType genericType = getGenericType();
  1076. if (genericType != null) {
  1077. genericType.ensureConsistent();
  1078. }
  1079. }
  1080. }
  1081. @Override
  1082. public void addParent(ResolvedType newParent) {
  1083. if (this.isRawType()) {
  1084. throw new IllegalStateException(
  1085. "The raw type should never be accumulating new interfaces, they should be on the generic type. Type is "
  1086. + this.getName());
  1087. }
  1088. if (newParent.isClass()) {
  1089. newSuperclass = newParent;
  1090. superclassReference = new WeakReference<>(null);
  1091. } else {
  1092. if (newInterfaces == null) {
  1093. newInterfaces = new ResolvedType[1];
  1094. newInterfaces[0] = newParent;
  1095. } else {
  1096. ResolvedType[] existing = getDelegate().getDeclaredInterfaces();
  1097. if (existing != null) {
  1098. for (ResolvedType resolvedType : existing) {
  1099. if (resolvedType.equals(newParent)) {
  1100. return; // already has this interface
  1101. }
  1102. }
  1103. }
  1104. ResolvedType[] newNewInterfaces = new ResolvedType[newInterfaces.length + 1];
  1105. System.arraycopy(newInterfaces, 0, newNewInterfaces, 1,
  1106. newInterfaces.length);
  1107. newNewInterfaces[0] = newParent;
  1108. newInterfaces = newNewInterfaces;
  1109. }
  1110. if (this.isGenericType()) {
  1111. synchronized (derivativeTypes) {
  1112. for (WeakReference<ReferenceType> derivativeTypeRef : derivativeTypes) {
  1113. ReferenceType derivativeType = derivativeTypeRef.get();
  1114. if (derivativeType != null) {
  1115. derivativeType.parameterizedInterfaces.clear();
  1116. }
  1117. }
  1118. }
  1119. }
  1120. parameterizedInterfaces.clear();
  1121. }
  1122. }
  1123. private boolean equal(UnresolvedType[] typeParameters,
  1124. ResolvedType[] resolvedParameters) {
  1125. if (typeParameters.length != resolvedParameters.length) {
  1126. return false;
  1127. }
  1128. int len = typeParameters.length;
  1129. for (int p = 0; p < len; p++) {
  1130. if (!typeParameters[p].equals(resolvedParameters[p])) {
  1131. return false;
  1132. }
  1133. }
  1134. return true;
  1135. }
  1136. /**
  1137. * Look for a derivative type with the specified type parameters. This can
  1138. * avoid creating an unnecessary new (duplicate) with the same information
  1139. * in it. This method also cleans up any reference entries that have been
  1140. * null'd by a GC.
  1141. *
  1142. * @param typeParameters
  1143. * the type parameters to use when searching for the derivative
  1144. * type.
  1145. * @return an existing derivative type or null if there isn't one
  1146. */
  1147. public ReferenceType findDerivativeType(ResolvedType[] typeParameters) {
  1148. synchronized (derivativeTypes) {
  1149. List<WeakReference<ReferenceType>> forRemoval = new ArrayList<>();
  1150. for (WeakReference<ReferenceType> derivativeTypeRef : derivativeTypes) {
  1151. ReferenceType derivativeType = derivativeTypeRef.get();
  1152. if (derivativeType == null) {
  1153. forRemoval.add(derivativeTypeRef);
  1154. } else {
  1155. if (derivativeType.isRawType()) {
  1156. continue;
  1157. }
  1158. if (equal(derivativeType.typeParameters, typeParameters)) {
  1159. return derivativeType; // this escape route wont remove
  1160. // the empty refs
  1161. }
  1162. }
  1163. }
  1164. derivativeTypes.removeAll(forRemoval);
  1165. }
  1166. return null;
  1167. }
  1168. public boolean hasNewInterfaces() {
  1169. return newInterfaces != null;
  1170. }
  1171. }