aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwisberg <wisberg>2003-12-15 12:13:47 +0000
committerwisberg <wisberg>2003-12-15 12:13:47 +0000
commit18bc9e7ebbe011bcfa3ab942c766bd2fa13081b4 (patch)
tree283c74e3dcf174ab69ff80c71688676079e38af9
parent38aa20202ee04c6fa31dcf827c310a65dc4b96ed (diff)
downloadaspectj-18bc9e7ebbe011bcfa3ab942c766bd2fa13081b4.tar.gz
aspectj-18bc9e7ebbe011bcfa3ab942c766bd2fa13081b4.zip
inpath support
-rw-r--r--docs/devGuideDB/ajc.xml22
-rw-r--r--docs/devGuideDB/antsupport.xml24
-rw-r--r--docs/dist/doc/changes.html11
-rw-r--r--taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java10
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java40
-rw-r--r--testing/src/org/aspectj/testing/util/FileUtil.java2
-rw-r--r--tests/ajcHarnessTests.xml6
-rw-r--r--tests/harness/inpath/aspectsrc/A.java20
-rw-r--r--tests/harness/inpath/build.xml11
-rw-r--r--tests/harness/inpath/input-path-classes/Main.classbin0 -> 1307 bytes
-rw-r--r--tests/harness/inpath/input-path-classes/pack/Util.classbin0 -> 182 bytes
-rw-r--r--tests/harness/inpath/input-path-classes/pack/resource.txt1
-rw-r--r--tests/harness/inpath/input-path-src/Main.java22
-rw-r--r--tests/harness/inpath/input-path-src/pack/Util.java8
-rw-r--r--tests/readme-writing-compiler-tests.html28
15 files changed, 186 insertions, 19 deletions
diff --git a/docs/devGuideDB/ajc.xml b/docs/devGuideDB/ajc.xml
index dd35fca32..afe218887 100644
--- a/docs/devGuideDB/ajc.xml
+++ b/docs/devGuideDB/ajc.xml
@@ -27,7 +27,8 @@
</para>
<para> The arguments after the options specify the source file(s) to compile.
- (Specify source classes using the <parameter>-injars</parameter> option, below.)
+ (Specify source classes using the <parameter>-injars</parameter> or
+ <parameter>-inpath</parameter> options, below.)
Files may be listed directly on the command line, or listed in a file.
The <parameter>-argfile <replaceable>file</replaceable></parameter>
and <parameter>@<replaceable>file</replaceable></parameter> forms
@@ -60,12 +61,21 @@
<varlistentry>
<term>-injars <replaceable>JarList</replaceable></term>
<listitem><para>
- Accept as source bytecode any .class files inside the
- specified .jar files. The output will include these
+ deprecated: since 1.2, use -inpath, which also takes
+ directories.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-inpath <replaceable>Path</replaceable></term>
+ <listitem><para>
+ Accept as source bytecode any .class files in the
+ .jar files or directories on Path.
+ The output will include these
classes, possibly as woven with any applicable aspects.
- JarList, like classpath, is a single argument containing
- a list of paths to jar files, delimited by the platform-
- specific classpath delimiter.
+ Path is a single argument containing
+ a list of paths to zip files or directories,
+ delimited by the platform-specific path delimiter.
</para></listitem>
</varlistentry>
diff --git a/docs/devGuideDB/antsupport.xml b/docs/devGuideDB/antsupport.xml
index d97aaf66f..bbadca4f6 100644
--- a/docs/devGuideDB/antsupport.xml
+++ b/docs/devGuideDB/antsupport.xml
@@ -124,9 +124,10 @@
be specified on the classpath, and that some sources be
be specified
(using one or more of
- <literal>sourceroots</literal>
- <literal>injars</literal>
- <literal>argfiles</literal> and
+ <literal>sourceroots</literal>,
+ <literal>injars</literal>,
+ <literal>inpath</literal>,
+ <literal>argfiles</literal>, and/or
<literal>srcdir</literal> (with patterns)).
When in incremental mode, only
<literal>sourceroots</literal> may be specified.
@@ -182,7 +183,18 @@
(<xref linkend="antTasks-iajc-paths"/>)
</para></entry>
<entry><para>
- Input zip files with .class file entries for bytecode weaving.
+ Deprecated - use inpath instead.
+ Read .class files for bytecode weaving
+ from zip files (only).
+ </para></entry>
+ </row>
+ <row>
+ <entry><para>inpath, inpathRef
+ (<xref linkend="antTasks-iajc-paths"/>)
+ </para></entry>
+ <entry><para>
+ Read .class files for bytecode weaving
+ from directories or zip files (like classpath).
</para></entry>
</row>
<row>
@@ -362,7 +374,7 @@
</para></entry>
<entry><para>
Experimental option to produce binaries that can only be used as input
- for the <literal>-injars</literal> option.
+ for the <literal>-injars</literal> or <literal>-inpath</literal> option.
Usually aspects are compiled normally and put on the
<literal>aspectpath</literal>.
</para></entry>
@@ -636,6 +648,7 @@
<literal>sourceroots</literal>,
<literal>argfiles</literal>,
<literal>injars</literal>,
+ <literal>inpath</literal>,
<literal>classpath</literal>,
<literal>bootclasspath</literal>,
<literal>forkclasspath</literal>, and
@@ -891,6 +904,7 @@
<listitem><para>
<literal>-Xcopyinjars</literal>:
copy resources from any input jars to output
+ (default behavior since 1.1.1)
</para></listitem>
<listitem><para>
<literal>-Xsourcerootcopyfilter {filter}</literal>:
diff --git a/docs/dist/doc/changes.html b/docs/dist/doc/changes.html
index 475b30422..8d5211aaa 100644
--- a/docs/dist/doc/changes.html
+++ b/docs/dist/doc/changes.html
@@ -144,6 +144,8 @@ All rights reserved.
<h2>Changes in AspectJ</h2>
<ul>
+ <li> <a href="#1.2">1.2</a> (released TODO XXX)
+ </li>
<li> <a href="#1.1.1">1.1.1</a> (released 2003-09)
</li>
<li> 1.1.0 (released 2003-06-06)
@@ -187,6 +189,15 @@ All rights reserved.
<hr />
+<h2><a name="1.2">1.2</a></h2>
+<p>Some of the more significant bug fixes and enhancements in this release include:
+ <ul>
+ <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=46347">46347</a>
+ The ajc compiler now can read .class files from directories as well as
+ zip files for bytecode weaving.
+ </li>
+ </ul>
+
<h2><a name="1.1.1">1.1.1</a></h2>
<p>All known P1 and P2 bugs have been fixed in this release. The <a href="https://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&target_milestone=1.1.1">full list of bug fixes</a>
diff --git a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
index 5b203c70b..81c31cf66 100644
--- a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
+++ b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
@@ -1034,6 +1034,9 @@ public class AjcTask extends MatchingTask {
if (null != injars) {
throw new BuildException("weaveDir incompatible with injars now");
}
+ if (null != inpath) {
+ throw new BuildException("weaveDir incompatible with inpath now");
+ }
File injar = zipDirectory(xweaveDir);
setInjars(new Path(getProject(), injar.getAbsolutePath()));
@@ -1439,9 +1442,12 @@ public class AjcTask extends MatchingTask {
throw new BuildException(s);
}
final Project project = getProject();
- if (copyInjars) {
+ if (copyInjars) { // XXXX remove as unused since 1.1.1
+ if (null != inpath) {
+ log("copyInjars does not support inpath.\n", Project.MSG_WARN);
+ }
String taskName = getTaskName() + " - unzip";
- String[] paths = injars.list();
+ String[] paths = injars.list();
if (!LangUtil.isEmpty(paths)) {
PatternSet patternSet = new PatternSet();
patternSet.setProject(project);
diff --git a/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java b/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java
index 224ade658..1616e7b6f 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java
@@ -82,6 +82,13 @@ public class CompilerRun implements IAjcRun {
final List /*String*/
injars;
+ /**
+ * During run, these String are collapsed and passed as the inpath option.
+ * The list is set up in setupAjcRun(..),
+ * which extracts only directories from the files attribute.
+ */
+ final List inpaths;
+
private CompilerRun(Spec spec) {
if (null == spec) {
throw new IllegalArgumentException("null spec");
@@ -89,6 +96,7 @@ public class CompilerRun implements IAjcRun {
this.spec = spec;
arguments = new ArrayList();
injars = new ArrayList();
+ inpaths = new ArrayList();
}
/**
@@ -147,6 +155,7 @@ public class CompilerRun implements IAjcRun {
// For a compile run to support relative paths + source base,
// change so the run calculates the paths (differently when staging)
+ final String[] inpathPaths;
final String[] injarPaths;
final String[] srcPaths;
{
@@ -158,11 +167,20 @@ public class CompilerRun implements IAjcRun {
true);
injarPaths =
LangUtil.endsWith(paths, CompilerRun.JAR_SUFFIXES, true);
+ inpathPaths =
+ LangUtil.selectDirectories(paths, testBaseSrcDir);
+ if (!spec.badInput) {
+ int found = inpathPaths.length + injarPaths.length + srcPaths.length;
+ if (paths.length != found) {
+ validator.fail("found " + found + " of " + paths.length + " sources");
+ }
+ }
}
// validate readable for sources
if (!spec.badInput) {
if (!validator.canRead(testBaseSrcDir, srcPaths, "sources")
|| !validator.canRead(testBaseSrcDir, injarPaths, "injars")
+ || !validator.canRead(testBaseSrcDir, inpathPaths, "inpaths")
|| !validator.canRead(
testBaseSrcDir,
spec.argfiles,
@@ -190,6 +208,7 @@ public class CompilerRun implements IAjcRun {
int numSources =
srcPaths.length
+ injarPaths.length
+ + inpathPaths.length
+ spec.argfiles.length
+ spec.sourceroots.length;
if (!spec.badInput && (numSources < 1)) {
@@ -202,6 +221,8 @@ public class CompilerRun implements IAjcRun {
FileUtil.getBaseDirFiles(testBaseSrcDir, spec.argfiles);
final File[] injarFiles =
FileUtil.getBaseDirFiles(testBaseSrcDir, injarPaths);
+ final File[] inpathFiles =
+ FileUtil.getBaseDirFiles(testBaseSrcDir, inpathPaths);
final File[] aspectFiles =
FileUtil.getBaseDirFiles(testBaseSrcDir, spec.aspectpath);
final File[] extdirFiles =
@@ -211,9 +232,10 @@ public class CompilerRun implements IAjcRun {
// hmm - duplicates validation above, verifying getBaseDirFiles?
if (!spec.badInput) {
if (!validator.canRead(argFiles, "argFiles")
- || !validator.canRead(injarFiles, "injarfiles")
- || !validator.canRead(aspectFiles, "aspectfiles")
- || !validator.canRead(classFiles, "classfiles")) {
+ || !validator.canRead(injarFiles, "injarFiles")
+ || !validator.canRead(inpathFiles, "inpathFiles")
+ || !validator.canRead(aspectFiles, "aspectFiles")
+ || !validator.canRead(classFiles, "classFiles")) {
return false;
}
}
@@ -322,6 +344,10 @@ public class CompilerRun implements IAjcRun {
if (!LangUtil.isEmpty(injarFiles)) {
injars.addAll(Arrays.asList(FileUtil.getPaths(injarFiles)));
}
+ inpaths.clear();
+ if (!LangUtil.isEmpty(inpathFiles)) {
+ inpaths.addAll(Arrays.asList(FileUtil.getPaths(inpathFiles)));
+ }
if (!LangUtil.isEmpty(argFiles)) {
String[] ra = FileUtil.getPaths(argFiles);
for (int j = 0; j < ra.length; j++) {
@@ -436,6 +462,14 @@ public class CompilerRun implements IAjcRun {
null));
}
+ if (0 < inpaths.size()) {
+ argList.add("-inpath");
+ argList.add(
+ FileUtil.flatten(
+ (String[]) inpaths.toArray(new String[0]),
+ null));
+ }
+
// put specified arguments last, for better badInput tests
argList.addAll(setupResult.commandOptions);
diff --git a/testing/src/org/aspectj/testing/util/FileUtil.java b/testing/src/org/aspectj/testing/util/FileUtil.java
index 2caa5e203..e3ca612d1 100644
--- a/testing/src/org/aspectj/testing/util/FileUtil.java
+++ b/testing/src/org/aspectj/testing/util/FileUtil.java
@@ -586,7 +586,7 @@ public class FileUtil {
}
String context = "FileUtil.copyFile(src, dest, err)";
boolean report = report(err, context, label, throwable);
- return (result && report);
+ return (result && !report);
}
/**
diff --git a/tests/ajcHarnessTests.xml b/tests/ajcHarnessTests.xml
index 721e0a189..0170b7124 100644
--- a/tests/ajcHarnessTests.xml
+++ b/tests/ajcHarnessTests.xml
@@ -286,6 +286,12 @@
<run class="SystemExit" options="-1"/>
</ajc-test>
+ <ajc-test dir="harness/inpath"
+ title="pass test inpath option - valid">
+ <compile files="input-path-classes" sourceroots="aspectsrc"/>
+ <run class="Main"/>
+ </ajc-test>
+
</suite>
diff --git a/tests/harness/inpath/aspectsrc/A.java b/tests/harness/inpath/aspectsrc/A.java
new file mode 100644
index 000000000..8d0f487a5
--- /dev/null
+++ b/tests/harness/inpath/aspectsrc/A.java
@@ -0,0 +1,20 @@
+
+import org.aspectj.testing.Tester;
+
+public aspect A {
+ static {
+ Tester.expectEvents(
+ new String[] {
+ "execution(void Main.main(String[]))",
+ "execution(void pack.Util.log(String[]))"
+ }
+ );
+ }
+ before() : execution(public static * *(..)) {
+ Tester.event("" + thisJoinPointStaticPart);
+ //System.out.println("\"" + thisJoinPointStaticPart);
+ }
+ after() returning : execution(public static void main(String[])) {
+ Tester.checkAllEvents();
+ }
+}
diff --git a/tests/harness/inpath/build.xml b/tests/harness/inpath/build.xml
new file mode 100644
index 000000000..21e378070
--- /dev/null
+++ b/tests/harness/inpath/build.xml
@@ -0,0 +1,11 @@
+
+<project name="inpath-test" default="all" basedir=".">
+
+
+ <target name="all" description="build classes">
+ <property name="dest.dir" location="${basedir}/input-path-classes"/>
+ <property name="src.dir" location="${basedir}/input-path-src"/>
+ <javac destdir="${dest.dir}" srcdir="${src.dir}"/>
+ </target>
+
+</project>
diff --git a/tests/harness/inpath/input-path-classes/Main.class b/tests/harness/inpath/input-path-classes/Main.class
new file mode 100644
index 000000000..51ecc1163
--- /dev/null
+++ b/tests/harness/inpath/input-path-classes/Main.class
Binary files differ
diff --git a/tests/harness/inpath/input-path-classes/pack/Util.class b/tests/harness/inpath/input-path-classes/pack/Util.class
new file mode 100644
index 000000000..eae0da606
--- /dev/null
+++ b/tests/harness/inpath/input-path-classes/pack/Util.class
Binary files differ
diff --git a/tests/harness/inpath/input-path-classes/pack/resource.txt b/tests/harness/inpath/input-path-classes/pack/resource.txt
new file mode 100644
index 000000000..9a2c7732f
--- /dev/null
+++ b/tests/harness/inpath/input-path-classes/pack/resource.txt
@@ -0,0 +1 @@
+testing \ No newline at end of file
diff --git a/tests/harness/inpath/input-path-src/Main.java b/tests/harness/inpath/input-path-src/Main.java
new file mode 100644
index 000000000..83b7dfb56
--- /dev/null
+++ b/tests/harness/inpath/input-path-src/Main.java
@@ -0,0 +1,22 @@
+
+import pack.Util;
+
+public class Main {
+ public static void main(String[] args) throws java.io.IOException {
+ Util.log(args);
+ boolean expectResourceCopy = false; // XXXX check
+ if (expectResourceCopy) {
+ java.io.InputStream in =
+ Main.class.getClassLoader().getResourceAsStream("pack/resource.txt");
+ if (null == in) {
+ throw new Error("unable to read pack/resource.txt");
+ }
+ byte[] buf = new byte[7];
+ int read = in.read(buf);
+ String val = new String(buf);
+ if (!"testing".equals(val)) {
+ throw new Error("expected \"testing\", got: " + val);
+ }
+ }
+ }
+}
diff --git a/tests/harness/inpath/input-path-src/pack/Util.java b/tests/harness/inpath/input-path-src/pack/Util.java
new file mode 100644
index 000000000..939f6a81d
--- /dev/null
+++ b/tests/harness/inpath/input-path-src/pack/Util.java
@@ -0,0 +1,8 @@
+
+package pack;
+
+public class Util {
+ public static void log(String[] args) {
+ // do nothing
+ }
+}
diff --git a/tests/readme-writing-compiler-tests.html b/tests/readme-writing-compiler-tests.html
index 932c35267..3eb9896cc 100644
--- a/tests/readme-writing-compiler-tests.html
+++ b/tests/readme-writing-compiler-tests.html
@@ -455,8 +455,9 @@ The <code>compile</code> element has the following attributes
which handle most of the other compiler arguments:
<ul>
<li><code>files</code>: .aj and .java files are treated as source files,
- but .jar files are extracted and passed to the compiler
+ but .jar/zip files are extracted and passed to the compiler
as <code>-injars</code>
+ and readable directories are passed as <code>-inpath</code>.
</li><li><code>classpath</code>: directories and jar files for the classpath
</li><li><code>aspectpath</code>: binary aspects in jar files
</li><li><code>argfiles</code>: argument list files
@@ -469,7 +470,7 @@ multiple entries are separated with commas.
Here is a cooked example that uses all <code>compiler</code> attributes:
<pre>
&lt;ajc-test dir="new" title="attributes test">
- &lt;compile files="Main.java,injar.jar"
+ &lt;compile files="Main.java,injar.jar,some-directory"
staging="true"
options="-Xlint,-g:none"
argfiles="debug.lst,aspects/test.lst"
@@ -479,11 +480,34 @@ Here is a cooked example that uses all <code>compiler</code> attributes:
&lt;/ajc-test>
</pre>
+<h5>Test-only compiler attributes</h5>
+The following attributes of the compiler entity dictate harness behavior:
+
+<ul>
+<li><u>badInput</u>:
+To test invalid input, set the compiler <code>badInput</code> attribute
+to "</code>true</code>". This prevents the harness from aborting a test
+because a specified input file was not found. (However, there is no way
+to specify bad input for a directory in the files attribute intended for
+-inpath, because the harness selects readable directories.)
+</li>
+
+
+<li><u>includeClassesDir</u>:
+Set this in order to include the output classes directory explicitly
+on the classpath.
+</li>
+<li><u>reuseCompiler</u>:
+Set this to re-use a compiler from a previous compiler run.
+(This tests statefulness of a compiler across non-incremental runs.)
+</li>
+</ul>
<h5>Unsupported compiler options</h5>
The harness does not support the following AspectJ compiler
options: <code>-target {version}, -outjar {file}, -log {file}</code>.
(<code>-d {dir}</code> is used but specification is not supported.)
+
<a name="background"></a>