diff options
author | wisberg <wisberg> | 2004-10-06 10:28:36 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2004-10-06 10:28:36 +0000 |
commit | ce5705cabcab7d5e03c8f31183375ed90dd3480e (patch) | |
tree | a89393327ffa2e1de48ae7f53bdff298d85d5b38 /testing | |
parent | 3d3d7fe9b9ebadc9dfc90307281076495fc4ac07 (diff) | |
download | aspectj-ce5705cabcab7d5e03c8f31183375ed90dd3480e.tar.gz aspectj-ce5705cabcab7d5e03c8f31183375ed90dd3480e.zip |
support for aspectpath, which forces forking
Diffstat (limited to 'testing')
-rw-r--r-- | testing/src/org/aspectj/testing/harness/bridge/JavaRun.java | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java index a74631929..d7a5410a9 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java @@ -106,7 +106,7 @@ public class JavaRun implements IAjcRun { File[] libs = sandbox.getClasspathJars(readable, this); boolean includeClassesDir = true; File[] dirs = sandbox.getClasspathDirectories(readable, this, includeClassesDir); - completedNormally = spec.forkSpec.fork + completedNormally = (spec.forkSpec.fork || !LangUtil.isEmpty(spec.aspectpath)) ? runInOtherVM(status, libs, dirs) : runInSameVM(status, libs, dirs); } finally { @@ -186,19 +186,41 @@ public class JavaRun implements IAjcRun { * @return */ protected boolean runInOtherVM(IRunStatus status, File[] libs, File[] dirs) { - // assert spec.fork; + // assert spec.fork || !LangUtil.isEmpty(spec.aspectpath); ArrayList cmd = new ArrayList(); cmd.add(FileUtil.getBestPath(spec.forkSpec.java)); if (!LangUtil.isEmpty(spec.forkSpec.vmargs)) { cmd.addAll(Arrays.asList(spec.forkSpec.vmargs)); } - cmd.add("-classpath"); + final String classpath; { - StringBuffer classpath = new StringBuffer(); - appendClasspath(classpath, spec.forkSpec.bootclasspath); - appendClasspath(classpath, dirs); - appendClasspath(classpath, libs); - cmd.add(classpath.toString()); + StringBuffer cp = new StringBuffer(); + appendClasspath(cp, spec.forkSpec.bootclasspath); + appendClasspath(cp, dirs); + appendClasspath(cp, libs); + classpath = cp.toString(); + } + if (LangUtil.isEmpty(spec.aspectpath)) { + cmd.add("-classpath"); + cmd.add(classpath); + } else { + // verify 1.4 or above, assuming same vm as running this + if (!LangUtil.supportsJava("1.4")) { + throw new Error("load-time weaving test requires Java 1.4+"); + } + cmd.add("-Djava.system.class.loader=org.aspectj.weaver.WeavingURLClassLoader"); + cmd.add("-classpath"); + cmd.add(System.getProperty("java.class.path")); + + File[] aspectJars = sandbox.findFiles(spec.aspectpath); + if (LangUtil.isEmpty(aspectJars)) { + throw new Error("unable to find " + Arrays.asList(spec.aspectpath)); + } + StringBuffer cp = new StringBuffer(); + appendClasspath(cp, aspectJars); + cmd.add("-Daj.aspect.path=" + cp.toString()); + cp.append(classpath); // appendClasspath writes trailing delimiter + cmd.add("-Daj.class.path=" + cp.toString()); } cmd.add(spec.className); cmd.addAll(spec.options); @@ -484,6 +506,7 @@ public class JavaRun implements IAjcRun { protected boolean errStreamIsError = true; protected final ForkSpec forkSpec; + protected String[] aspectpath; public Spec() { super(XMLNAME); @@ -522,6 +545,9 @@ public class JavaRun implements IAjcRun { this.className = className; } + public void setAspectpath(String path) { + this.aspectpath = XMLWriter.unflattenList(path); + } public void setErrStreamIsError(boolean errStreamIsError) { this.errStreamIsError = errStreamIsError; } |