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.

World.java 45KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * 2005 Contributors
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * PARC initial implementation
  12. * Adrian Colyer, Andy Clement, overhaul for generics
  13. * ******************************************************************/
  14. package org.aspectj.weaver;
  15. import java.lang.ref.ReferenceQueue;
  16. import java.lang.ref.SoftReference;
  17. import java.lang.ref.WeakReference;
  18. import java.util.ArrayList;
  19. import java.util.HashMap;
  20. import java.util.Iterator;
  21. import java.util.List;
  22. import java.util.Map;
  23. import java.util.Properties;
  24. import java.util.WeakHashMap;
  25. import org.aspectj.asm.IHierarchy;
  26. import org.aspectj.bridge.IMessageHandler;
  27. import org.aspectj.bridge.ISourceLocation;
  28. import org.aspectj.bridge.Message;
  29. import org.aspectj.bridge.MessageUtil;
  30. import org.aspectj.bridge.IMessage.Kind;
  31. import org.aspectj.bridge.context.PinpointingMessageHandler;
  32. import org.aspectj.weaver.UnresolvedType.TypeKind;
  33. import org.aspectj.weaver.bcel.BcelObjectType;
  34. import org.aspectj.weaver.patterns.DeclarePrecedence;
  35. import org.aspectj.weaver.patterns.PerClause;
  36. import org.aspectj.weaver.patterns.Pointcut;
  37. import org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegate;
  38. import org.aspectj.weaver.tools.Trace;
  39. import org.aspectj.weaver.tools.TraceFactory;
  40. /**
  41. * A World is a collection of known types and crosscutting members.
  42. */
  43. public abstract class World implements Dump.INode {
  44. /** handler for any messages produced during resolution etc. */
  45. private IMessageHandler messageHandler = IMessageHandler.SYSTEM_ERR;
  46. /** handler for cross-reference information produced during the weaving process */
  47. private ICrossReferenceHandler xrefHandler = null;
  48. /** Currently 'active' scope in which to lookup (resolve) typevariable references */
  49. private TypeVariableDeclaringElement typeVariableLookupScope;
  50. /** The heart of the world, a map from type signatures to resolved types */
  51. protected TypeMap typeMap = new TypeMap(this); // Signature to ResolvedType
  52. // see pr145963
  53. /** Should we create the hierarchy for binary classes and aspects*/
  54. public static boolean createInjarHierarchy = true;
  55. /** Calculator for working out aspect precedence */
  56. private AspectPrecedenceCalculator precedenceCalculator;
  57. /** All of the type and shadow mungers known to us */
  58. private CrosscuttingMembersSet crosscuttingMembersSet =
  59. new CrosscuttingMembersSet(this);
  60. /** Model holds ASM relationships */
  61. private IHierarchy model = null;
  62. /** for processing Xlint messages */
  63. private Lint lint = new Lint(this);
  64. /** XnoInline option setting passed down to weaver */
  65. private boolean XnoInline;
  66. /** XlazyTjp option setting passed down to weaver */
  67. private boolean XlazyTjp;
  68. /** XhasMember option setting passed down to weaver */
  69. private boolean XhasMember = false;
  70. /** Xpinpoint controls whether we put out developer info showing the source of messages */
  71. private boolean Xpinpoint = false;
  72. /** When behaving in a Java 5 way autoboxing is considered */
  73. private boolean behaveInJava5Way = false;
  74. /** Determines if this world could be used for multiple compiles */
  75. private boolean incrementalCompileCouldFollow = false;
  76. /** The level of the aspectjrt.jar the code we generate needs to run on */
  77. private String targetAspectjRuntimeLevel = Constants.RUNTIME_LEVEL_DEFAULT;
  78. /** Flags for the new joinpoints that are 'optional' */
  79. private boolean optionalJoinpoint_ArrayConstruction = false; // Command line flag: "-Xjoinpoints:arrayconstruction"
  80. private boolean optionalJoinpoint_Synchronization = false; // Command line flag: "-Xjoinpoints:synchronization"
  81. private boolean addSerialVerUID = false;
  82. private Properties extraConfiguration = null;
  83. private boolean checkedAdvancedConfiguration=false;
  84. private boolean synchronizationPointcutsInUse = false;
  85. // Xset'table options
  86. private boolean fastDelegateSupportEnabled = isASMAround;
  87. private boolean runMinimalMemory = false;
  88. private boolean shouldPipelineCompilation = true;
  89. protected boolean bcelRepositoryCaching = xsetBCEL_REPOSITORY_CACHING_DEFAULT.equalsIgnoreCase("true");
  90. private boolean completeBinaryTypes = false;
  91. public boolean forDEBUG_structuralChangesCode = false;
  92. public boolean forDEBUG_bridgingCode = false;
  93. private static Trace trace = TraceFactory.getTraceFactory().getTrace(World.class);
  94. // Records whether ASM is around ... so we might use it for delegates
  95. protected static boolean isASMAround = false;
  96. private long errorThreshold;
  97. private long warningThreshold;
  98. // static {
  99. // try {
  100. // Class c = Class.forName("org.aspectj.org.objectweb.asm.ClassVisitor");
  101. // isASMAround = true;
  102. // } catch (ClassNotFoundException cnfe) {
  103. // isASMAround = false;
  104. // }
  105. // }
  106. /**
  107. * A list of RuntimeExceptions containing full stack information for every
  108. * type we couldn't find.
  109. */
  110. private List dumpState_cantFindTypeExceptions = null;
  111. /**
  112. * Play God.
  113. * On the first day, God created the primitive types and put them in the type
  114. * map.
  115. */
  116. protected World() {
  117. super();
  118. if (trace.isTraceEnabled()) trace.enter("<init>", this);
  119. Dump.registerNode(this.getClass(),this);
  120. typeMap.put("B", ResolvedType.BYTE);
  121. typeMap.put("S", ResolvedType.SHORT);
  122. typeMap.put("I", ResolvedType.INT);
  123. typeMap.put("J", ResolvedType.LONG);
  124. typeMap.put("F", ResolvedType.FLOAT);
  125. typeMap.put("D", ResolvedType.DOUBLE);
  126. typeMap.put("C", ResolvedType.CHAR);
  127. typeMap.put("Z", ResolvedType.BOOLEAN);
  128. typeMap.put("V", ResolvedType.VOID);
  129. precedenceCalculator = new AspectPrecedenceCalculator(this);
  130. if (trace.isTraceEnabled()) trace.exit("<init>");
  131. }
  132. /**
  133. * Dump processing when a fatal error occurs
  134. */
  135. public void accept (Dump.IVisitor visitor) {
  136. visitor.visitString("Shadow mungers:");
  137. visitor.visitList(crosscuttingMembersSet.getShadowMungers());
  138. visitor.visitString("Type mungers:");
  139. visitor.visitList(crosscuttingMembersSet.getTypeMungers());
  140. visitor.visitString("Late Type mungers:");
  141. visitor.visitList(crosscuttingMembersSet.getLateTypeMungers());
  142. if (dumpState_cantFindTypeExceptions!=null) {
  143. visitor.visitString("Cant find type problems:");
  144. visitor.visitList(dumpState_cantFindTypeExceptions);
  145. dumpState_cantFindTypeExceptions = null;
  146. }
  147. }
  148. // =============================================================================
  149. // T Y P E R E S O L U T I O N
  150. // =============================================================================
  151. /**
  152. * Resolve a type that we require to be present in the world
  153. */
  154. public ResolvedType resolve(UnresolvedType ty) {
  155. return resolve(ty, false);
  156. }
  157. /**
  158. * Attempt to resolve a type - the source location gives you some context in which
  159. * resolution is taking place. In the case of an error where we can't find the
  160. * type - we can then at least report why (source location) we were trying to resolve it.
  161. */
  162. public ResolvedType resolve(UnresolvedType ty,ISourceLocation isl) {
  163. ResolvedType ret = resolve(ty,true);
  164. if (ResolvedType.isMissing(ty)) {
  165. //IMessage msg = null;
  166. getLint().cantFindType.signal(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,ty.getName()),isl);
  167. //if (isl!=null) {
  168. //msg = MessageUtil.error(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,ty.getName()),isl);
  169. //} else {
  170. //msg = MessageUtil.error(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,ty.getName()));
  171. //}
  172. //messageHandler.handleMessage(msg);
  173. }
  174. return ret;
  175. }
  176. /**
  177. * Convenience method for resolving an array of unresolved types
  178. * in one hit. Useful for e.g. resolving type parameters in signatures.
  179. */
  180. public ResolvedType[] resolve(UnresolvedType[] types) {
  181. if (types == null) return new ResolvedType[0];
  182. ResolvedType[] ret = new ResolvedType[types.length];
  183. for (int i=0; i<types.length; i++) {
  184. ret[i] = resolve(types[i]);
  185. }
  186. return ret;
  187. }
  188. /**
  189. * Resolve a type. This the hub of type resolution. The resolved type is added
  190. * to the type map by signature.
  191. */
  192. public ResolvedType resolve(UnresolvedType ty, boolean allowMissing) {
  193. // special resolution processing for already resolved types.
  194. if (ty instanceof ResolvedType) {
  195. ResolvedType rty = (ResolvedType) ty;
  196. rty = resolve(rty);
  197. return rty;
  198. }
  199. // dispatch back to the type variable reference to resolve its constituent parts
  200. // don't do this for other unresolved types otherwise you'll end up in a loop
  201. if (ty.isTypeVariableReference()) {
  202. return ty.resolve(this);
  203. }
  204. // if we've already got a resolved type for the signature, just return it
  205. // after updating the world
  206. String signature = ty.getSignature();
  207. ResolvedType ret = typeMap.get(signature);
  208. if (ret != null) {
  209. ret.world = this; // Set the world for the RTX
  210. return ret;
  211. } else if ( signature.equals("?") || signature.equals("*")) {
  212. // might be a problem here, not sure '?' should make it to here as a signature, the
  213. // proper signature for wildcard '?' is '*'
  214. // fault in generic wildcard, can't be done earlier because of init issues
  215. ResolvedType something = new BoundedReferenceType("?","Ljava/lang/Object",this);
  216. typeMap.put("?",something);
  217. return something;
  218. }
  219. // no existing resolved type, create one
  220. if (ty.isArray()) {
  221. ResolvedType componentType = resolve(ty.getComponentType(),allowMissing);
  222. //String brackets = signature.substring(0,signature.lastIndexOf("[")+1);
  223. ret = new ResolvedType.Array(signature, "["+componentType.getErasureSignature(),
  224. this,
  225. componentType);
  226. } else {
  227. ret = resolveToReferenceType(ty,allowMissing);
  228. if (!allowMissing && ret.isMissing()) {
  229. ret = handleRequiredMissingTypeDuringResolution(ty);
  230. }
  231. if (completeBinaryTypes) {
  232. completeBinaryType(ret);
  233. }
  234. }
  235. // Pulling in the type may have already put the right entry in the map
  236. if (typeMap.get(signature)==null && !ret.isMissing()) {
  237. typeMap.put(signature, ret);
  238. }
  239. return ret;
  240. }
  241. /**
  242. * Called when a type is resolved - enables its type hierarchy to be finished off before we
  243. * proceed
  244. */
  245. protected void completeBinaryType(ResolvedType ret) {}
  246. /**
  247. * Return true if the classloader relating to this world is definetly the one that will
  248. * define the specified class. Return false otherwise or we don't know for certain.
  249. */
  250. public boolean isLocallyDefined(String classname) {
  251. return false;
  252. }
  253. /**
  254. * We tried to resolve a type and couldn't find it...
  255. */
  256. private ResolvedType handleRequiredMissingTypeDuringResolution(UnresolvedType ty) {
  257. // defer the message until someone asks a question of the type that we can't answer
  258. // just from the signature.
  259. // MessageUtil.error(messageHandler,
  260. // WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE,ty.getName()));
  261. if (dumpState_cantFindTypeExceptions==null) {
  262. dumpState_cantFindTypeExceptions = new ArrayList();
  263. }
  264. dumpState_cantFindTypeExceptions.add(new RuntimeException("Can't find type "+ty.getName()));
  265. return new MissingResolvedTypeWithKnownSignature(ty.getSignature(),this);
  266. }
  267. /**
  268. * Some TypeFactory operations create resolved types directly, but these won't be
  269. * in the typeMap - this resolution process puts them there. Resolved types are
  270. * also told their world which is needed for the special autoboxing resolved types.
  271. */
  272. public ResolvedType resolve(ResolvedType ty) {
  273. if (ty.isTypeVariableReference()) return ty; // until type variables have proper sigs...
  274. ResolvedType resolved = typeMap.get(ty.getSignature());
  275. if (resolved == null) {
  276. typeMap.put(ty.getSignature(), ty);
  277. resolved = ty;
  278. }
  279. resolved.world = this;
  280. return resolved;
  281. }
  282. /**
  283. * Convenience method for finding a type by name and resolving it in one step.
  284. */
  285. public ResolvedType resolve(String name) {
  286. // trace.enter("resolve", this, new Object[] {name});
  287. ResolvedType ret = resolve(UnresolvedType.forName(name));
  288. // trace.exit("resolve", ret);
  289. return ret;
  290. }
  291. public ResolvedType resolve(String name,boolean allowMissing) {
  292. return resolve(UnresolvedType.forName(name),allowMissing);
  293. }
  294. private ResolvedType currentlyResolvingBaseType;
  295. /**
  296. * Resolve to a ReferenceType - simple, raw, parameterized, or generic.
  297. * Raw, parameterized, and generic versions of a type share a delegate.
  298. */
  299. private final ResolvedType resolveToReferenceType(UnresolvedType ty,boolean allowMissing) {
  300. if (ty.isParameterizedType()) {
  301. // ======= parameterized types ================
  302. ResolvedType rt = resolveGenericTypeFor(ty,allowMissing);
  303. if (rt.isMissing()) return rt;
  304. ReferenceType genericType = (ReferenceType)rt;
  305. currentlyResolvingBaseType = genericType;
  306. ReferenceType parameterizedType =
  307. TypeFactory.createParameterizedType(genericType, ty.typeParameters, this);
  308. currentlyResolvingBaseType = null;
  309. return parameterizedType;
  310. } else if (ty.isGenericType()) {
  311. // ======= generic types ======================
  312. ReferenceType genericType = (ReferenceType)resolveGenericTypeFor(ty,false);
  313. return genericType;
  314. } else if (ty.isGenericWildcard()) {
  315. // ======= generic wildcard types =============
  316. return resolveGenericWildcardFor(ty);
  317. } else {
  318. // ======= simple and raw types ===============
  319. String erasedSignature = ty.getErasureSignature();
  320. ReferenceType simpleOrRawType = new ReferenceType(erasedSignature, this);
  321. if (ty.needsModifiableDelegate()) simpleOrRawType.setNeedsModifiableDelegate(true);
  322. ReferenceTypeDelegate delegate = resolveDelegate(simpleOrRawType);
  323. // 117854
  324. // if (delegate == null) return ResolvedType.MISSING;
  325. if (delegate == null) return new MissingResolvedTypeWithKnownSignature(ty.getSignature(),erasedSignature,this);//ResolvedType.MISSING;
  326. if (delegate.isGeneric() && behaveInJava5Way) {
  327. // ======== raw type ===========
  328. simpleOrRawType.typeKind = TypeKind.RAW;
  329. ReferenceType genericType = makeGenericTypeFrom(delegate,simpleOrRawType);
  330. // name = ReferenceType.fromTypeX(UnresolvedType.forRawTypeNames(ty.getName()),this);
  331. simpleOrRawType.setDelegate(delegate);
  332. genericType.setDelegate(delegate);
  333. simpleOrRawType.setGenericType(genericType);
  334. return simpleOrRawType;
  335. } else {
  336. // ======== simple type =========
  337. simpleOrRawType.setDelegate(delegate);
  338. return simpleOrRawType;
  339. }
  340. }
  341. }
  342. /**
  343. * Attempt to resolve a type that should be a generic type.
  344. */
  345. public ResolvedType resolveGenericTypeFor(UnresolvedType anUnresolvedType, boolean allowMissing) {
  346. // Look up the raw type by signature
  347. String rawSignature = anUnresolvedType.getRawType().getSignature();
  348. ResolvedType rawType = (ResolvedType) typeMap.get(rawSignature);
  349. if (rawType==null) {
  350. rawType = resolve(UnresolvedType.forSignature(rawSignature),allowMissing);
  351. typeMap.put(rawSignature,rawType);
  352. }
  353. if (rawType.isMissing()) return rawType;
  354. // Does the raw type know its generic form? (It will if we created the
  355. // raw type from a source type, it won't if its been created just through
  356. // being referenced, e.g. java.util.List
  357. ResolvedType genericType = rawType.getGenericType();
  358. // There is a special case to consider here (testGenericsBang_pr95993 highlights it)
  359. // You may have an unresolvedType for a parameterized type but it
  360. // is backed by a simple type rather than a generic type. This occurs for
  361. // inner types of generic types that inherit their enclosing types
  362. // type variables.
  363. if (rawType.isSimpleType() && (anUnresolvedType.typeParameters==null || anUnresolvedType.typeParameters.length==0)) {
  364. rawType.world = this;
  365. return rawType;
  366. }
  367. if (genericType != null) {
  368. genericType.world = this;
  369. return genericType;
  370. } else {
  371. // Fault in the generic that underpins the raw type ;)
  372. ReferenceTypeDelegate delegate = resolveDelegate((ReferenceType)rawType);
  373. ReferenceType genericRefType = makeGenericTypeFrom(delegate,((ReferenceType)rawType));
  374. ((ReferenceType)rawType).setGenericType(genericRefType);
  375. genericRefType.setDelegate(delegate);
  376. ((ReferenceType)rawType).setDelegate(delegate);
  377. return genericRefType;
  378. }
  379. }
  380. private ReferenceType makeGenericTypeFrom(ReferenceTypeDelegate delegate, ReferenceType rawType) {
  381. String genericSig = delegate.getDeclaredGenericSignature();
  382. if (genericSig != null) {
  383. return new ReferenceType(
  384. UnresolvedType.forGenericTypeSignature(rawType.getSignature(),delegate.getDeclaredGenericSignature()),this);
  385. } else {
  386. return new ReferenceType(
  387. UnresolvedType.forGenericTypeVariables(rawType.getSignature(), delegate.getTypeVariables()),this);
  388. }
  389. }
  390. /**
  391. * Go from an unresolved generic wildcard (represented by UnresolvedType) to a resolved version (BoundedReferenceType).
  392. */
  393. private ReferenceType resolveGenericWildcardFor(UnresolvedType aType) {
  394. BoundedReferenceType ret = null;
  395. // FIXME asc doesnt take account of additional interface bounds (e.g. ? super R & Serializable - can you do that?)
  396. if (aType.isExtends()) {
  397. ReferenceType upperBound = (ReferenceType)resolve(aType.getUpperBound());
  398. ret = new BoundedReferenceType(upperBound,true,this);
  399. } else if (aType.isSuper()) {
  400. ReferenceType lowerBound = (ReferenceType) resolve(aType.getLowerBound());
  401. ret = new BoundedReferenceType(lowerBound,false,this);
  402. } else {
  403. // must be ? on its own!
  404. }
  405. return ret;
  406. }
  407. /**
  408. * Find the ReferenceTypeDelegate behind this reference type so that it can
  409. * fulfill its contract.
  410. */
  411. protected abstract ReferenceTypeDelegate resolveDelegate(ReferenceType ty);
  412. /**
  413. * Special resolution for "core" types like OBJECT. These are resolved just like
  414. * any other type, but if they are not found it is more serious and we issue an
  415. * error message immediately.
  416. */
  417. public ResolvedType getCoreType(UnresolvedType tx) {
  418. ResolvedType coreTy = resolve(tx,true);
  419. if (coreTy.isMissing()) {
  420. MessageUtil.error(messageHandler,
  421. WeaverMessages.format(WeaverMessages.CANT_FIND_CORE_TYPE,tx.getName()));
  422. }
  423. return coreTy;
  424. }
  425. /**
  426. * Lookup a type by signature, if not found then build one and put it in the
  427. * map.
  428. */
  429. public ReferenceType lookupOrCreateName(UnresolvedType ty) {
  430. String signature = ty.getSignature();
  431. ReferenceType ret = lookupBySignature(signature);
  432. if (ret == null) {
  433. ret = ReferenceType.fromTypeX(ty, this);
  434. typeMap.put(signature, ret);
  435. }
  436. return ret;
  437. }
  438. /**
  439. * Lookup a reference type in the world by its signature. Returns
  440. * null if not found.
  441. */
  442. public ReferenceType lookupBySignature(String signature) {
  443. return (ReferenceType) typeMap.get(signature);
  444. }
  445. // =============================================================================
  446. // T Y P E R E S O L U T I O N -- E N D
  447. // =============================================================================
  448. /**
  449. * Member resolution is achieved by resolving the declaring type and then
  450. * looking up the member in the resolved declaring type.
  451. */
  452. public ResolvedMember resolve(Member member) {
  453. ResolvedType declaring = member.getDeclaringType().resolve(this);
  454. if (declaring.isRawType()) declaring = declaring.getGenericType();
  455. ResolvedMember ret;
  456. if (member.getKind() == Member.FIELD) {
  457. ret = declaring.lookupField(member);
  458. } else {
  459. ret = declaring.lookupMethod(member);
  460. }
  461. if (ret != null) return ret;
  462. return declaring.lookupSyntheticMember(member);
  463. }
  464. // Methods for creating various cross-cutting members...
  465. // ===========================================================
  466. /**
  467. * Create an advice shadow munger from the given advice attribute
  468. */
  469. public abstract Advice createAdviceMunger(
  470. AjAttribute.AdviceAttribute attribute,
  471. Pointcut pointcut,
  472. Member signature);
  473. /**
  474. * Create an advice shadow munger for the given advice kind
  475. */
  476. public final Advice createAdviceMunger(
  477. AdviceKind kind,
  478. Pointcut p,
  479. Member signature,
  480. int extraParameterFlags,
  481. IHasSourceLocation loc)
  482. {
  483. AjAttribute.AdviceAttribute attribute =
  484. new AjAttribute.AdviceAttribute(kind, p, extraParameterFlags, loc.getStart(), loc.getEnd(), loc.getSourceContext());
  485. return createAdviceMunger(attribute, p, signature);
  486. }
  487. public abstract ConcreteTypeMunger makeCflowStackFieldAdder(ResolvedMember cflowField);
  488. public abstract ConcreteTypeMunger makeCflowCounterFieldAdder(ResolvedMember cflowField);
  489. /**
  490. * Register a munger for perclause @AJ aspect so that we add aspectOf(..) to them as needed
  491. * @see org.aspectj.weaver.bcel.BcelWorld#makePerClauseAspect(ResolvedType, org.aspectj.weaver.patterns.PerClause.Kind)
  492. */
  493. public abstract ConcreteTypeMunger makePerClauseAspect(ResolvedType aspect, PerClause.Kind kind);
  494. public abstract ConcreteTypeMunger concreteTypeMunger(ResolvedTypeMunger munger, ResolvedType aspectType);
  495. /**
  496. * Same signature as org.aspectj.util.PartialOrder.PartialComparable.compareTo
  497. */
  498. public int compareByPrecedence(ResolvedType aspect1, ResolvedType aspect2) {
  499. return precedenceCalculator.compareByPrecedence(aspect1, aspect2);
  500. }
  501. public Integer getPrecedenceIfAny(ResolvedType aspect1, ResolvedType aspect2) {
  502. return precedenceCalculator.getPrecedenceIfAny(aspect1, aspect2);
  503. }
  504. /**
  505. * compares by precedence with the additional rule that a super-aspect is
  506. * sorted before its sub-aspects
  507. */
  508. public int compareByPrecedenceAndHierarchy(ResolvedType aspect1, ResolvedType aspect2) {
  509. return precedenceCalculator.compareByPrecedenceAndHierarchy(aspect1, aspect2);
  510. }
  511. // simple property getter and setters
  512. // ===========================================================
  513. /**
  514. * Nobody should hold onto a copy of this message handler, or setMessageHandler won't
  515. * work right.
  516. */
  517. public IMessageHandler getMessageHandler() {
  518. return messageHandler;
  519. }
  520. public void setMessageHandler(IMessageHandler messageHandler) {
  521. if (this.isInPinpointMode()) {
  522. this.messageHandler = new PinpointingMessageHandler(messageHandler);
  523. } else {
  524. this.messageHandler = messageHandler;
  525. }
  526. }
  527. /**
  528. * convenenience method for creating and issuing messages via the message handler -
  529. * if you supply two locations you will get two messages.
  530. */
  531. public void showMessage(
  532. Kind kind,
  533. String message,
  534. ISourceLocation loc1,
  535. ISourceLocation loc2)
  536. {
  537. if (loc1 != null) {
  538. messageHandler.handleMessage(new Message(message, kind, null, loc1));
  539. if (loc2 != null) {
  540. messageHandler.handleMessage(new Message(message, kind, null, loc2));
  541. }
  542. } else {
  543. messageHandler.handleMessage(new Message(message, kind, null, loc2));
  544. }
  545. }
  546. public boolean debug (String message) {
  547. return MessageUtil.debug(messageHandler,message);
  548. }
  549. public void setCrossReferenceHandler(ICrossReferenceHandler xrefHandler) {
  550. this.xrefHandler = xrefHandler;
  551. }
  552. /**
  553. * Get the cross-reference handler for the world, may be null.
  554. */
  555. public ICrossReferenceHandler getCrossReferenceHandler() {
  556. return this.xrefHandler;
  557. }
  558. public void setTypeVariableLookupScope(TypeVariableDeclaringElement scope) {
  559. this.typeVariableLookupScope = scope;
  560. }
  561. public TypeVariableDeclaringElement getTypeVariableLookupScope() {
  562. return typeVariableLookupScope;
  563. }
  564. public List getDeclareParents() {
  565. return crosscuttingMembersSet.getDeclareParents();
  566. }
  567. public List getDeclareAnnotationOnTypes() {
  568. return crosscuttingMembersSet.getDeclareAnnotationOnTypes();
  569. }
  570. public List getDeclareAnnotationOnFields() {
  571. return crosscuttingMembersSet.getDeclareAnnotationOnFields();
  572. }
  573. public List getDeclareAnnotationOnMethods() {
  574. return crosscuttingMembersSet.getDeclareAnnotationOnMethods();
  575. }
  576. public List getDeclareSoft() {
  577. return crosscuttingMembersSet.getDeclareSofts();
  578. }
  579. public CrosscuttingMembersSet getCrosscuttingMembersSet() {
  580. return crosscuttingMembersSet;
  581. }
  582. public IHierarchy getModel() {
  583. return model;
  584. }
  585. public void setModel(IHierarchy model) {
  586. this.model = model;
  587. }
  588. public Lint getLint() {
  589. return lint;
  590. }
  591. public void setLint(Lint lint) {
  592. this.lint = lint;
  593. }
  594. public boolean isXnoInline() {
  595. return XnoInline;
  596. }
  597. public void setXnoInline(boolean xnoInline) {
  598. XnoInline = xnoInline;
  599. }
  600. public boolean isXlazyTjp() {
  601. return XlazyTjp;
  602. }
  603. public void setXlazyTjp(boolean b) {
  604. XlazyTjp = b;
  605. }
  606. public boolean isHasMemberSupportEnabled() {
  607. return XhasMember;
  608. }
  609. public void setXHasMemberSupportEnabled(boolean b) {
  610. XhasMember = b;
  611. }
  612. public boolean isInPinpointMode() {
  613. return Xpinpoint;
  614. }
  615. public void setPinpointMode(boolean b) {
  616. this.Xpinpoint = b;
  617. }
  618. public void setBehaveInJava5Way(boolean b) {
  619. behaveInJava5Way = b;
  620. }
  621. /**
  622. * Set the error and warning threashold which can be taken from
  623. * CompilerOptions (see bug 129282)
  624. *
  625. * @param errorThreshold
  626. * @param warningThreshold
  627. */
  628. public void setErrorAndWarningThreshold(long errorThreshold, long warningThreshold) {
  629. this.errorThreshold = errorThreshold;
  630. this.warningThreshold = warningThreshold;
  631. }
  632. /**
  633. * @return true if ignoring the UnusedDeclaredThrownException and false if
  634. * this compiler option is set to error or warning
  635. */
  636. public boolean isIgnoringUnusedDeclaredThrownException() {
  637. // the 0x800000 is CompilerOptions.UnusedDeclaredThrownException
  638. // which is ASTNode.bit24
  639. if((this.errorThreshold & 0x800000) != 0
  640. || (this.warningThreshold & 0x800000) != 0)
  641. return false;
  642. return true;
  643. }
  644. public void performExtraConfiguration(String config) {
  645. if (config==null) return;
  646. // Bunch of name value pairs to split
  647. extraConfiguration = new Properties();
  648. int pos =-1;
  649. while ((pos=config.indexOf(","))!=-1) {
  650. String nvpair = config.substring(0,pos);
  651. int pos2 = nvpair.indexOf("=");
  652. if (pos2!=-1) {
  653. String n = nvpair.substring(0,pos2);
  654. String v = nvpair.substring(pos2+1);
  655. extraConfiguration.setProperty(n,v);
  656. }
  657. config = config.substring(pos+1);
  658. }
  659. if (config.length()>0) {
  660. int pos2 = config.indexOf("=");
  661. if (pos2!=-1) {
  662. String n = config.substring(0,pos2);
  663. String v = config.substring(pos2+1);
  664. extraConfiguration.setProperty(n,v);
  665. }
  666. }
  667. ensureAdvancedConfigurationProcessed();
  668. }
  669. /**
  670. * may return null
  671. */
  672. public Properties getExtraConfiguration() {
  673. return extraConfiguration;
  674. }
  675. public final static String xsetCAPTURE_ALL_CONTEXT = "captureAllContext"; // default false
  676. public final static String xsetACTIVATE_LIGHTWEIGHT_DELEGATES = "activateLightweightDelegates"; // default true
  677. public final static String xsetRUN_MINIMAL_MEMORY ="runMinimalMemory"; // default true
  678. public final static String xsetDEBUG_STRUCTURAL_CHANGES_CODE = "debugStructuralChangesCode"; // default false
  679. public final static String xsetDEBUG_BRIDGING = "debugBridging"; // default false
  680. public final static String xsetBCEL_REPOSITORY_CACHING = "bcelRepositoryCaching";
  681. public final static String xsetPIPELINE_COMPILATION = "pipelineCompilation";
  682. public final static String xsetPIPELINE_COMPILATION_DEFAULT = "true";
  683. public final static String xsetCOMPLETE_BINARY_TYPES = "completeBinaryTypes";
  684. public final static String xsetCOMPLETE_BINARY_TYPES_DEFAULT = "false";
  685. public final static String xsetBCEL_REPOSITORY_CACHING_DEFAULT = "true";
  686. public boolean isInJava5Mode() {
  687. return behaveInJava5Way;
  688. }
  689. public void setTargetAspectjRuntimeLevel(String s) {
  690. targetAspectjRuntimeLevel = s;
  691. }
  692. public void setOptionalJoinpoints(String jps) {
  693. if (jps==null) return;
  694. if (jps.indexOf("arrayconstruction")!=-1) optionalJoinpoint_ArrayConstruction = true;
  695. if (jps.indexOf("synchronization")!=-1) optionalJoinpoint_Synchronization = true;
  696. }
  697. public boolean isJoinpointArrayConstructionEnabled() {
  698. return optionalJoinpoint_ArrayConstruction;
  699. }
  700. public boolean isJoinpointSynchronizationEnabled() {
  701. return optionalJoinpoint_Synchronization;
  702. }
  703. public String getTargetAspectjRuntimeLevel() {
  704. return targetAspectjRuntimeLevel;
  705. }
  706. public boolean isTargettingAspectJRuntime12() {
  707. boolean b = false; // pr116679
  708. if (!isInJava5Mode()) b=true;
  709. else b = getTargetAspectjRuntimeLevel().equals(org.aspectj.weaver.Constants.RUNTIME_LEVEL_12);
  710. //System.err.println("Asked if targetting runtime 1.2 , returning: "+b);
  711. return b;
  712. }
  713. /*
  714. * Map of types in the world, can have 'references' to expendable ones which
  715. * can be garbage collected to recover memory.
  716. * An expendable type is a reference type that is not exposed to the weaver (ie
  717. * just pulled in for type resolution purposes).
  718. */
  719. protected static class TypeMap {
  720. private static boolean debug = false;
  721. // Strategy for entries in the expendable map
  722. public static int DONT_USE_REFS = 0; // Hang around forever
  723. public static int USE_WEAK_REFS = 1; // Collected asap
  724. public static int USE_SOFT_REFS = 2; // Collected when short on memory
  725. // SECRETAPI - Can switch to a policy of choice ;)
  726. public static int policy = USE_SOFT_REFS;
  727. // Map of types that never get thrown away
  728. private Map /* String -> ResolvedType */ tMap = new HashMap();
  729. // Map of types that may be ejected from the cache if we need space
  730. private Map expendableMap = new WeakHashMap();
  731. private World w;
  732. // profiling tools...
  733. private boolean memoryProfiling = false;
  734. private int maxExpendableMapSize = -1;
  735. private int collectedTypes = 0;
  736. private ReferenceQueue rq = new ReferenceQueue();
  737. private static Trace trace = TraceFactory.getTraceFactory().getTrace(World.TypeMap.class);
  738. TypeMap(World w) {
  739. if (trace.isTraceEnabled()) trace.enter("<init>",this,w);
  740. this.w = w;
  741. memoryProfiling = false;// !w.getMessageHandler().isIgnoring(Message.INFO);
  742. if (trace.isTraceEnabled()) trace.exit("<init>");
  743. }
  744. /**
  745. * Add a new type into the map, the key is the type signature.
  746. * Some types do *not* go in the map, these are ones involving
  747. * *member* type variables. The reason is that when all you have is the
  748. * signature which gives you a type variable name, you cannot
  749. * guarantee you are using the type variable in the same way
  750. * as someone previously working with a similarly
  751. * named type variable. So, these do not go into the map:
  752. * - TypeVariableReferenceType.
  753. * - ParameterizedType where a member type variable is involved.
  754. * - BoundedReferenceType when one of the bounds is a type variable.
  755. *
  756. * definition: "member type variables" - a tvar declared on a generic
  757. * method/ctor as opposed to those you see declared on a generic type.
  758. */
  759. public ResolvedType put(String key, ResolvedType type) {
  760. if (type.isParameterizedType() && type.isParameterizedWithAMemberTypeVariable()) {
  761. if (debug)
  762. System.err.println("Not putting a parameterized type that utilises member declared type variables into the typemap: key="+key+" type="+type);
  763. return type;
  764. }
  765. if (type.isTypeVariableReference()) {
  766. if (debug)
  767. System.err.println("Not putting a type variable reference type into the typemap: key="+key+" type="+type);
  768. return type;
  769. }
  770. // this test should be improved - only avoid putting them in if one of the
  771. // bounds is a member type variable
  772. if (type instanceof BoundedReferenceType) {
  773. if (debug)
  774. System.err.println("Not putting a bounded reference type into the typemap: key="+key+" type="+type);
  775. return type;
  776. }
  777. if (type instanceof MissingResolvedTypeWithKnownSignature) {
  778. if (debug)
  779. System.err.println("Not putting a missing type into the typemap: key="+key+" type="+type);
  780. return type;
  781. }
  782. if ((type instanceof ReferenceType) && (((ReferenceType)type).getDelegate()==null) && w.isExpendable(type)) {
  783. if (debug)
  784. System.err.println("Not putting expendable ref type with null delegate into typemap: key="+key+" type="+type);
  785. return type;
  786. }
  787. if (w.isExpendable(type)) {
  788. // Dont use reference queue for tracking if not profiling...
  789. if (policy==USE_WEAK_REFS) {
  790. if (memoryProfiling) expendableMap.put(key,new WeakReference(type,rq));
  791. else expendableMap.put(key,new WeakReference(type));
  792. } else if (policy==USE_SOFT_REFS) {
  793. if (memoryProfiling) expendableMap.put(key,new SoftReference(type,rq));
  794. else expendableMap.put(key,new SoftReference(type));
  795. } else {
  796. expendableMap.put(key,type);
  797. }
  798. if (memoryProfiling && expendableMap.size()>maxExpendableMapSize) {
  799. maxExpendableMapSize = expendableMap.size();
  800. }
  801. return type;
  802. } else {
  803. return (ResolvedType) tMap.put(key,type);
  804. }
  805. }
  806. public void report() {
  807. if (!memoryProfiling) return;
  808. checkq();
  809. w.getMessageHandler().handleMessage(MessageUtil.info("MEMORY: world expendable type map reached maximum size of #"+maxExpendableMapSize+" entries"));
  810. w.getMessageHandler().handleMessage(MessageUtil.info("MEMORY: types collected through garbage collection #"+collectedTypes+" entries"));
  811. }
  812. public void checkq() {
  813. if (!memoryProfiling) return;
  814. while (rq.poll()!=null) collectedTypes++;
  815. }
  816. /**
  817. * Lookup a type by its signature, always look
  818. * in the real map before the expendable map
  819. */
  820. public ResolvedType get(String key) {
  821. checkq();
  822. ResolvedType ret = (ResolvedType) tMap.get(key);
  823. if (ret == null) {
  824. if (policy==USE_WEAK_REFS) {
  825. WeakReference ref = (WeakReference)expendableMap.get(key);
  826. if (ref != null) {
  827. ret = (ResolvedType) ref.get();
  828. }
  829. } else if (policy==USE_SOFT_REFS) {
  830. SoftReference ref = (SoftReference)expendableMap.get(key);
  831. if (ref != null) {
  832. ret = (ResolvedType) ref.get();
  833. }
  834. } else {
  835. return (ResolvedType)expendableMap.get(key);
  836. }
  837. }
  838. return ret;
  839. }
  840. /** Remove a type from the map */
  841. public ResolvedType remove(String key) {
  842. ResolvedType ret = (ResolvedType) tMap.remove(key);
  843. if (ret == null) {
  844. if (policy==USE_WEAK_REFS) {
  845. WeakReference wref = (WeakReference)expendableMap.remove(key);
  846. if (wref!=null) ret = (ResolvedType)wref.get();
  847. } else if (policy==USE_SOFT_REFS) {
  848. SoftReference wref = (SoftReference)expendableMap.remove(key);
  849. if (wref!=null) ret = (ResolvedType)wref.get();
  850. } else {
  851. ret = (ResolvedType)expendableMap.remove(key);
  852. }
  853. }
  854. return ret;
  855. }
  856. public String toString() {
  857. StringBuffer sb = new StringBuffer();
  858. sb.append("types:\n");
  859. sb.append(dumpthem(tMap));
  860. sb.append("expendables:\n");
  861. sb.append(dumpthem(expendableMap));
  862. return sb.toString();
  863. }
  864. private String dumpthem(Map m) {
  865. StringBuffer sb = new StringBuffer();
  866. int otherTypes = 0;
  867. int bcelDel = 0;
  868. int refDel = 0;
  869. for (Iterator iter = m.entrySet().iterator(); iter.hasNext();) {
  870. Map.Entry entry = (Map.Entry) iter.next();
  871. Object val = entry.getValue();
  872. if (val instanceof WeakReference) {
  873. val = ((WeakReference)val).get();
  874. } else
  875. if (val instanceof SoftReference) {
  876. val = ((SoftReference)val).get();
  877. }
  878. sb.append(entry.getKey()+"="+val).append("\n");
  879. if (val instanceof ReferenceType) {
  880. ReferenceType refType = (ReferenceType)val;
  881. if (refType.getDelegate() instanceof BcelObjectType) {
  882. bcelDel++;
  883. } else if (refType.getDelegate() instanceof ReflectionBasedReferenceTypeDelegate) {
  884. refDel++;
  885. } else {
  886. otherTypes++;
  887. }
  888. } else {
  889. otherTypes++;
  890. }
  891. }
  892. sb.append("# BCEL = "+bcelDel+", # REF = "+refDel+", # Other = "+otherTypes);
  893. return sb.toString();
  894. }
  895. public int totalSize() {
  896. return tMap.size()+expendableMap.size();
  897. }
  898. public int hardSize() {
  899. return tMap.size();
  900. }
  901. }
  902. /** Reference types we don't intend to weave may be ejected from
  903. * the cache if we need the space.
  904. */
  905. protected boolean isExpendable(ResolvedType type) {
  906. return (
  907. !type.equals(UnresolvedType.OBJECT) &&
  908. (type != null) &&
  909. (!type.isExposedToWeaver()) &&
  910. (!type.isPrimitiveType())
  911. );
  912. }
  913. /**
  914. * This class is used to compute and store precedence relationships between
  915. * aspects.
  916. */
  917. private static class AspectPrecedenceCalculator {
  918. private World world;
  919. private Map cachedResults;
  920. public AspectPrecedenceCalculator(World forSomeWorld) {
  921. this.world = forSomeWorld;
  922. this.cachedResults = new HashMap();
  923. }
  924. /**
  925. * Ask every declare precedence in the world to order the two aspects.
  926. * If more than one declare precedence gives an ordering, and the orderings
  927. * conflict, then that's an error.
  928. */
  929. public int compareByPrecedence(ResolvedType firstAspect, ResolvedType secondAspect) {
  930. PrecedenceCacheKey key = new PrecedenceCacheKey(firstAspect,secondAspect);
  931. if (cachedResults.containsKey(key)) {
  932. return ((Integer) cachedResults.get(key)).intValue();
  933. } else {
  934. int order = 0;
  935. DeclarePrecedence orderer = null; // Records the declare precedence statement that gives the first ordering
  936. for (Iterator i = world.getCrosscuttingMembersSet().getDeclareDominates().iterator(); i.hasNext(); ) {
  937. DeclarePrecedence d = (DeclarePrecedence)i.next();
  938. int thisOrder = d.compare(firstAspect, secondAspect);
  939. if (thisOrder != 0) {
  940. if (orderer==null) orderer = d;
  941. if (order != 0 && order != thisOrder) {
  942. ISourceLocation[] isls = new ISourceLocation[2];
  943. isls[0]=orderer.getSourceLocation();
  944. isls[1]=d.getSourceLocation();
  945. Message m =
  946. new Message("conflicting declare precedence orderings for aspects: "+
  947. firstAspect.getName()+" and "+secondAspect.getName(),null,true,isls);
  948. world.getMessageHandler().handleMessage(m);
  949. } else {
  950. order = thisOrder;
  951. }
  952. }
  953. }
  954. cachedResults.put(key, new Integer(order));
  955. return order;
  956. }
  957. }
  958. public Integer getPrecedenceIfAny(ResolvedType aspect1,ResolvedType aspect2) {
  959. return (Integer)cachedResults.get(new PrecedenceCacheKey(aspect1,aspect2));
  960. }
  961. public int compareByPrecedenceAndHierarchy(ResolvedType firstAspect, ResolvedType secondAspect) {
  962. if (firstAspect.equals(secondAspect)) return 0;
  963. int ret = compareByPrecedence(firstAspect, secondAspect);
  964. if (ret != 0) return ret;
  965. if (firstAspect.isAssignableFrom(secondAspect)) return -1;
  966. else if (secondAspect.isAssignableFrom(firstAspect)) return +1;
  967. return 0;
  968. }
  969. private static class PrecedenceCacheKey {
  970. public ResolvedType aspect1;
  971. public ResolvedType aspect2;
  972. public PrecedenceCacheKey(ResolvedType a1, ResolvedType a2) {
  973. this.aspect1 = a1;
  974. this.aspect2 = a2;
  975. }
  976. public boolean equals(Object obj) {
  977. if (!(obj instanceof PrecedenceCacheKey)) return false;
  978. PrecedenceCacheKey other = (PrecedenceCacheKey) obj;
  979. return (aspect1 == other.aspect1 && aspect2 == other.aspect2);
  980. }
  981. public int hashCode() {
  982. return aspect1.hashCode() + aspect2.hashCode();
  983. }
  984. }
  985. }
  986. public void validateType(UnresolvedType type) { }
  987. // --- with java5 we can get into a recursive mess if we aren't careful when resolving types (*cough* java.lang.Enum) ---
  988. // --- this first map is for java15 delegates which may try and recursively access the same type variables.
  989. // --- I would rather stash this against a reference type - but we don't guarantee referencetypes are unique for
  990. // so we can't :(
  991. private Map workInProgress1 = new HashMap();
  992. public TypeVariable[] getTypeVariablesCurrentlyBeingProcessed(Class baseClass) {
  993. return (TypeVariable[])workInProgress1.get(baseClass);
  994. }
  995. public void recordTypeVariablesCurrentlyBeingProcessed(Class baseClass, TypeVariable[] typeVariables) {
  996. workInProgress1.put(baseClass,typeVariables);
  997. }
  998. public void forgetTypeVariablesCurrentlyBeingProcessed(Class baseClass) {
  999. workInProgress1.remove(baseClass);
  1000. }
  1001. public void setAddSerialVerUID(boolean b) { addSerialVerUID=b;}
  1002. public boolean isAddSerialVerUID() { return addSerialVerUID;}
  1003. /** be careful calling this - pr152257 */
  1004. public void flush() {
  1005. typeMap.expendableMap.clear();
  1006. }
  1007. public void ensureAdvancedConfigurationProcessed() {
  1008. // Check *once* whether the user has switched asm support off
  1009. if (!checkedAdvancedConfiguration) {
  1010. Properties p = getExtraConfiguration();
  1011. if (p!=null) {
  1012. if (isASMAround) { // dont bother if its not...
  1013. String s = p.getProperty(xsetACTIVATE_LIGHTWEIGHT_DELEGATES,"true");
  1014. fastDelegateSupportEnabled = s.equalsIgnoreCase("true");
  1015. if (!fastDelegateSupportEnabled)
  1016. getMessageHandler().handleMessage(MessageUtil.info("[activateLightweightDelegates=false] Disabling optimization to use lightweight delegates for non-woven types"));
  1017. }
  1018. String s = p.getProperty(xsetBCEL_REPOSITORY_CACHING,xsetBCEL_REPOSITORY_CACHING_DEFAULT);
  1019. bcelRepositoryCaching = s.equalsIgnoreCase("true");
  1020. if (!bcelRepositoryCaching) {
  1021. getMessageHandler().handleMessage(MessageUtil.info("[bcelRepositoryCaching=false] AspectJ will not use a bcel cache for class information"));
  1022. }
  1023. s = p.getProperty(xsetPIPELINE_COMPILATION,xsetPIPELINE_COMPILATION_DEFAULT);
  1024. shouldPipelineCompilation = s.equalsIgnoreCase("true");
  1025. s = p.getProperty(xsetCOMPLETE_BINARY_TYPES,xsetCOMPLETE_BINARY_TYPES_DEFAULT);
  1026. completeBinaryTypes = s.equalsIgnoreCase("true");
  1027. if (completeBinaryTypes) {
  1028. getMessageHandler().handleMessage(MessageUtil.info("[completeBinaryTypes=true] Completion of binary types activated"));
  1029. }
  1030. s = p.getProperty(xsetRUN_MINIMAL_MEMORY,"false");
  1031. runMinimalMemory = s.equalsIgnoreCase("true");
  1032. // if (runMinimalMemory)
  1033. // getMessageHandler().handleMessage(MessageUtil.info("[runMinimalMemory=true] Optimizing bcel processing (and cost of performance) to use less memory"));
  1034. s = p.getProperty(xsetDEBUG_STRUCTURAL_CHANGES_CODE,"false");
  1035. forDEBUG_structuralChangesCode = s.equalsIgnoreCase("true");
  1036. s = p.getProperty(xsetDEBUG_BRIDGING,"false");
  1037. forDEBUG_bridgingCode = s.equalsIgnoreCase("true");
  1038. }
  1039. checkedAdvancedConfiguration=true;
  1040. }
  1041. }
  1042. public boolean isRunMinimalMemory() {
  1043. ensureAdvancedConfigurationProcessed();
  1044. return runMinimalMemory;
  1045. }
  1046. public boolean shouldPipelineCompilation() {
  1047. ensureAdvancedConfigurationProcessed();
  1048. return shouldPipelineCompilation;
  1049. }
  1050. public void setFastDelegateSupport(boolean b) {
  1051. if (b && !isASMAround) {
  1052. throw new BCException("Unable to activate fast delegate support, ASM classes cannot be found");
  1053. }
  1054. fastDelegateSupportEnabled = b;
  1055. }
  1056. public boolean isFastDelegateSupportEnabled() {
  1057. return false; // ASM not currently being used
  1058. // ensureAdvancedConfigurationProcessed();
  1059. // return fastDelegateSupportEnabled;
  1060. }
  1061. public void setIncrementalCompileCouldFollow(boolean b) {incrementalCompileCouldFollow = b;}
  1062. public boolean couldIncrementalCompileFollow() {return incrementalCompileCouldFollow;}
  1063. public void setSynchronizationPointcutsInUse() {
  1064. if (trace.isTraceEnabled()) trace.enter("setSynchronizationPointcutsInUse", this);
  1065. synchronizationPointcutsInUse =true;
  1066. if (trace.isTraceEnabled()) trace.exit("setSynchronizationPointcutsInUse");
  1067. }
  1068. public boolean areSynchronizationPointcutsInUse() {return synchronizationPointcutsInUse;}
  1069. public boolean isASMAround() {
  1070. return isASMAround;
  1071. }
  1072. }