summaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core/src
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/src
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/src')
-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
2 files changed, 46 insertions, 4 deletions
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);
}