Browse Source

Bugzilla Bug 71339

	  	AJC produces partial output jar file, when there are warnings during weaving
(new dependencies)
tags/V1_2_1
aclement 20 years ago
parent
commit
36d7a888c5

+ 2
- 1
org.aspectj.ajdt.core/.project View File

<comment></comment> <comment></comment>
<projects> <projects>
<project>asm</project> <project>asm</project>
<project>weaver</project>
<project>bridge</project> <project>bridge</project>
<project>org.eclipse.jdt.core</project> <project>org.eclipse.jdt.core</project>
<project>runtime</project> <project>runtime</project>
<project>testing-client</project>
<project>testing-util</project> <project>testing-util</project>
<project>util</project> <project>util</project>
<project>weaver</project>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>

+ 37
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java View File

import org.aspectj.ajdt.internal.core.builder.*; import org.aspectj.ajdt.internal.core.builder.*;
import org.aspectj.bridge.*; import org.aspectj.bridge.*;
import org.aspectj.util.*; import org.aspectj.util.*;
import org.aspectj.weaver.WeaverMessages;
import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.batch.Main; import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
&& (0 == buildConfig.getSourceRoots().size())) { && (0 == buildConfig.getSourceRoots().size())) {
MessageUtil.error(handler, "specify a source root when in incremental mode"); 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(); setDebugOptions();
buildConfig.getOptions().set(options); buildConfig.getOptions().set(options);

+ 9
- 4
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java View File

} }
} finally { } finally {
if (zos != null) { if (zos != null) {
closeOutputStream();
closeOutputStream(buildConfig.getOutputJar());
} }
ret = !handler.hasErrors(); ret = !handler.hasErrors();
// bug 59895, don't release reference to handler as may be needed by a nested call // bug 59895, don't release reference to handler as may be needed by a nested call
return true; return true;
} }


private void closeOutputStream() {
private void closeOutputStream(File outJar) {
try { try {
if (zos != null) zos.close(); if (zos != null) zos.close();
zos = null; zos = null;
/* Ensure we don't write an incomplete JAR bug-71339 */
if (handler.hasErrors()) {
outJar.delete();
}
} catch (IOException ex) { } catch (IOException ex) {
IMessage message = IMessage message =
new Message("Unable to write outjar " new Message("Unable to write outjar "
+ buildConfig.getOutputJar().getPath()
+ outJar.getPath()
+ "(" + ex.getMessage() + "(" + ex.getMessage()
+ ")", + ")",
new SourceLocation(buildConfig.getOutputJar(),0),
new SourceLocation(outJar,0),
true); true);
handler.handleMessage(message); handler.handleMessage(message);
} }

BIN
org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar View File


BIN
org.aspectj.ajdt.core/testdata/OutjarTest/child.jar View File


BIN
org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar View File


+ 17
- 0
org.aspectj.ajdt.core/testdata/OutjarTest/src/jar1/Parent.java View File

/*******************************************************************************
* 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) {
}
}

+ 20
- 0
org.aspectj.ajdt.core/testdata/OutjarTest/src/jar2/Child.java View File

/*******************************************************************************
* 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()");
}
}

+ 22
- 0
org.aspectj.ajdt.core/testdata/OutjarTest/src/jar3/Aspect.aj View File

/*******************************************************************************
* 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()");
}
}

+ 56
- 0
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java View File

makeURLWeavingClassLoaderJars(); makeURLWeavingClassLoaderJars();
makeDuplicateManifestTestJars(); makeDuplicateManifestTestJars();

makeOutjarTestJars();
} }
public static void makeJar0() throws IOException { public static void makeJar0() throws IOException {
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/TraceHello.java"); args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/TraceHello.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); 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);
}
} }

+ 1
- 0
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjdtBuilderTests.java View File

suite.addTestSuite(AsmBuilderTest.class); suite.addTestSuite(AsmBuilderTest.class);
suite.addTestSuite(AjCompilerOptionsTest.class); suite.addTestSuite(AjCompilerOptionsTest.class);
suite.addTestSuite(AjStateTest.class); suite.addTestSuite(AjStateTest.class);
suite.addTestSuite(OutjarTest.class);
//$JUnit-END$ //$JUnit-END$
return suite; return suite;
} }

+ 8
- 0
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java View File

private int incrementalStage = 10; private int incrementalStage = 10;
private boolean shouldEmptySandbox = true; private boolean shouldEmptySandbox = true;
private AjcCommandController controller; 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 * Constructs a new Ajc instance, with a new AspectJ compiler
System.setOut(systemOut); System.setOut(systemOut);
System.setErr(systemErr); System.setErr(systemErr);
} }
if (verbose) {
System.err.println(result.getStandardError());
System.out.println(result.getStandardOutput());
System.out.println(result);
}
return result; return result;
} }
if ((args[i].equals("-aspectpath") || if ((args[i].equals("-aspectpath") ||
args[i].equals("-inpath") || args[i].equals("-inpath") ||
args[i].equals("-injars") || args[i].equals("-injars") ||
args[i].equals("-outjar") ||
args[i].equals("-classpath") || args[i].equals("-classpath") ||
args[i].equals("-sourceroots") || args[i].equals("-sourceroots") ||
args[i].equals("-Xlintfile") || args[i].equals("-Xlintfile") ||

Loading…
Cancel
Save