aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoraclement <aclement>2004-08-13 15:18:01 +0000
committeraclement <aclement>2004-08-13 15:18:01 +0000
commit36d7a888c5b0ebaf1947afff7d29fc17115101a3 (patch)
tree213292e62ca36d11323242446ac5a715fbe004df /org.aspectj.ajdt.core
parent17cd7b3e1254a56ffd3248bb5bc4ffacdf48bb98 (diff)
downloadaspectj-36d7a888c5b0ebaf1947afff7d29fc17115101a3.tar.gz
aspectj-36d7a888c5b0ebaf1947afff7d29fc17115101a3.zip
Bugzilla Bug 71339
AJC produces partial output jar file, when there are warnings during weaving (new dependencies)
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/.project3
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java37
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java13
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jarbin0 -> 1235 bytes
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/child.jarbin0 -> 677 bytes
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/parent.jarbin0 -> 589 bytes
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/src/jar1/Parent.java17
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/src/jar2/Child.java20
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/src/jar3/Aspect.aj22
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java56
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjdtBuilderTests.java1
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java8
12 files changed, 172 insertions, 5 deletions
diff --git a/org.aspectj.ajdt.core/.project b/org.aspectj.ajdt.core/.project
index 301a33091..55bb13722 100644
--- a/org.aspectj.ajdt.core/.project
+++ b/org.aspectj.ajdt.core/.project
@@ -4,12 +4,13 @@
<comment></comment>
<projects>
<project>asm</project>
- <project>weaver</project>
<project>bridge</project>
<project>org.eclipse.jdt.core</project>
<project>runtime</project>
+ <project>testing-client</project>
<project>testing-util</project>
<project>util</project>
+ <project>weaver</project>
</projects>
<buildSpec>
<buildCommand>
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 167c2f718..72b7d6b8a 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
@@ -20,6 +20,7 @@ import java.util.*;
import org.aspectj.ajdt.internal.core.builder.*;
import org.aspectj.bridge.*;
import org.aspectj.util.*;
+import org.aspectj.weaver.WeaverMessages;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -180,6 +181,42 @@ public class BuildArgParser extends Main {
&& (0 == buildConfig.getSourceRoots().size())) {
MessageUtil.error(handler, "specify a source root when in incremental mode");
}
+
+ /*
+ * Ensure we don't overwrite injars, inpath or aspectpath with outjar
+ * bug-71339
+ */
+ File outjar = buildConfig.getOutputJar();
+ if (outjar != null) {
+
+ /* Search injars */
+ for (Iterator i = buildConfig.getInJars().iterator(); i.hasNext(); ) {
+ File injar = (File)i.next();
+ if (injar.equals(outjar)) {
+ String message = WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH);
+ MessageUtil.error(handler,message);
+ }
+ }
+
+ /* Search inpath */
+ for (Iterator i = buildConfig.getInpath().iterator(); i.hasNext(); ) {
+ File inPathElement = (File)i.next();
+ if (!inPathElement.isDirectory() && inPathElement.equals(outjar)) {
+ String message = WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH);
+ MessageUtil.error(handler,message);
+ }
+ }
+
+ /* Search aspectpath */
+ for (Iterator i = buildConfig.getAspectpath().iterator(); i.hasNext(); ) {
+ File pathElement = (File)i.next();
+ if (!pathElement.isDirectory() && pathElement.equals(outjar)) {
+ String message = WeaverMessages.format(WeaverMessages.OUTJAR_IN_INPUT_PATH);
+ MessageUtil.error(handler,message);
+ }
+ }
+
+ }
setDebugOptions();
buildConfig.getOptions().set(options);
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 3a684d390..deabe0638 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
@@ -229,7 +229,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
}
} finally {
if (zos != null) {
- closeOutputStream();
+ closeOutputStream(buildConfig.getOutputJar());
}
ret = !handler.hasErrors();
// bug 59895, don't release reference to handler as may be needed by a nested call
@@ -257,17 +257,22 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
return true;
}
- private void closeOutputStream() {
+ private void closeOutputStream(File outJar) {
try {
if (zos != null) zos.close();
zos = null;
+
+ /* Ensure we don't write an incomplete JAR bug-71339 */
+ if (handler.hasErrors()) {
+ outJar.delete();
+ }
} catch (IOException ex) {
IMessage message =
new Message("Unable to write outjar "
- + buildConfig.getOutputJar().getPath()
+ + outJar.getPath()
+ "(" + ex.getMessage()
+ ")",
- new SourceLocation(buildConfig.getOutputJar(),0),
+ new SourceLocation(outJar,0),
true);
handler.handleMessage(message);
}
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
new file mode 100644
index 000000000..37151cc0f
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
new file mode 100644
index 000000000..df45a1dd6
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
new file mode 100644
index 000000000..eba9b328a
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar1/Parent.java b/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar1/Parent.java
new file mode 100644
index 000000000..55ec0c902
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar1/Parent.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Matthew Webster - initial implementation
+ *******************************************************************************/
+package jar1;
+
+public class Parent {
+
+ public static void main(String[] args) {
+ }
+}
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar2/Child.java b/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar2/Child.java
new file mode 100644
index 000000000..534a96a79
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar2/Child.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Matthew Webster - initial implementation
+ *******************************************************************************/
+package jar2;
+
+import jar1.Parent;
+
+public class Child extends Parent {
+
+ public static void main(String[] args) {
+ System.out.println("? Child.main()");
+ }
+}
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar3/Aspect.aj b/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar3/Aspect.aj
new file mode 100644
index 000000000..afe7cbf5d
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/src/jar3/Aspect.aj
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Matthew Webster - initial implementation
+ *******************************************************************************/
+package jar3;
+
+public aspect Aspect {
+
+ pointcut main () :
+ execution(* *.main(..));
+
+ after () : main () {
+ System.out.println("? Aspect.main()");
+ }
+
+}
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java
index 4205b733c..9d509d9e2 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java
@@ -40,6 +40,8 @@ public class BcweaverJarMaker {
makeURLWeavingClassLoaderJars();
makeDuplicateManifestTestJars();
+
+ makeOutjarTestJars();
}
public static void makeJar0() throws IOException {
@@ -357,4 +359,58 @@ public class BcweaverJarMaker {
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/TraceHello.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
}
+
+ public static void makeOutjarTestJars() throws IOException {
+ List args = new ArrayList();
+
+ /*
+ * parent
+ */
+ args.clear();
+ args.add("-classpath");
+ args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar" +
+ File.pathSeparator + System.getProperty("aspectjrt.path"));
+ args.add("-outjar");
+ args.add("./testdata/OutjarTest/parent.jar");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/OutjarTest/src/jar1/Parent.java");
+ CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
+
+ /*
+ * child
+ */
+ args.clear();
+ args.add("-classpath");
+ args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar"
+ + File.pathSeparator + System.getProperty("aspectjrt.path")
+ + File.pathSeparator + "./testdata/OutjarTest/parent.jar");
+ args.add("-outjar");
+ args.add("./testdata/OutjarTest/child.jar");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/OutjarTest/src/jar2/Child.java");
+ CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
+
+ /*
+ * aspects
+ */
+ args.clear();
+ args.add("-classpath");
+ args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar"
+ + File.pathSeparator + System.getProperty("aspectjrt.path"));
+ args.add("-outjar");
+ args.add("./testdata/OutjarTest/aspects.jar");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/OutjarTest/src/jar3/Aspect.aj");
+ CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
+
+ /*
+ * aspectjar
+ */
+// args = new ArrayList();
+// args.add("-classpath");
+// args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar" +
+// File.pathSeparator + System.getProperty("aspectjrt.path"));
+// args.add("-outjar");
+// args.add("../ajde/testdata/DuplicateManifestTest/aspectjar.jar");
+// args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/Trace.java");
+// args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/TraceHello.java");
+// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
+ }
}
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjdtBuilderTests.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjdtBuilderTests.java
index ebf12d945..17501534f 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjdtBuilderTests.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjdtBuilderTests.java
@@ -25,6 +25,7 @@ public class AjdtBuilderTests extends TestCase {
suite.addTestSuite(AsmBuilderTest.class);
suite.addTestSuite(AjCompilerOptionsTest.class);
suite.addTestSuite(AjStateTest.class);
+ suite.addTestSuite(OutjarTest.class);
//$JUnit-END$
return suite;
}
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java
index 443ea7da7..fa87bae21 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java
@@ -53,6 +53,8 @@ public class Ajc {
private int incrementalStage = 10;
private boolean shouldEmptySandbox = true;
private AjcCommandController controller;
+ private static boolean verbose = (!System.getProperty("org.aspectj.tools.ajc.Ajc.verbose","false").equals("false"));
+
/**
* Constructs a new Ajc instance, with a new AspectJ compiler
@@ -175,6 +177,11 @@ public class Ajc {
System.setOut(systemOut);
System.setErr(systemErr);
}
+ if (verbose) {
+ System.err.println(result.getStandardError());
+ System.out.println(result.getStandardOutput());
+ System.out.println(result);
+ }
return result;
}
@@ -279,6 +286,7 @@ public class Ajc {
if ((args[i].equals("-aspectpath") ||
args[i].equals("-inpath") ||
args[i].equals("-injars") ||
+ args[i].equals("-outjar") ||
args[i].equals("-classpath") ||
args[i].equals("-sourceroots") ||
args[i].equals("-Xlintfile") ||