From: aclement Date: Mon, 6 Sep 2004 15:13:46 +0000 (+0000) Subject: Part of fix for AJDT bug 72671 X-Git-Tag: V1_2_1~69 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d1551bda9b14c6c2035e0c8df6f09bf4634041de;p=aspectj.git Part of fix for AJDT bug 72671 Bootclasspath specification for compiling is not possible --- diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java index 26cfe8894..b1b761356 100644 --- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java +++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java @@ -495,7 +495,6 @@ public class CompilerAdapter { * @@ -505,7 +504,8 @@ public class CompilerAdapter { */ private void configureProjectOptions( AjBuildConfig config, ProjectPropertiesAdapter properties ) { // XXX no error handling in copying project properties - String propcp = properties.getClasspath(); // XXX omitting bootclasspath... + // Handle regular classpath + String propcp = properties.getClasspath(); if (!LangUtil.isEmpty(propcp)) { StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator); List configClasspath = config.getClasspath(); @@ -524,7 +524,30 @@ public class CompilerAdapter { Ajde.getDefault().logEvent("building with classpath: " + both); } } - + + // Handle boot classpath + propcp = properties.getBootClasspath(); + if (!LangUtil.isEmpty(propcp)) { + StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator); + List configClasspath = config.getBootclasspath(); + ArrayList toAdd = new ArrayList(); + while (st.hasMoreTokens()) { + String entry = st.nextToken(); + if (!configClasspath.contains(entry)) { + toAdd.add(entry); + } + } + if (0 < toAdd.size()) { + ArrayList both = new ArrayList(configClasspath.size() + toAdd.size()); + both.addAll(configClasspath); + both.addAll(toAdd); + config.setBootclasspath(both); + Ajde.getDefault().logEvent("building with boot classpath: " + both); + } + } + + + // set outputdir and outputjar only if both not set if ((null == config.getOutputDir() && (null == config.getOutputJar()))) { String outPath = properties.getOutputPath(); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java index c8888e8a5..37ed3dbd4 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -177,6 +177,7 @@ public class BuildArgParser extends Main { if (setClasspath) { buildConfig.setClasspath(getClasspath(parser)); + buildConfig.setBootclasspath(getBootclasspath(parser)); } if (incrementalMode @@ -284,6 +285,16 @@ public class BuildArgParser extends Main { } + public List getBootclasspath(AjcConfigParser parser) { + List ret = new ArrayList(); + + if (parser.bootclasspath == null) { + addClasspath(System.getProperty("sun.boot.class.path", ""), ret); + } else { + addClasspath(parser.bootclasspath, ret); + } + return ret; + } /** * If the classpath is not set, we use the environment's java.class.path, but remove * the aspectjtools.jar entry from that list in order to prevent wierd bootstrap issues @@ -292,11 +303,11 @@ public class BuildArgParser extends Main { public List getClasspath(AjcConfigParser parser) { List ret = new ArrayList(); - if (parser.bootclasspath == null) { - addClasspath(System.getProperty("sun.boot.class.path", ""), ret); - } else { - addClasspath(parser.bootclasspath, ret); - } +// if (parser.bootclasspath == null) { +// addClasspath(System.getProperty("sun.boot.class.path", ""), ret); +// } else { +// addClasspath(parser.bootclasspath, ret); +// } String extdirs = parser.extdirs; if (extdirs == null) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java index 34474602d..c798a7dcc 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java @@ -31,7 +31,7 @@ import org.aspectj.util.FileUtil; * All configuration information needed to run the AspectJ compiler. * Compiler options (as opposed to path information) are held in an AjCompilerOptions instance */ -public class AjBuildConfig { // XXX needs bootclasspath? +public class AjBuildConfig { private boolean shouldProceed = true; @@ -50,6 +50,7 @@ public class AjBuildConfig { // XXX needs bootclasspath? private Map/*String->File*/ sourcePathResources = new HashMap(); private List/*File*/ aspectpath = new ArrayList(); private List/*String*/ classpath = new ArrayList(); + private List/*String*/ bootclasspath = new ArrayList(); private File configFile; private String lintMode = AJLINT_DEFAULT; @@ -137,7 +138,7 @@ public class AjBuildConfig { // XXX needs bootclasspath? } /** - * This includes all entries from -bootclasspath, -extdirs, -classpath, + * This does not include -bootclasspath but includes -extdirs and -classpath */ public List getClasspath() { // XXX setters don't respect javadoc contract... return classpath; @@ -146,6 +147,14 @@ public class AjBuildConfig { // XXX needs bootclasspath? public void setClasspath(List classpath) { this.classpath = classpath; } + + public List getBootclasspath() { + return bootclasspath; + } + + public void setBootclasspath(List bootclasspath) { + this.bootclasspath = bootclasspath; + } public File getOutputJar() { return outputJar; @@ -225,12 +234,12 @@ public class AjBuildConfig { // XXX needs bootclasspath? } /** - * @return List (String) classpath of injars, inpath, aspectpath - * entries, specified classpath (bootclasspath, extdirs, and - * classpath), and output dir or jar + * @return List (String) classpath of bootclasspath, injars, inpath, aspectpath + * entries, specified classpath (extdirs, and classpath), and output dir or jar */ public List getFullClasspath() { List full = new ArrayList(); + full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath? for (Iterator i = inJars.iterator(); i.hasNext(); ) { full.add(((File)i.next()).getAbsolutePath()); } @@ -238,7 +247,7 @@ public class AjBuildConfig { // XXX needs bootclasspath? full.add(((File)i.next()).getAbsolutePath()); } for (Iterator i = aspectpath.iterator(); i.hasNext(); ) { - full.add(((File)i.next()).getAbsolutePath()); + full.add(((File)i.next()).getAbsolutePath()); } full.addAll(getClasspath()); // if (null != outputDir) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 2161ee47e..6ff844760 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -485,7 +485,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc /** init only on initial batch compile? no file-specific options */ private void initBcelWorld(IMessageHandler handler) throws IOException { - bcelWorld = new BcelWorld(buildConfig.getClasspath(), handler, null); + List cp = buildConfig.getBootclasspath(); + cp.addAll(buildConfig.getClasspath()); + bcelWorld = new BcelWorld(cp, handler, null); bcelWorld.setXnoInline(buildConfig.isXnoInline()); bcelWorld.setXlazyTjp(buildConfig.isXlazyTjp()); bcelWeaver = new BcelWeaver(bcelWorld); @@ -825,10 +827,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc } String makeClasspathString() { - if (buildConfig == null || buildConfig.getClasspath() == null) return ""; + if (buildConfig == null || buildConfig.getFullClasspath() == null) return ""; StringBuffer buf = new StringBuffer(); boolean first = true; - for (Iterator it = buildConfig.getClasspath().iterator(); it.hasNext(); ) { + for (Iterator it = buildConfig.getFullClasspath().iterator(); it.hasNext(); ) { if (first) { first = false; } else { buf.append(File.pathSeparator); } buf.append(it.next().toString()); @@ -849,8 +851,8 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc return null; } - if (buildConfig == null || buildConfig.getClasspath() == null) return "no classpath specified"; - for (Iterator it = buildConfig.getClasspath().iterator(); it.hasNext(); ) { + if (buildConfig == null || buildConfig.getFullClasspath() == null) return "no classpath specified"; + for (Iterator it = buildConfig.getFullClasspath().iterator(); it.hasNext(); ) { File p = new File( (String)it.next() ); if (p.isFile() && p.getName().equals("aspectjrt.jar")) { diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java index ed6eb66f6..252a13ab3 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java @@ -112,7 +112,7 @@ public class BuildArgParserTestCase extends TestCase { public void testPathResolutionFromConfigArgs() { String FILE_PATH = "@" + TEST_DIR + "configWithClasspathExtdirsBootCPArgs.lst"; AjBuildConfig config = genBuildConfig(new String[] { FILE_PATH }, messageWriter); - List classpath = config.getClasspath(); + List classpath = config.getFullClasspath(); // should have three entries, resolved relative to location of .lst file assertEquals("Three entries in classpath",3,classpath.size()); Iterator cpIter = classpath.iterator(); @@ -300,13 +300,13 @@ public class BuildArgParserTestCase extends TestCase { AjBuildConfig config = genBuildConfig(new String[] { "-bootclasspath", PATH }, messageWriter); - assertTrue("Should find '" + PATH + "' contained in the first entry of '" + config.getClasspath().toString(), - ((String)config.getClasspath().get(0)).indexOf(PATH) != -1); + assertTrue("Should find '" + PATH + "' contained in the first entry of '" + config.getBootclasspath().toString(), + ((String)config.getBootclasspath().get(0)).indexOf(PATH) != -1); config = genBuildConfig(new String[] { }, messageWriter); - assertTrue(config.getClasspath().toString(), !config.getClasspath().get(0).equals(PATH)); + assertTrue(config.getBootclasspath().toString(), !config.getBootclasspath().get(0).equals(PATH)); } public void testOutputJar() throws InvalidInputException {