Bläddra i källkod

inpath support

tags/mostlyLastEclipse2xTree_20040112
wisberg 20 år sedan
förälder
incheckning
18bc9e7ebb

+ 16
- 6
docs/devGuideDB/ajc.xml Visa fil

@@ -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>


+ 19
- 5
docs/devGuideDB/antsupport.xml Visa fil

@@ -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>:

+ 11
- 0
docs/dist/doc/changes.html Visa fil

@@ -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>

+ 8
- 2
taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java Visa fil

@@ -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);

+ 37
- 3
testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java Visa fil

@@ -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);


+ 1
- 1
testing/src/org/aspectj/testing/util/FileUtil.java Visa fil

@@ -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);
}

/**

+ 6
- 0
tests/ajcHarnessTests.xml Visa fil

@@ -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>



+ 20
- 0
tests/harness/inpath/aspectsrc/A.java Visa fil

@@ -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();
}
}

+ 11
- 0
tests/harness/inpath/build.xml Visa fil

@@ -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>

Binär
tests/harness/inpath/input-path-classes/Main.class Visa fil


Binär
tests/harness/inpath/input-path-classes/pack/Util.class Visa fil


+ 1
- 0
tests/harness/inpath/input-path-classes/pack/resource.txt Visa fil

@@ -0,0 +1 @@
testing

+ 22
- 0
tests/harness/inpath/input-path-src/Main.java Visa fil

@@ -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);
}
}
}
}

+ 8
- 0
tests/harness/inpath/input-path-src/pack/Util.java Visa fil

@@ -0,0 +1,8 @@

package pack;

public class Util {
public static void log(String[] args) {
// do nothing
}
}

+ 26
- 2
tests/readme-writing-compiler-tests.html Visa fil

@@ -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>

Laddar…
Avbryt
Spara