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.

AjBuildManager.java 58KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajdt.internal.core.builder;
  13. import java.io.BufferedOutputStream;
  14. import java.io.ByteArrayOutputStream;
  15. import java.io.File;
  16. import java.io.FileFilter;
  17. import java.io.FileInputStream;
  18. import java.io.FileNotFoundException;
  19. import java.io.IOException;
  20. import java.io.OutputStream;
  21. import java.io.PrintStream;
  22. import java.util.ArrayList;
  23. import java.util.Collection;
  24. import java.util.Collections;
  25. import java.util.HashMap;
  26. import java.util.Iterator;
  27. import java.util.List;
  28. import java.util.Locale;
  29. import java.util.Map;
  30. import java.util.Set;
  31. import java.util.jar.Attributes;
  32. import java.util.jar.JarFile;
  33. import java.util.jar.JarInputStream;
  34. import java.util.jar.JarOutputStream;
  35. import java.util.jar.Manifest;
  36. import java.util.zip.ZipEntry;
  37. import org.aspectj.ajdt.ajc.BuildArgParser;
  38. import org.aspectj.ajdt.internal.compiler.AjCompilerAdapter;
  39. import org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter;
  40. import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
  41. import org.aspectj.ajdt.internal.compiler.IBinarySourceProvider;
  42. import org.aspectj.ajdt.internal.compiler.ICompilerAdapter;
  43. import org.aspectj.ajdt.internal.compiler.ICompilerAdapterFactory;
  44. import org.aspectj.ajdt.internal.compiler.IIntermediateResultsRequestor;
  45. import org.aspectj.ajdt.internal.compiler.IOutputClassFileNameProvider;
  46. import org.aspectj.ajdt.internal.compiler.InterimCompilationResult;
  47. import org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment;
  48. import org.aspectj.ajdt.internal.compiler.lookup.AnonymousClassPublisher;
  49. import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
  50. import org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter;
  51. import org.aspectj.asm.AsmManager;
  52. import org.aspectj.asm.IHierarchy;
  53. import org.aspectj.asm.IProgramElement;
  54. import org.aspectj.asm.internal.ProgramElement;
  55. import org.aspectj.bridge.AbortException;
  56. import org.aspectj.bridge.CountingMessageHandler;
  57. import org.aspectj.bridge.ILifecycleAware;
  58. import org.aspectj.bridge.IMessage;
  59. import org.aspectj.bridge.IMessageHandler;
  60. import org.aspectj.bridge.IProgressListener;
  61. import org.aspectj.bridge.ISourceLocation;
  62. import org.aspectj.bridge.Message;
  63. import org.aspectj.bridge.MessageUtil;
  64. import org.aspectj.bridge.SourceLocation;
  65. import org.aspectj.bridge.Version;
  66. import org.aspectj.bridge.context.CompilationAndWeavingContext;
  67. import org.aspectj.bridge.context.ContextFormatter;
  68. import org.aspectj.bridge.context.ContextToken;
  69. import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
  70. import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
  71. import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
  72. import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
  73. import org.aspectj.org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
  74. import org.aspectj.org.eclipse.jdt.internal.compiler.ICompilerRequestor;
  75. import org.aspectj.org.eclipse.jdt.internal.compiler.IProblemFactory;
  76. import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathLocation;
  77. import org.aspectj.org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
  78. import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem;
  79. import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
  80. import org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
  81. import org.aspectj.org.eclipse.jdt.internal.compiler.env.IModule;
  82. import org.aspectj.org.eclipse.jdt.internal.compiler.env.INameEnvironment;
  83. import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
  84. import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser;
  85. import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
  86. import org.aspectj.org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
  87. import org.aspectj.tools.ajc.Main;
  88. import org.aspectj.util.FileUtil;
  89. import org.aspectj.weaver.CustomMungerFactory;
  90. import org.aspectj.weaver.Dump;
  91. import org.aspectj.weaver.ResolvedType;
  92. import org.aspectj.weaver.World;
  93. import org.aspectj.weaver.bcel.BcelWeaver;
  94. import org.aspectj.weaver.bcel.BcelWorld;
  95. import org.aspectj.weaver.bcel.UnwovenClassFile;
  96. import org.eclipse.core.runtime.OperationCanceledException;
  97. public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySourceProvider, ICompilerAdapterFactory {
  98. private static final String CROSSREFS_FILE_NAME = "build.lst";
  99. private static final String CANT_WRITE_RESULT = "unable to write compilation result";
  100. private static final String MANIFEST_NAME = "META-INF/MANIFEST.MF";
  101. public static boolean COPY_INPATH_DIR_RESOURCES = false;
  102. // AJDT doesn't want this check, so Main enables it.
  103. private static boolean DO_RUNTIME_VERSION_CHECK = false;
  104. // If runtime version check fails, warn or fail? (unset?)
  105. static final boolean FAIL_IF_RUNTIME_NOT_FOUND = false;
  106. private static final FileFilter binarySourceFilter = new FileFilter() {
  107. @Override
  108. public boolean accept(File f) {
  109. return f.getName().endsWith(".class");
  110. }
  111. };
  112. /**
  113. * This builder is static so that it can be subclassed and reset. However, note that there is only one builder present, so if
  114. * two extendsion reset it, only the latter will get used.
  115. */
  116. public static AsmHierarchyBuilder asmHierarchyBuilder = new AsmHierarchyBuilder();
  117. static {
  118. // CompilationAndWeavingContext.setMultiThreaded(false);
  119. CompilationAndWeavingContext.registerFormatter(CompilationAndWeavingContext.BATCH_BUILD, new AjBuildContexFormatter());
  120. CompilationAndWeavingContext
  121. .registerFormatter(CompilationAndWeavingContext.INCREMENTAL_BUILD, new AjBuildContexFormatter());
  122. }
  123. private IProgressListener progressListener = null;
  124. private boolean environmentSupportsIncrementalCompilation = false;
  125. private int compiledCount;
  126. private int sourceFileCount;
  127. private JarOutputStream zos;
  128. private boolean batchCompile = true;
  129. private INameEnvironment environment;
  130. private Map<String, List<UnwovenClassFile>> /* String -> List<UCF> */binarySourcesForTheNextCompile = new HashMap<String, List<UnwovenClassFile>>();
  131. // FIXME asc should this really be in here?
  132. // private AsmManager structureModel;
  133. public AjBuildConfig buildConfig;
  134. private boolean ignoreOutxml;
  135. private boolean wasFullBuild = true; // true if last build was a full build rather than an incremental build
  136. AjState state = new AjState(this);
  137. /**
  138. * Enable check for runtime version, used only by Ant/command-line Main.
  139. *
  140. * @param caller Main unused except to limit to non-null clients.
  141. */
  142. public static void enableRuntimeVersionCheck(Main caller) {
  143. DO_RUNTIME_VERSION_CHECK = null != caller;
  144. }
  145. public BcelWeaver getWeaver() {
  146. return state.getWeaver();
  147. }
  148. public BcelWorld getBcelWorld() {
  149. return state.getBcelWorld();
  150. }
  151. public CountingMessageHandler handler;
  152. private CustomMungerFactory customMungerFactory;
  153. public AjBuildManager(IMessageHandler holder) {
  154. super();
  155. this.handler = CountingMessageHandler.makeCountingMessageHandler(holder);
  156. }
  157. public void environmentSupportsIncrementalCompilation(boolean itDoes) {
  158. this.environmentSupportsIncrementalCompilation = itDoes;
  159. if (itDoes) {
  160. org.aspectj.weaver.loadtime.definition.DocumentParser.deactivateCaching();
  161. }
  162. }
  163. /** @return true if we should generate a model as a side-effect */
  164. public boolean doGenerateModel() {
  165. return buildConfig.isGenerateModelMode();
  166. }
  167. public boolean batchBuild(AjBuildConfig buildConfig, IMessageHandler baseHandler) throws IOException, AbortException {
  168. return performBuild(buildConfig, baseHandler, true);
  169. }
  170. public boolean incrementalBuild(AjBuildConfig buildConfig, IMessageHandler baseHandler) throws IOException, AbortException {
  171. return performBuild(buildConfig, baseHandler, false);
  172. }
  173. /**
  174. * Perform a build.
  175. *
  176. * @return true if the build was successful (ie. no errors)
  177. */
  178. private boolean performBuild(AjBuildConfig buildConfig, IMessageHandler baseHandler, boolean isFullBuild) throws IOException,
  179. AbortException {
  180. boolean ret = true;
  181. batchCompile = isFullBuild;
  182. wasFullBuild = isFullBuild;
  183. if (baseHandler instanceof ILifecycleAware) {
  184. ((ILifecycleAware) baseHandler).buildStarting(!isFullBuild);
  185. }
  186. CompilationAndWeavingContext.reset();
  187. final int phase = isFullBuild ? CompilationAndWeavingContext.BATCH_BUILD : CompilationAndWeavingContext.INCREMENTAL_BUILD;
  188. final ContextToken ct = CompilationAndWeavingContext.enteringPhase(phase, buildConfig);
  189. try {
  190. if (isFullBuild) {
  191. this.state = new AjState(this);
  192. }
  193. this.state.setCouldBeSubsequentIncrementalBuild(this.environmentSupportsIncrementalCompilation);
  194. final boolean canIncremental = state.prepareForNextBuild(buildConfig);
  195. if (!canIncremental && !isFullBuild) { // retry as batch?
  196. CompilationAndWeavingContext.leavingPhase(ct);
  197. if (state.listenerDefined()) {
  198. state.getListener().recordDecision("Falling back to batch compilation");
  199. }
  200. return performBuild(buildConfig, baseHandler, true);
  201. }
  202. this.handler = CountingMessageHandler.makeCountingMessageHandler(baseHandler);
  203. if (buildConfig == null || buildConfig.isCheckRuntimeVersion()) {
  204. if (DO_RUNTIME_VERSION_CHECK) {
  205. final String check = checkRtJar(buildConfig);
  206. if (check != null) {
  207. if (FAIL_IF_RUNTIME_NOT_FOUND) {
  208. MessageUtil.error(handler, check);
  209. CompilationAndWeavingContext.leavingPhase(ct);
  210. return false;
  211. } else {
  212. MessageUtil.warn(handler, check);
  213. }
  214. }
  215. }
  216. }
  217. // if (batch) {
  218. setBuildConfig(buildConfig);
  219. // }
  220. if (isFullBuild || !AsmManager.attemptIncrementalModelRepairs) {
  221. // if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
  222. setupModel(buildConfig);
  223. // }
  224. }
  225. if (isFullBuild) {
  226. initBcelWorld(handler);
  227. }
  228. if (handler.hasErrors()) {
  229. CompilationAndWeavingContext.leavingPhase(ct);
  230. return false;
  231. }
  232. if (buildConfig.getOutputJar() != null) {
  233. if (!openOutputStream(buildConfig.getOutputJar())) {
  234. CompilationAndWeavingContext.leavingPhase(ct);
  235. return false;
  236. }
  237. }
  238. if (isFullBuild) {
  239. // System.err.println("XXXX batch: " + buildConfig.getFiles());
  240. if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
  241. AsmManager.setLastActiveStructureModel(state.getStructureModel());
  242. getWorld().setModel(state.getStructureModel());
  243. // in incremental build, only get updated model?
  244. }
  245. binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(true);
  246. performCompilation(buildConfig.getFiles());
  247. state.clearBinarySourceFiles(); // we don't want these hanging around...
  248. if (!proceedOnError() && handler.hasErrors()) {
  249. CompilationAndWeavingContext.leavingPhase(ct);
  250. if (AsmManager.isReporting()) {
  251. state.getStructureModel().reportModelInfo("After a batch build");
  252. }
  253. return false;
  254. }
  255. if (AsmManager.isReporting()) {
  256. state.getStructureModel().reportModelInfo("After a batch build");
  257. }
  258. } else {
  259. // done already?
  260. // if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
  261. // bcelWorld.setModel(StructureModelManager.INSTANCE.getStructureModel());
  262. // }
  263. // System.err.println("XXXX start inc ");
  264. AsmManager.setLastActiveStructureModel(state.getStructureModel());
  265. binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(true);
  266. Set<File> files = state.getFilesToCompile(true);
  267. if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
  268. if (AsmManager.attemptIncrementalModelRepairs) {
  269. state.getStructureModel().resetDeltaProcessing();
  270. state.getStructureModel().processDelta(files, state.getAddedFiles(), state.getDeletedFiles());
  271. }
  272. }
  273. boolean hereWeGoAgain = !(files.isEmpty() && binarySourcesForTheNextCompile.isEmpty());
  274. for (int i = 0; (i < 5) && hereWeGoAgain; i++) {
  275. if (state.listenerDefined()) {
  276. state.getListener()
  277. .recordInformation("Starting incremental compilation loop " + (i + 1) + " of possibly 5");
  278. // System.err.println("XXXX inc: " + files);
  279. }
  280. performCompilation(files);
  281. if ((!proceedOnError() && handler.hasErrors())
  282. || (progressListener != null && progressListener.isCancelledRequested())) {
  283. CompilationAndWeavingContext.leavingPhase(ct);
  284. return false;
  285. }
  286. if (state.requiresFullBatchBuild()) {
  287. if (state.listenerDefined()) {
  288. state.getListener().recordInformation(" Dropping back to full build");
  289. }
  290. return batchBuild(buildConfig, baseHandler);
  291. }
  292. binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(false);
  293. files = state.getFilesToCompile(false);
  294. hereWeGoAgain = !(files.isEmpty() && binarySourcesForTheNextCompile.isEmpty());
  295. // TODO Andy - Needs some thought here...
  296. // I think here we might want to pass empty addedFiles/deletedFiles as they were
  297. // dealt with on the first call to processDelta - we are going through this loop
  298. // again because in compiling something we found something else we needed to
  299. // rebuild. But what case causes this?
  300. if (hereWeGoAgain) {
  301. if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
  302. if (AsmManager.attemptIncrementalModelRepairs) {
  303. state.getStructureModel().processDelta(files, state.getAddedFiles(), state.getDeletedFiles());
  304. }
  305. }
  306. }
  307. }
  308. if (!files.isEmpty()) {
  309. CompilationAndWeavingContext.leavingPhase(ct);
  310. return batchBuild(buildConfig, baseHandler);
  311. } else {
  312. if (AsmManager.isReporting()) {
  313. state.getStructureModel().reportModelInfo("After an incremental build");
  314. }
  315. }
  316. }
  317. // XXX not in Mik's incremental
  318. if (buildConfig.isEmacsSymMode()) {
  319. new org.aspectj.ajdt.internal.core.builder.EmacsStructureModelManager().externalizeModel(state.getStructureModel());
  320. }
  321. // for bug 113554: support ajsym file generation for command line builds
  322. if (buildConfig.isGenerateCrossRefsMode()) {
  323. final File configFileProxy = new File(buildConfig.getOutputDir(), CROSSREFS_FILE_NAME);
  324. state.getStructureModel().writeStructureModel(configFileProxy.getAbsolutePath());
  325. }
  326. // have to tell state we succeeded or next is not incremental
  327. state.successfulCompile(buildConfig, isFullBuild);
  328. // For a full compile, copy resources to the destination
  329. // - they should not get deleted on incremental and AJDT
  330. // will handle changes to them that require a recopying
  331. if (isFullBuild) {
  332. copyResourcesToDestination();
  333. }
  334. if (buildConfig.getOutxmlName() != null) {
  335. writeOutxmlFile();
  336. }
  337. /* boolean weaved = */// weaveAndGenerateClassFiles();
  338. // if not weaved, then no-op build, no model changes
  339. // but always returns true
  340. // XXX weaved not in Mik's incremental
  341. if (buildConfig.isGenerateModelMode()) {
  342. state.getStructureModel().fireModelUpdated();
  343. }
  344. CompilationAndWeavingContext.leavingPhase(ct);
  345. } finally {
  346. if (baseHandler instanceof ILifecycleAware) {
  347. ((ILifecycleAware) baseHandler).buildFinished(!isFullBuild);
  348. }
  349. if (zos != null) {
  350. closeOutputStream(buildConfig.getOutputJar());
  351. }
  352. ret = !handler.hasErrors();
  353. if (getBcelWorld() != null) {
  354. final BcelWorld bcelWorld = getBcelWorld();
  355. bcelWorld.reportTimers();
  356. bcelWorld.tidyUp();
  357. }
  358. if (getWeaver() != null) {
  359. getWeaver().tidyUp();
  360. // bug 59895, don't release reference to handler as may be needed by a nested call
  361. // handler = null;
  362. }
  363. }
  364. return ret;
  365. }
  366. /**
  367. * Open an output jar file in which to write the compiler output.
  368. *
  369. * @param outJar the jar file to open
  370. * @return true if successful
  371. */
  372. private boolean openOutputStream(File outJar) {
  373. try {
  374. OutputStream os = FileUtil.makeOutputStream(buildConfig.getOutputJar());
  375. zos = new JarOutputStream(os, getWeaver().getManifest(true));
  376. } catch (IOException ex) {
  377. IMessage message = new Message("Unable to open outjar " + outJar.getPath() + "(" + ex.getMessage() + ")",
  378. new SourceLocation(outJar, 0), true);
  379. handler.handleMessage(message);
  380. return false;
  381. }
  382. return true;
  383. }
  384. private void closeOutputStream(File outJar) {
  385. try {
  386. if (zos != null) {
  387. zos.close();
  388. if (buildConfig.getCompilationResultDestinationManager() != null) {
  389. buildConfig.getCompilationResultDestinationManager().reportFileWrite(outJar.getPath(),
  390. CompilationResultDestinationManager.FILETYPE_OUTJAR);
  391. }
  392. }
  393. zos = null;
  394. /* Ensure we don't write an incomplete JAR bug-71339 */
  395. if (handler.hasErrors()) {
  396. outJar.delete();
  397. if (buildConfig.getCompilationResultDestinationManager() != null) {
  398. buildConfig.getCompilationResultDestinationManager().reportFileRemove(outJar.getPath(),
  399. CompilationResultDestinationManager.FILETYPE_OUTJAR);
  400. }
  401. }
  402. } catch (IOException ex) {
  403. IMessage message = new Message("Unable to write outjar " + outJar.getPath() + "(" + ex.getMessage() + ")",
  404. new SourceLocation(outJar, 0), true);
  405. handler.handleMessage(message);
  406. }
  407. }
  408. private void copyResourcesToDestination() throws IOException {
  409. // resources that we need to copy are contained in the injars and inpath only
  410. for (Iterator i = buildConfig.getInJars().iterator(); i.hasNext();) {
  411. File inJar = (File) i.next();
  412. copyResourcesFromJarFile(inJar);
  413. }
  414. for (Iterator i = buildConfig.getInpath().iterator(); i.hasNext();) {
  415. File inPathElement = (File) i.next();
  416. if (inPathElement.isDirectory()) {
  417. copyResourcesFromDirectory(inPathElement);
  418. } else {
  419. copyResourcesFromJarFile(inPathElement);
  420. }
  421. }
  422. if (buildConfig.getSourcePathResources() != null) {
  423. for (Iterator i = buildConfig.getSourcePathResources().keySet().iterator(); i.hasNext();) {
  424. String resource = (String) i.next();
  425. File from = buildConfig.getSourcePathResources().get(resource);
  426. copyResourcesFromFile(from, resource, from);
  427. }
  428. }
  429. writeManifest();
  430. }
  431. private void copyResourcesFromJarFile(File jarFile) throws IOException {
  432. JarInputStream inStream = null;
  433. try {
  434. inStream = new JarInputStream(new FileInputStream(jarFile));
  435. while (true) {
  436. ZipEntry entry = inStream.getNextEntry();
  437. if (entry == null) {
  438. break;
  439. }
  440. String filename = entry.getName();
  441. // System.out.println("? copyResourcesFromJarFile() filename='" + filename +"'");
  442. if (entry.isDirectory()) {
  443. writeDirectory(filename, jarFile);
  444. } else if (acceptResource(filename, false)) {
  445. byte[] bytes = FileUtil.readAsByteArray(inStream);
  446. writeResource(filename, bytes, jarFile);
  447. }
  448. inStream.closeEntry();
  449. }
  450. } finally {
  451. if (inStream != null) {
  452. inStream.close();
  453. }
  454. }
  455. }
  456. private void copyResourcesFromDirectory(File dir) throws IOException {
  457. if (!COPY_INPATH_DIR_RESOURCES) {
  458. return;
  459. }
  460. // Get a list of all files (i.e. everything that isnt a directory)
  461. File[] files = FileUtil.listFiles(dir, new FileFilter() {
  462. @Override
  463. public boolean accept(File f) {
  464. boolean accept = !(f.isDirectory() || f.getName().endsWith(".class"));
  465. return accept;
  466. }
  467. });
  468. // For each file, add it either as a real .class file or as a resource
  469. for (int i = 0; i < files.length; i++) {
  470. // ASSERT: files[i].getAbsolutePath().startsWith(inFile.getAbsolutePath()
  471. // or we are in trouble...
  472. String filename = files[i].getAbsolutePath().substring(dir.getAbsolutePath().length() + 1);
  473. copyResourcesFromFile(files[i], filename, dir);
  474. }
  475. }
  476. private void copyResourcesFromFile(File f, String filename, File src) throws IOException {
  477. if (!acceptResource(filename, true)) {
  478. return;
  479. }
  480. FileInputStream fis = null;
  481. try {
  482. fis = new FileInputStream(f);
  483. byte[] bytes = FileUtil.readAsByteArray(fis);
  484. // String relativePath = files[i].getPath();
  485. writeResource(filename, bytes, src);
  486. } catch (FileNotFoundException fnfe) {
  487. // pr359332: looks like the file moved (refactoring?) just as this copy was starting
  488. // that is OK
  489. } finally {
  490. if (fis != null) {
  491. fis.close();
  492. }
  493. }
  494. }
  495. /**
  496. * Add a directory entry to the output zip file. Don't do anything if not writing out to a zip file. A directory entry is one
  497. * whose filename ends with '/'
  498. *
  499. * @param directory the directory path
  500. * @param srcloc the src of the directory entry, for use when creating a warning message
  501. * @throws IOException if something goes wrong creating the new zip entry
  502. */
  503. private void writeDirectory(String directory, File srcloc) throws IOException {
  504. if (state.hasResource(directory)) {
  505. IMessage msg = new Message("duplicate resource: '" + directory + "'", IMessage.WARNING, null, new SourceLocation(
  506. srcloc, 0));
  507. handler.handleMessage(msg);
  508. return;
  509. }
  510. if (zos != null) {
  511. ZipEntry newEntry = new ZipEntry(directory);
  512. zos.putNextEntry(newEntry);
  513. zos.closeEntry();
  514. state.recordResource(directory, srcloc);
  515. }
  516. // Nothing to do if not writing to a zip file
  517. }
  518. private void writeResource(String filename, byte[] content, File srcLocation) throws IOException {
  519. if (state.hasResource(filename)) {
  520. IMessage msg = new Message("duplicate resource: '" + filename + "'", IMessage.WARNING, null, new SourceLocation(
  521. srcLocation, 0));
  522. handler.handleMessage(msg);
  523. return;
  524. }
  525. if (filename.equals(buildConfig.getOutxmlName())) {
  526. ignoreOutxml = true;
  527. IMessage msg = new Message("-outxml/-outxmlfile option ignored because resource already exists: '" + filename + "'",
  528. IMessage.WARNING, null, new SourceLocation(srcLocation, 0));
  529. handler.handleMessage(msg);
  530. }
  531. if (zos != null) {
  532. ZipEntry newEntry = new ZipEntry(filename); // ??? get compression scheme right
  533. zos.putNextEntry(newEntry);
  534. zos.write(content);
  535. zos.closeEntry();
  536. } else {
  537. File destDir = buildConfig.getOutputDir();
  538. if (buildConfig.getCompilationResultDestinationManager() != null) {
  539. destDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForResource(srcLocation);
  540. }
  541. try {
  542. File outputLocation = new File(destDir, filename);
  543. OutputStream fos = FileUtil.makeOutputStream(outputLocation);
  544. fos.write(content);
  545. fos.close();
  546. if (buildConfig.getCompilationResultDestinationManager() != null) {
  547. buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputLocation.getPath(),
  548. CompilationResultDestinationManager.FILETYPE_RESOURCE);
  549. }
  550. } catch (FileNotFoundException fnfe) {
  551. IMessage msg = new Message("unable to copy resource to output folder: '" + filename + "' - reason: "
  552. + fnfe.getMessage(), IMessage.ERROR, null, new SourceLocation(srcLocation, 0));
  553. handler.handleMessage(msg);
  554. }
  555. }
  556. state.recordResource(filename, srcLocation);
  557. }
  558. /*
  559. * If we are writing to an output directory copy the manifest but only if we already have one
  560. */
  561. private void writeManifest() throws IOException {
  562. Manifest manifest = getWeaver().getManifest(false);
  563. if (manifest != null && zos == null) {
  564. File outputDir = buildConfig.getOutputDir();
  565. if (buildConfig.getCompilationResultDestinationManager() != null) {
  566. // Manifests are only written if we have a jar on the inpath. Therefore,
  567. // we write the manifest to the defaultOutputLocation because this is
  568. // where we sent the classes that were on the inpath
  569. outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
  570. }
  571. if (outputDir == null) {
  572. return;
  573. }
  574. File outputLocation = new File(outputDir, MANIFEST_NAME);
  575. OutputStream fos = FileUtil.makeOutputStream(outputLocation);
  576. manifest.write(fos);
  577. fos.close();
  578. if (buildConfig.getCompilationResultDestinationManager() != null) {
  579. buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputLocation.getPath(),
  580. CompilationResultDestinationManager.FILETYPE_RESOURCE);
  581. }
  582. }
  583. }
  584. private boolean acceptResource(String resourceName, boolean fromFile) {
  585. if ((resourceName.startsWith("CVS/")) || (resourceName.indexOf("/CVS/") != -1) || (resourceName.endsWith("/CVS"))
  586. || (resourceName.endsWith(".class")) || (resourceName.startsWith(".svn/"))
  587. || (resourceName.indexOf("/.svn/") != -1) || (resourceName.endsWith("/.svn")) ||
  588. // Do not copy manifests if either they are coming from a jar or we are writing to a jar
  589. (resourceName.toUpperCase().equals(MANIFEST_NAME) && (!fromFile || zos != null))) {
  590. return false;
  591. } else {
  592. return true;
  593. }
  594. }
  595. private void writeOutxmlFile() throws IOException {
  596. if (ignoreOutxml) {
  597. return;
  598. }
  599. String filename = buildConfig.getOutxmlName();
  600. // System.err.println("? AjBuildManager.writeOutxmlFile() outxml=" + filename);
  601. Map<File, List<String>> outputDirsAndAspects = findOutputDirsForAspects();
  602. Set<Map.Entry<File, List<String>>> outputDirs = outputDirsAndAspects.entrySet();
  603. for (Iterator<Map.Entry<File, List<String>>> iterator = outputDirs.iterator(); iterator.hasNext();) {
  604. Map.Entry<File, List<String>> entry = iterator.next();
  605. File outputDir = entry.getKey();
  606. List<String> aspects = entry.getValue();
  607. ByteArrayOutputStream baos = getOutxmlContents(aspects);
  608. if (zos != null) {
  609. ZipEntry newEntry = new ZipEntry(filename);
  610. zos.putNextEntry(newEntry);
  611. zos.write(baos.toByteArray());
  612. zos.closeEntry();
  613. } else {
  614. File outputFile = new File(outputDir, filename);
  615. OutputStream fos = FileUtil.makeOutputStream(outputFile);
  616. fos.write(baos.toByteArray());
  617. fos.close();
  618. if (buildConfig.getCompilationResultDestinationManager() != null) {
  619. buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputFile.getPath(),
  620. CompilationResultDestinationManager.FILETYPE_RESOURCE);
  621. }
  622. }
  623. }
  624. }
  625. private ByteArrayOutputStream getOutxmlContents(List aspectNames) {
  626. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  627. PrintStream ps = new PrintStream(baos);
  628. ps.println("<aspectj>");
  629. ps.println("<aspects>");
  630. if (aspectNames != null) {
  631. for (Iterator i = aspectNames.iterator(); i.hasNext();) {
  632. String name = (String) i.next();
  633. ps.println("<aspect name=\"" + name + "\"/>");
  634. }
  635. }
  636. ps.println("</aspects>");
  637. ps.println("</aspectj>");
  638. ps.println();
  639. ps.close();
  640. return baos;
  641. }
  642. /**
  643. * Returns a map where the keys are File objects corresponding to all the output directories and the values are a list of
  644. * aspects which are sent to that ouptut directory
  645. */
  646. private Map<File, List<String>> findOutputDirsForAspects() {
  647. Map<File, List<String>> outputDirsToAspects = new HashMap<File, List<String>>();
  648. Map<String, char[]> aspectNamesToFileNames = state.getAspectNamesToFileNameMap();
  649. if (buildConfig.getCompilationResultDestinationManager() == null
  650. || buildConfig.getCompilationResultDestinationManager().getAllOutputLocations().size() == 1) {
  651. // we only have one output directory...which simplifies things
  652. File outputDir = buildConfig.getOutputDir();
  653. if (buildConfig.getCompilationResultDestinationManager() != null) {
  654. outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
  655. }
  656. List<String> aspectNames = new ArrayList<String>();
  657. if (aspectNamesToFileNames != null) {
  658. Set<String> keys = aspectNamesToFileNames.keySet();
  659. for (String name : keys) {
  660. aspectNames.add(name);
  661. }
  662. }
  663. outputDirsToAspects.put(outputDir, aspectNames);
  664. } else {
  665. List outputDirs = buildConfig.getCompilationResultDestinationManager().getAllOutputLocations();
  666. for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) {
  667. File outputDir = (File) iterator.next();
  668. outputDirsToAspects.put(outputDir, new ArrayList<String>());
  669. }
  670. if (aspectNamesToFileNames != null) {
  671. Set<Map.Entry<String, char[]>> entrySet = aspectNamesToFileNames.entrySet();
  672. for (Iterator<Map.Entry<String, char[]>> iterator = entrySet.iterator(); iterator.hasNext();) {
  673. Map.Entry<String, char[]> entry = iterator.next();
  674. String aspectName = entry.getKey();
  675. char[] fileName = entry.getValue();
  676. File outputDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
  677. new File(new String(fileName)));
  678. if (!outputDirsToAspects.containsKey(outputDir)) {
  679. outputDirsToAspects.put(outputDir, new ArrayList<String>());
  680. }
  681. ((List) outputDirsToAspects.get(outputDir)).add(aspectName);
  682. }
  683. }
  684. }
  685. return outputDirsToAspects;
  686. }
  687. // public static void dumprels() {
  688. // IRelationshipMap irm = AsmManager.getDefault().getRelationshipMap();
  689. // int ctr = 1;
  690. // Set entries = irm.getEntries();
  691. // for (Iterator iter = entries.iterator(); iter.hasNext();) {
  692. // String hid = (String) iter.next();
  693. // List rels = irm.get(hid);
  694. // for (Iterator iterator = rels.iterator(); iterator.hasNext();) {
  695. // IRelationship ir = (IRelationship) iterator.next();
  696. // List targets = ir.getTargets();
  697. // for (Iterator iterator2 = targets.iterator();
  698. // iterator2.hasNext();
  699. // ) {
  700. // String thid = (String) iterator2.next();
  701. // System.err.println("Hid:"+(ctr++)+":(targets="+targets.size()+") "+hid+" ("+ir.getName()+") "+thid);
  702. // }
  703. // }
  704. // }
  705. // }
  706. /**
  707. * Responsible for managing the ASM model between builds. Contains the policy for maintaining the persistance of elements in the
  708. * model.
  709. *
  710. * This code is driven before each 'fresh' (batch) build to create a new model.
  711. */
  712. private void setupModel(AjBuildConfig config) {
  713. if (!(config.isEmacsSymMode() || config.isGenerateModelMode())) {
  714. return;
  715. }
  716. // AsmManager.setCreatingModel(config.isEmacsSymMode() || config.isGenerateModelMode());
  717. // if (!AsmManager.isCreatingModel())
  718. // return;
  719. CompilationResultDestinationManager crdm = config.getCompilationResultDestinationManager();
  720. AsmManager structureModel = AsmManager.createNewStructureModel(crdm == null ? Collections.EMPTY_MAP : crdm.getInpathMap());
  721. // AsmManager.getDefault().getRelationshipMap().clear();
  722. IHierarchy model = structureModel.getHierarchy();
  723. String rootLabel = "<root>";
  724. IProgramElement.Kind kind = IProgramElement.Kind.FILE_JAVA;
  725. if (buildConfig.getConfigFile() != null) {
  726. rootLabel = buildConfig.getConfigFile().getName();
  727. model.setConfigFile(buildConfig.getConfigFile().getAbsolutePath());
  728. kind = IProgramElement.Kind.FILE_LST;
  729. }
  730. model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList()));
  731. model.setFileMap(new HashMap<String, IProgramElement>());
  732. // setStructureModel(model);
  733. state.setStructureModel(structureModel);
  734. // state.setRelationshipMap(AsmManager.getDefault().getRelationshipMap());
  735. }
  736. //
  737. // private void dumplist(List l) {
  738. // System.err.println("---- "+l.size());
  739. // for (int i =0 ;i<l.size();i++) System.err.println(i+"\t "+l.get(i));
  740. // }
  741. // private void accumulateFileNodes(IProgramElement ipe,List store) {
  742. // if (ipe.getKind()==IProgramElement.Kind.FILE_JAVA ||
  743. // ipe.getKind()==IProgramElement.Kind.FILE_ASPECTJ) {
  744. // if (!ipe.getName().equals("<root>")) {
  745. // store.add(ipe);
  746. // return;
  747. // }
  748. // }
  749. // for (Iterator i = ipe.getChildren().iterator();i.hasNext();) {
  750. // accumulateFileNodes((IProgramElement)i.next(),store);
  751. // }
  752. // }
  753. // LTODO delegate to BcelWeaver?
  754. // XXX hideous, should not be Object
  755. public void setCustomMungerFactory(Object o) {
  756. customMungerFactory = (CustomMungerFactory) o;
  757. }
  758. public Object getCustomMungerFactory() {
  759. return customMungerFactory;
  760. }
  761. /** init only on initial batch compile? no file-specific options */
  762. private void initBcelWorld(IMessageHandler handler) throws IOException {
  763. List cp = buildConfig.getFullClasspath(); // pr145693
  764. // buildConfig.getBootclasspath();
  765. // cp.addAll(buildConfig.getClasspath());
  766. BcelWorld bcelWorld = new BcelWorld(cp, handler, null);
  767. bcelWorld.setBehaveInJava5Way(buildConfig.getBehaveInJava5Way());
  768. bcelWorld.setTiming(buildConfig.isTiming(), false);
  769. bcelWorld.setAddSerialVerUID(buildConfig.isAddSerialVerUID());
  770. bcelWorld.setXmlConfigured(buildConfig.isXmlConfigured());
  771. bcelWorld.setXmlFiles(buildConfig.getXmlFiles());
  772. bcelWorld.performExtraConfiguration(buildConfig.getXconfigurationInfo());
  773. bcelWorld.setTargetAspectjRuntimeLevel(buildConfig.getTargetAspectjRuntimeLevel());
  774. bcelWorld.setOptionalJoinpoints(buildConfig.getXJoinpoints());
  775. bcelWorld.setXnoInline(buildConfig.isXnoInline());
  776. bcelWorld.setXlazyTjp(buildConfig.isXlazyTjp());
  777. bcelWorld.setXHasMemberSupportEnabled(buildConfig.isXHasMemberEnabled());
  778. bcelWorld.setPinpointMode(buildConfig.isXdevPinpoint());
  779. bcelWorld.setErrorAndWarningThreshold(buildConfig.getOptions().errorThreshold.isSet(24), buildConfig.getOptions().warningThreshold.isSet(24));
  780. BcelWeaver bcelWeaver = new BcelWeaver(bcelWorld);
  781. bcelWeaver.setCustomMungerFactory(customMungerFactory);
  782. state.setWorld(bcelWorld);
  783. state.setWeaver(bcelWeaver);
  784. state.clearBinarySourceFiles();
  785. if (buildConfig.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT)) {
  786. bcelWorld.getLint().loadDefaultProperties();
  787. } else {
  788. bcelWorld.getLint().setAll(buildConfig.getLintMode());
  789. }
  790. if (buildConfig.getLintOptionsMap() != null) {
  791. bcelWorld.getLint().setFromMap(buildConfig.getLintOptionsMap());
  792. }
  793. if (buildConfig.getLintSpecFile() != null) {
  794. bcelWorld.getLint().setFromProperties(buildConfig.getLintSpecFile());
  795. }
  796. for (File f: buildConfig.getAspectpath()) {
  797. if (!f.exists()) {
  798. IMessage message = new Message("invalid aspectpath entry: " + f.getName(), null, true);
  799. handler.handleMessage(message);
  800. } else {
  801. bcelWeaver.addLibraryJarFile(f);
  802. }
  803. }
  804. // String lintMode = buildConfig.getLintMode();
  805. File outputDir = buildConfig.getOutputDir();
  806. if (outputDir == null && buildConfig.getCompilationResultDestinationManager() != null) {
  807. // send all output from injars and inpath to the default output location
  808. // (will also later send the manifest there too)
  809. outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
  810. }
  811. // ??? incremental issues
  812. for (File inJar : buildConfig.getInJars()) {
  813. List<UnwovenClassFile> unwovenClasses = bcelWeaver.addJarFile(inJar, outputDir, false);
  814. state.recordBinarySource(inJar.getPath(), unwovenClasses);
  815. }
  816. for (File inPathElement : buildConfig.getInpath()) {
  817. if (!inPathElement.isDirectory()) {
  818. // its a jar file on the inpath
  819. // the weaver method can actually handle dirs, but we don't call it, see next block
  820. List<UnwovenClassFile> unwovenClasses = bcelWeaver.addJarFile(inPathElement, outputDir, true);
  821. state.recordBinarySource(inPathElement.getPath(), unwovenClasses);
  822. } else {
  823. // add each class file in an in-dir individually, this gives us the best error reporting
  824. // (they are like 'source' files then), and enables a cleaner incremental treatment of
  825. // class file changes in indirs.
  826. File[] binSrcs = FileUtil.listFiles(inPathElement, binarySourceFilter);
  827. for (int j = 0; j < binSrcs.length; j++) {
  828. UnwovenClassFile ucf = bcelWeaver.addClassFile(binSrcs[j], inPathElement, outputDir);
  829. List<UnwovenClassFile> ucfl = new ArrayList<UnwovenClassFile>();
  830. ucfl.add(ucf);
  831. state.recordBinarySource(binSrcs[j].getPath(), ucfl);
  832. }
  833. }
  834. }
  835. bcelWeaver.setReweavableMode(buildConfig.isXNotReweavable());
  836. // check for org.aspectj.runtime.JoinPoint
  837. ResolvedType joinPoint = bcelWorld.resolve("org.aspectj.lang.JoinPoint");
  838. if (joinPoint.isMissing()) {
  839. IMessage message = new Message(
  840. "classpath error: unable to find org.aspectj.lang.JoinPoint (check that aspectjrt.jar is in your classpath)",
  841. null, true);
  842. handler.handleMessage(message);
  843. }
  844. }
  845. public World getWorld() {
  846. return getBcelWorld();
  847. }
  848. // void addAspectClassFilesToWeaver(List addedClassFiles) throws IOException {
  849. // for (Iterator i = addedClassFiles.iterator(); i.hasNext();) {
  850. // UnwovenClassFile classFile = (UnwovenClassFile) i.next();
  851. // getWeaver().addClassFile(classFile);
  852. // }
  853. // }
  854. public FileSystem getLibraryAccess(String[] classpaths, String[] filenames) {
  855. String defaultEncoding = buildConfig.getOptions().defaultEncoding;
  856. if ("".equals(defaultEncoding)) {//$NON-NLS-1$
  857. defaultEncoding = null;
  858. }
  859. // Bug 46671: We need an array as long as the number of elements in the classpath - *even though* not every
  860. // element of the classpath is likely to be a directory. If we ensure every element of the array is set to
  861. // only look for BINARY, then we make sure that for any classpath element that is a directory, we won't build
  862. // a classpathDirectory object that will attempt to look for source when it can't find binary.
  863. // int[] classpathModes = new int[classpaths.length];
  864. // for (int i =0 ;i<classpaths.length;i++) classpathModes[i]=ClasspathDirectory.BINARY;
  865. FileSystem nameEnvironment = null;
  866. // TODO J9 The compiler likes to work in terms of checked classpath objects - these will be different
  867. // depending on where the code came from (classpath, modulepath). If working with just the raw
  868. // 'classpaths' object it isn't recording where the code came from. This will be an issue later for
  869. // weaving, the distinction will need to be maintained for proper 'module aware/respecting' weaving.
  870. if (buildConfig.getCheckedClasspaths() == null) {
  871. nameEnvironment = new FileSystem(classpaths, filenames, defaultEncoding, ClasspathLocation.BINARY, null);
  872. } else {
  873. nameEnvironment = new FileSystem(buildConfig.getCheckedClasspaths(), filenames, false, null);
  874. }
  875. nameEnvironment.module = buildConfig.getModuleDesc();
  876. return nameEnvironment;
  877. }
  878. public IProblemFactory getProblemFactory() {
  879. return new DefaultProblemFactory(Locale.getDefault());
  880. }
  881. /*
  882. * Build the set of compilation source units
  883. */
  884. public CompilationUnit[] getCompilationUnits(String[] filenames) {
  885. int fileCount = filenames.length;
  886. CompilationUnit[] units = new CompilationUnit[fileCount];
  887. // HashtableOfObject knownFileNames = new HashtableOfObject(fileCount);
  888. String defaultEncoding = buildConfig.getOptions().defaultEncoding;
  889. if ("".equals(defaultEncoding)) {//$NON-NLS-1$
  890. defaultEncoding = null;
  891. }
  892. CompilationUnit moduleCU = null;
  893. // TODO building with multiple module-infos?
  894. int moduleIndex = -1;
  895. IModule moduleDesc = buildConfig.getModuleDesc();
  896. String moduleName = moduleDesc == null? null: new String(moduleDesc.name());
  897. for (int i=0;i<fileCount;i++) {
  898. if (filenames[i].endsWith("module-info.java")) {
  899. moduleIndex = i;
  900. moduleCU = new CompilationUnit(null, filenames[i], defaultEncoding, null, false, moduleName);
  901. }
  902. }
  903. for (int i = 0; i < fileCount; i++) {
  904. // units[i] = new CompilationUnit(null, filenames[i], defaultEncoding);
  905. if (i == moduleIndex) {
  906. units[i] = moduleCU;
  907. } else {
  908. units[i] = new CompilationUnit(null, filenames[i], defaultEncoding, null, false, moduleName);
  909. // With Java 10 changes the modulebinding is fetched from the rootenvironment
  910. // this.moduleBinding = rootEnvironment.getModule(this.module);
  911. // rather than using the moduleCU:
  912. // if (this.modCU != null)
  913. // return this.moduleBinding = this.modCU.module(rootEnvironment);
  914. // units[i].setModule(moduleCU);
  915. }
  916. // new CompilationUnit(null, fileName, encoding, this.destinationPaths[i],
  917. // shouldIgnoreOptionalProblems(this.ignoreOptionalProblemsFromFolders, fileName.toCharArray()),
  918. // this.modNames[i]);
  919. }
  920. return units;
  921. }
  922. public String extractDestinationPathFromSourceFile(CompilationResult result) {
  923. ICompilationUnit compilationUnit = result.compilationUnit;
  924. if (compilationUnit != null) {
  925. char[] fileName = compilationUnit.getFileName();
  926. int lastIndex = CharOperation.lastIndexOf(java.io.File.separatorChar, fileName);
  927. if (lastIndex == -1) {
  928. return System.getProperty("user.dir"); //$NON-NLS-1$
  929. }
  930. return new String(CharOperation.subarray(fileName, 0, lastIndex));
  931. }
  932. return System.getProperty("user.dir"); //$NON-NLS-1$
  933. }
  934. public void performCompilation(Collection<File> files) {
  935. if (progressListener != null) {
  936. compiledCount = 0;
  937. sourceFileCount = files.size();
  938. progressListener.setText("compiling source files");
  939. }
  940. // Translate from strings to File objects
  941. String[] filenames = new String[files.size()];
  942. int idx = 0;
  943. for (Iterator<File> fIterator = files.iterator(); fIterator.hasNext();) {
  944. File f = fIterator.next();
  945. filenames[idx++] = f.getPath();
  946. }
  947. environment = state.getNameEnvironment();
  948. boolean environmentNeedsRebuilding = false;
  949. // Might be a bit too cautious, but let us see how it goes
  950. if (buildConfig.getChanged() != AjBuildConfig.NO_CHANGES) {
  951. environmentNeedsRebuilding = true;
  952. }
  953. if (environment == null || environmentNeedsRebuilding) {
  954. List<String> cps = buildConfig.getFullClasspath();
  955. Dump.saveFullClasspath(cps);
  956. String[] classpaths = new String[cps.size()];
  957. for (int i = 0; i < cps.size(); i++) {
  958. classpaths[i] = cps.get(i);
  959. }
  960. FileSystem fileSystem = getLibraryAccess(classpaths, filenames);
  961. environment = new StatefulNameEnvironment(fileSystem, state.getClassNameToFileMap(), state);
  962. state.setFileSystem(fileSystem);
  963. state.setNameEnvironment(environment);
  964. } else {
  965. ((StatefulNameEnvironment) environment).update(state.getClassNameToFileMap(), state.deltaAddedClasses);
  966. state.deltaAddedClasses.clear();
  967. }
  968. org.aspectj.ajdt.internal.compiler.CompilerAdapter.setCompilerAdapterFactory(this);
  969. final Map<String, String> settings = buildConfig.getOptions().getMap();
  970. final BuildArgParser bMain = buildConfig.getBuildArgParser();
  971. final org.aspectj.org.eclipse.jdt.internal.compiler.Compiler compiler = new org.aspectj.org.eclipse.jdt.internal.compiler.Compiler(
  972. environment, DefaultErrorHandlingPolicies.proceedWithAllProblems(), settings,
  973. getBatchRequestor(), getProblemFactory());
  974. bMain.compilerOptions = compiler.options;
  975. bMain.batchCompiler = compiler;
  976. bMain.initializeAnnotationProcessorManager();
  977. compiler.options.produceReferenceInfo = true; // TODO turn off when not needed
  978. if (bMain.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_6
  979. && bMain.compilerOptions.processAnnotations) {
  980. // need this too?
  981. // if (bMain.checkVMVersion(ClassFileConstants.JDK1_6)) {
  982. // initializeAnnotationProcessorManager();
  983. // if (this.classNames != null) {
  984. // this.batchCompiler.setBinaryTypes(processClassNames(this.batchCompiler.lookupEnvironment));
  985. // }
  986. // } else {
  987. // // report a warning
  988. // this.logger.logIncorrectVMVersionForAnnotationProcessing();
  989. // }
  990. if (bMain.checkVMVersion(ClassFileConstants.JDK9)) {
  991. try {
  992. bMain.initRootModules(bMain.batchCompiler.lookupEnvironment, state.getFileSystem());
  993. } catch (IllegalArgumentException iae) {
  994. ISourceLocation location = null;
  995. if (buildConfig.getConfigFile() != null) {
  996. location = new SourceLocation(buildConfig.getConfigFile(), 0);
  997. }
  998. IMessage m = new Message(iae.getMessage(), IMessage.ERROR, null, location);
  999. handler.handleMessage(m);
  1000. }
  1001. }
  1002. }
  1003. try {
  1004. compiler.compile(getCompilationUnits(filenames));
  1005. } catch (OperationCanceledException oce) {
  1006. handler.handleMessage(new Message("build cancelled:" + oce.getMessage(), IMessage.WARNING, null, null));
  1007. }
  1008. // cleanup
  1009. org.aspectj.ajdt.internal.compiler.CompilerAdapter.setCompilerAdapterFactory(null);
  1010. AnonymousClassPublisher.aspectOf().setAnonymousClassCreationListener(null);
  1011. environment.cleanup();
  1012. // environment = null;
  1013. }
  1014. public void cleanupEnvironment() {
  1015. if (environment != null) {
  1016. environment.cleanup();
  1017. environment = null;
  1018. // le = null;
  1019. }
  1020. }
  1021. /*
  1022. * Answer the component to which will be handed back compilation results from the compiler
  1023. */
  1024. public IIntermediateResultsRequestor getInterimResultRequestor() {
  1025. return new IIntermediateResultsRequestor() {
  1026. @Override
  1027. public void acceptResult(InterimCompilationResult result) {
  1028. if (progressListener != null) {
  1029. compiledCount++;
  1030. progressListener.setProgress((compiledCount / 2.0) / sourceFileCount);
  1031. progressListener.setText("compiled: " + result.fileName());
  1032. }
  1033. state.noteResult(result);
  1034. if (progressListener != null && progressListener.isCancelledRequested()) {
  1035. throw new AbortCompilation(true, new OperationCanceledException("Compilation cancelled as requested"));
  1036. }
  1037. }
  1038. };
  1039. }
  1040. public ICompilerRequestor getBatchRequestor() {
  1041. return new ICompilerRequestor() {
  1042. @Override
  1043. public void acceptResult(CompilationResult unitResult) {
  1044. // end of compile, must now write the results to the output destination
  1045. // this is either a jar file or a file in a directory
  1046. boolean hasErrors = unitResult.hasErrors();
  1047. if (!hasErrors || proceedOnError()) {
  1048. Collection<ClassFile> classFiles = unitResult.compiledTypes.values();
  1049. boolean shouldAddAspectName = (buildConfig.getOutxmlName() != null);
  1050. for (Iterator<ClassFile> iter = classFiles.iterator(); iter.hasNext();) {
  1051. ClassFile classFile = iter.next();
  1052. String filename = new String(classFile.fileName());
  1053. String classname = filename.replace('/', '.');
  1054. filename = filename.replace('/', File.separatorChar) + ".class";
  1055. try {
  1056. if (buildConfig.getOutputJar() == null) {
  1057. String outfile = writeDirectoryEntry(unitResult, classFile, filename);
  1058. getWorld().classWriteEvent(classFile.getCompoundName());
  1059. if (environmentSupportsIncrementalCompilation) {
  1060. if (!classname.endsWith("$ajcMightHaveAspect")) {
  1061. ResolvedType type = getBcelWorld().resolve(classname);
  1062. if (type.isAspect()) {
  1063. state.recordAspectClassFile(outfile);
  1064. }
  1065. }
  1066. }
  1067. } else {
  1068. writeZipEntry(classFile, filename);
  1069. }
  1070. if (shouldAddAspectName && !classname.endsWith("$ajcMightHaveAspect")) {
  1071. addAspectName(classname, unitResult.getFileName());
  1072. }
  1073. } catch (IOException ex) {
  1074. IMessage message = EclipseAdapterUtils.makeErrorMessage(new String(unitResult.fileName),
  1075. CANT_WRITE_RESULT, ex);
  1076. handler.handleMessage(message);
  1077. }
  1078. }
  1079. state.noteNewResult(unitResult);
  1080. unitResult.compiledTypes.clear(); // free up references to AjClassFile instances
  1081. }
  1082. if (unitResult.hasProblems() || unitResult.hasTasks()) {
  1083. IProblem[] problems = unitResult.getAllProblems();
  1084. for (int i = 0; i < problems.length; i++) {
  1085. IMessage message = EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problems[i], getBcelWorld(),
  1086. progressListener);
  1087. handler.handleMessage(message);
  1088. }
  1089. }
  1090. }
  1091. private String writeDirectoryEntry(CompilationResult unitResult, ClassFile classFile, String filename)
  1092. throws IOException {
  1093. File destinationPath = buildConfig.getOutputDir();
  1094. if (buildConfig.getCompilationResultDestinationManager() != null) {
  1095. destinationPath = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
  1096. new File(new String(unitResult.fileName)));
  1097. }
  1098. String outFile;
  1099. if (destinationPath == null) {
  1100. outFile = new File(filename).getName();
  1101. outFile = new File(extractDestinationPathFromSourceFile(unitResult), outFile).getPath();
  1102. } else {
  1103. outFile = new File(destinationPath, filename).getPath();
  1104. }
  1105. try {
  1106. BufferedOutputStream os = FileUtil.makeOutputStream(new File(outFile));
  1107. os.write(classFile.getBytes());
  1108. os.close();
  1109. } catch (FileNotFoundException fnfe) {
  1110. IMessage msg = new Message("unable to write out class file: '" + filename + "' - reason: " + fnfe.getMessage(),
  1111. IMessage.ERROR, null, new SourceLocation(new File(outFile), 0));
  1112. handler.handleMessage(msg);
  1113. }
  1114. if (buildConfig.getCompilationResultDestinationManager() != null) {
  1115. buildConfig.getCompilationResultDestinationManager().reportFileWrite(outFile,
  1116. CompilationResultDestinationManager.FILETYPE_CLASS);
  1117. }
  1118. return outFile;
  1119. }
  1120. private void writeZipEntry(ClassFile classFile, String name) throws IOException {
  1121. name = name.replace(File.separatorChar, '/');
  1122. ZipEntry newEntry = new ZipEntry(name); // ??? get compression scheme right
  1123. zos.putNextEntry(newEntry);
  1124. zos.write(classFile.getBytes());
  1125. zos.closeEntry();
  1126. }
  1127. private void addAspectName(String name, char[] fileContainingAspect) {
  1128. BcelWorld world = getBcelWorld();
  1129. ResolvedType type = world.resolve(name);
  1130. // System.err.println("? writeAspectName() type=" + type);
  1131. if (type.isAspect()) {
  1132. if (state.getAspectNamesToFileNameMap() == null) {
  1133. state.initializeAspectNamesToFileNameMap();
  1134. }
  1135. if (!state.getAspectNamesToFileNameMap().containsKey(name)) {
  1136. state.getAspectNamesToFileNameMap().put(name, fileContainingAspect);
  1137. }
  1138. }
  1139. }
  1140. };
  1141. }
  1142. protected boolean proceedOnError() {
  1143. return buildConfig.getProceedOnError();
  1144. }
  1145. // public void noteClassFiles(AjCompiler.InterimResult result) {
  1146. // if (result == null) return;
  1147. // CompilationResult unitResult = result.result;
  1148. // String sourceFileName = result.fileName();
  1149. // if (!(unitResult.hasErrors() && !proceedOnError())) {
  1150. // List unwovenClassFiles = new ArrayList();
  1151. // Enumeration classFiles = unitResult.compiledTypes.elements();
  1152. // while (classFiles.hasMoreElements()) {
  1153. // ClassFile classFile = (ClassFile) classFiles.nextElement();
  1154. // String filename = new String(classFile.fileName());
  1155. // filename = filename.replace('/', File.separatorChar) + ".class";
  1156. //
  1157. // File destinationPath = buildConfig.getOutputDir();
  1158. // if (destinationPath == null) {
  1159. // filename = new File(filename).getName();
  1160. // filename = new File(extractDestinationPathFromSourceFile(unitResult), filename).getPath();
  1161. // } else {
  1162. // filename = new File(destinationPath, filename).getPath();
  1163. // }
  1164. //
  1165. // //System.out.println("classfile: " + filename);
  1166. // unwovenClassFiles.add(new UnwovenClassFile(filename, classFile.getBytes()));
  1167. // }
  1168. // state.noteClassesFromFile(unitResult, sourceFileName, unwovenClassFiles);
  1169. // // System.out.println("file: " + sourceFileName);
  1170. // // for (int i=0; i < unitResult.simpleNameReferences.length; i++) {
  1171. // // System.out.println("simple: " + new String(unitResult.simpleNameReferences[i]));
  1172. // // }
  1173. // // for (int i=0; i < unitResult.qualifiedReferences.length; i++) {
  1174. // // System.out.println("qualified: " +
  1175. // // new String(CharOperation.concatWith(unitResult.qualifiedReferences[i], '/')));
  1176. // // }
  1177. // } else {
  1178. // state.noteClassesFromFile(null, sourceFileName, Collections.EMPTY_LIST);
  1179. // }
  1180. // }
  1181. //
  1182. private void setBuildConfig(AjBuildConfig buildConfig) {
  1183. this.buildConfig = buildConfig;
  1184. if (!this.environmentSupportsIncrementalCompilation) {
  1185. this.environmentSupportsIncrementalCompilation = (buildConfig.isIncrementalMode() || buildConfig
  1186. .isIncrementalFileMode());
  1187. }
  1188. handler.reset();
  1189. }
  1190. String makeClasspathString(AjBuildConfig buildConfig) {
  1191. if (buildConfig == null || buildConfig.getFullClasspath() == null) {
  1192. return "";
  1193. }
  1194. StringBuffer buf = new StringBuffer();
  1195. boolean first = true;
  1196. for (Iterator it = buildConfig.getFullClasspath().iterator(); it.hasNext();) {
  1197. if (first) {
  1198. first = false;
  1199. } else {
  1200. buf.append(File.pathSeparator);
  1201. }
  1202. buf.append(it.next().toString());
  1203. }
  1204. return buf.toString();
  1205. }
  1206. /**
  1207. * This will return null if aspectjrt.jar is present and has the correct version. Otherwise it will return a string message
  1208. * indicating the problem.
  1209. */
  1210. private String checkRtJar(AjBuildConfig buildConfig) {
  1211. // omitting dev info
  1212. if (Version.text.equals(Version.DEVELOPMENT)) {
  1213. // in the development version we can't do this test usefully
  1214. // MessageUtil.info(holder, "running development version of aspectj compiler");
  1215. return null;
  1216. }
  1217. if (buildConfig == null || buildConfig.getFullClasspath() == null) {
  1218. return "no classpath specified";
  1219. }
  1220. String ret = null;
  1221. for (Iterator it = buildConfig.getFullClasspath().iterator(); it.hasNext();) {
  1222. File p = new File((String) it.next());
  1223. // pr112830, allow variations on aspectjrt.jar of the form aspectjrtXXXXXX.jar
  1224. if (p.isFile() && p.getName().startsWith("aspectjrt") && p.getName().endsWith(".jar")) {
  1225. try {
  1226. String version = null;
  1227. Manifest manifest = new JarFile(p).getManifest();
  1228. if (manifest == null) {
  1229. ret = "no manifest found in " + p.getAbsolutePath() + ", expected " + Version.text;
  1230. continue;
  1231. }
  1232. Attributes attr = manifest.getAttributes("org/aspectj/lang/");
  1233. if (null != attr) {
  1234. version = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
  1235. if (null != version) {
  1236. version = version.trim();
  1237. }
  1238. }
  1239. // assume that users of development aspectjrt.jar know what they're doing
  1240. if (Version.DEVELOPMENT.equals(version)) {
  1241. // MessageUtil.info(holder,
  1242. // "running with development version of aspectjrt.jar in " +
  1243. // p.getAbsolutePath());
  1244. return null;
  1245. } else if (!Version.text.equals(version)) {
  1246. ret = "bad version number found in " + p.getAbsolutePath() + " expected " + Version.text + " found "
  1247. + version;
  1248. continue;
  1249. }
  1250. } catch (IOException ioe) {
  1251. ret = "bad jar file found in " + p.getAbsolutePath() + " error: " + ioe;
  1252. }
  1253. return null; // this is the "OK" return value!
  1254. } else if (p.isFile() && p.getName().indexOf("org.aspectj.runtime") != -1) {
  1255. // likely to be a variant from the springsource bundle repo b272591
  1256. return null;
  1257. } else {
  1258. // might want to catch other classpath errors
  1259. }
  1260. }
  1261. if (ret != null) {
  1262. return ret; // last error found in potentially matching jars...
  1263. }
  1264. return "couldn't find aspectjrt.jar on classpath, checked: " + makeClasspathString(buildConfig);
  1265. }
  1266. @Override
  1267. public String toString() {
  1268. StringBuffer buf = new StringBuffer();
  1269. buf.append("AjBuildManager(");
  1270. buf.append(")");
  1271. return buf.toString();
  1272. }
  1273. //
  1274. // public void setStructureModel(IHierarchy structureModel) {
  1275. // this.structureModel = structureModel;
  1276. // }
  1277. /**
  1278. * Returns null if there is no structure model
  1279. */
  1280. public AsmManager getStructureModel() {
  1281. return (state == null ? null : state.getStructureModel());
  1282. }
  1283. public IProgressListener getProgressListener() {
  1284. return progressListener;
  1285. }
  1286. public void setProgressListener(IProgressListener progressListener) {
  1287. this.progressListener = progressListener;
  1288. }
  1289. /*
  1290. * (non-Javadoc)
  1291. *
  1292. * @see org.aspectj.ajdt.internal.compiler.AjCompiler.IOutputClassFileNameProvider#getOutputClassFileName(char[])
  1293. */
  1294. @Override
  1295. public String getOutputClassFileName(char[] eclipseClassFileName, CompilationResult result) {
  1296. String filename = new String(eclipseClassFileName);
  1297. filename = filename.replace('/', File.separatorChar) + ".class";
  1298. File destinationPath = buildConfig.getOutputDir();
  1299. if (buildConfig.getCompilationResultDestinationManager() != null) {
  1300. File f = new File(new String(result.getFileName()));
  1301. destinationPath = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(f);
  1302. }
  1303. String outFile;
  1304. if (destinationPath == null) {
  1305. outFile = new File(filename).getName();
  1306. outFile = new File(extractDestinationPathFromSourceFile(result), outFile).getPath();
  1307. } else {
  1308. outFile = new File(destinationPath, filename).getPath();
  1309. }
  1310. return outFile;
  1311. }
  1312. /*
  1313. * (non-Javadoc)
  1314. *
  1315. * @see org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory#getAdapter(org.eclipse.jdt.internal.compiler.Compiler)
  1316. */
  1317. @Override
  1318. public ICompilerAdapter getAdapter(org.aspectj.org.eclipse.jdt.internal.compiler.Compiler forCompiler) {
  1319. // complete compiler config and return a suitable adapter...
  1320. populateCompilerOptionsFromLintSettings(forCompiler);
  1321. AjProblemReporter pr = new AjProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), forCompiler.options,
  1322. getProblemFactory());
  1323. forCompiler.problemReporter = pr;
  1324. AjLookupEnvironment le = new AjLookupEnvironment(forCompiler, forCompiler.options, pr, environment);
  1325. EclipseFactory factory = new EclipseFactory(le, this);
  1326. le.factory = factory;
  1327. pr.factory = factory;
  1328. forCompiler.lookupEnvironment = le;
  1329. forCompiler.parser = new Parser(pr, forCompiler.options.parseLiteralExpressionsAsConstants);
  1330. if (getBcelWorld().shouldPipelineCompilation()) {
  1331. IMessage message = MessageUtil.info("Pipelining compilation");
  1332. handler.handleMessage(message);
  1333. return new AjPipeliningCompilerAdapter(forCompiler, batchCompile, getBcelWorld(), getWeaver(), factory,
  1334. getInterimResultRequestor(), progressListener,
  1335. this, // IOutputFilenameProvider
  1336. this, // IBinarySourceProvider
  1337. state.getBinarySourceMap(), buildConfig.isTerminateAfterCompilation(), buildConfig.getProceedOnError(),
  1338. buildConfig.isNoAtAspectJAnnotationProcessing(), buildConfig.isMakeReflectable(), state);
  1339. } else {
  1340. return new AjCompilerAdapter(forCompiler, batchCompile, getBcelWorld(), getWeaver(), factory,
  1341. getInterimResultRequestor(), progressListener,
  1342. this, // IOutputFilenameProvider
  1343. this, // IBinarySourceProvider
  1344. state.getBinarySourceMap(), buildConfig.isTerminateAfterCompilation(), buildConfig.getProceedOnError(),
  1345. buildConfig.isNoAtAspectJAnnotationProcessing(), buildConfig.isMakeReflectable(), state);
  1346. }
  1347. }
  1348. /**
  1349. * Some AspectJ lint options need to be known about in the compiler. This is how we pass them over...
  1350. *
  1351. * @param forCompiler
  1352. */
  1353. private void populateCompilerOptionsFromLintSettings(org.aspectj.org.eclipse.jdt.internal.compiler.Compiler forCompiler) {
  1354. BcelWorld world = this.state.getBcelWorld();
  1355. IMessage.Kind swallowedExceptionKind = world.getLint().swallowedExceptionInCatchBlock.getKind();
  1356. Map optionsMap = new HashMap();
  1357. optionsMap.put(CompilerOptions.OPTION_ReportSwallowedExceptionInCatchBlock, swallowedExceptionKind == null ? "ignore"
  1358. : swallowedExceptionKind.toString());
  1359. forCompiler.options.set(optionsMap);
  1360. }
  1361. /*
  1362. * (non-Javadoc)
  1363. *
  1364. * @see org.aspectj.ajdt.internal.compiler.IBinarySourceProvider#getBinarySourcesForThisWeave()
  1365. */
  1366. @Override
  1367. public Map<String, List<UnwovenClassFile>> getBinarySourcesForThisWeave() {
  1368. return binarySourcesForTheNextCompile;
  1369. }
  1370. public static AsmHierarchyBuilder getAsmHierarchyBuilder() {
  1371. return asmHierarchyBuilder;
  1372. }
  1373. /**
  1374. * Override the the default hierarchy builder.
  1375. */
  1376. public static void setAsmHierarchyBuilder(AsmHierarchyBuilder newBuilder) {
  1377. asmHierarchyBuilder = newBuilder;
  1378. }
  1379. public AjState getState() {
  1380. return state;
  1381. }
  1382. public void setState(AjState buildState) {
  1383. state = buildState;
  1384. }
  1385. private static class AjBuildContexFormatter implements ContextFormatter {
  1386. @Override
  1387. public String formatEntry(int phaseId, Object data) {
  1388. StringBuffer sb = new StringBuffer();
  1389. if (phaseId == CompilationAndWeavingContext.BATCH_BUILD) {
  1390. sb.append("batch building ");
  1391. } else {
  1392. sb.append("incrementally building ");
  1393. }
  1394. AjBuildConfig config = (AjBuildConfig) data;
  1395. List classpath = config.getClasspath();
  1396. sb.append("with classpath: ");
  1397. for (Iterator iter = classpath.iterator(); iter.hasNext();) {
  1398. sb.append(iter.next().toString());
  1399. sb.append(File.pathSeparator);
  1400. }
  1401. return sb.toString();
  1402. }
  1403. }
  1404. public boolean wasFullBuild() {
  1405. return wasFullBuild;
  1406. }
  1407. }