aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoraclement <aclement>2004-08-23 13:40:31 +0000
committeraclement <aclement>2004-08-23 13:40:31 +0000
commitf5035234ee878003515413fee5e7e6bfa7a2228d (patch)
tree076109c08757dec1961f3899afac0fa2498475ef /org.aspectj.ajdt.core
parentd0be7b851b7bcedce43ab31cc307f44ebf0a2f2e (diff)
downloadaspectj-f5035234ee878003515413fee5e7e6bfa7a2228d.tar.gz
aspectj-f5035234ee878003515413fee5e7e6bfa7a2228d.zip
Matthews enhancement fix for Bugzilla Bug 72154 "Support for simple dump file"
+ Andy using it to capture 'cant find type' issues.
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java12
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java4
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java2
-rw-r--r--org.aspectj.ajdt.core/testdata/DumpTestCase/src/Aspect.aj6
-rw-r--r--org.aspectj.ajdt.core/testdata/DumpTestCase/src/DeclareError.aj6
-rw-r--r--org.aspectj.ajdt.core/testdata/DumpTestCase/src/DeclareWarning.aj5
-rw-r--r--org.aspectj.ajdt.core/testdata/DumpTestCase/src/HelloWorld.java6
-rw-r--r--org.aspectj.ajdt.core/testdata/DumpTestCase/src/Pointcuts.aj5
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java1
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompilerDumpTestCase.java102
11 files changed, 146 insertions, 5 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java
index 080192767..714596084 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java
@@ -15,6 +15,7 @@ package org.aspectj.ajdt.ajc;
import org.aspectj.ajdt.internal.core.builder.*;
import org.aspectj.bridge.*;
+import org.aspectj.weaver.Dump;
import org.eclipse.jdt.internal.core.builder.MissingSourceFileException;
/**
@@ -105,10 +106,12 @@ public class AjdtCommand implements ICommand {
return false;
}
//System.err.println("errs: " + counter.hasErrors());
- return ((repeat
- ? buildManager.incrementalBuild(config, handler)
- : buildManager.batchBuild(config, handler))
- && !counter.hasErrors());
+ boolean result = ((repeat
+ ? buildManager.incrementalBuild(config, handler)
+ : buildManager.batchBuild(config, handler))
+ && !counter.hasErrors());
+ Dump.dumpOnExit();
+ return result;
} catch (AbortException ae) {
if (ae.isSilent()) {
throw ae;
@@ -119,6 +122,7 @@ public class AjdtCommand implements ICommand {
MessageUtil.error(handler, t.getMessage());
} catch (Throwable t) {
MessageUtil.abort(handler, ABORT_MESSAGE, t);
+ Dump.dumpWithException(t);
}
return false;
}
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 72b7d6b8a..c8888e8a5 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.Dump;
import org.aspectj.weaver.WeaverMessages;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.batch.Main;
@@ -107,7 +108,8 @@ public class BuildArgParser extends Main {
* @return AjBuildConfig per args,
* which will be invalid unless there are no handler errors.
*/
- public AjBuildConfig populateBuildConfig(AjBuildConfig buildConfig, String[] args, boolean setClasspath, File configFile) {
+ public AjBuildConfig populateBuildConfig(AjBuildConfig buildConfig, String[] args, boolean setClasspath, File configFile) {
+ Dump.saveCommandLine(args);
buildConfig.setConfigFile(configFile);
try {
// sets filenames to be non-null in order to make sure that file paramters are ignored
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 deabe0638..2161ee47e 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
@@ -30,6 +30,7 @@ import org.aspectj.asm.*;
import org.aspectj.asm.internal.ProgramElement;
import org.aspectj.bridge.*;
import org.aspectj.util.FileUtil;
+import org.aspectj.weaver.Dump;
import org.aspectj.weaver.World;
import org.aspectj.weaver.bcel.*;
import org.eclipse.core.runtime.OperationCanceledException;
@@ -648,6 +649,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
}
List cps = buildConfig.getFullClasspath();
+ Dump.saveFullClasspath(cps);
String[] classpaths = new String[cps.size()];
for (int i=0; i < cps.size(); i++) {
classpaths[i] = (String)cps.get(i);
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java
index fa790ae7c..0cfa6103f 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java
@@ -32,6 +32,7 @@ import org.aspectj.bridge.ReflectionFactory;
import org.aspectj.bridge.Version;
import org.aspectj.util.FileUtil;
import org.aspectj.util.LangUtil;
+import org.aspectj.weaver.Dump;
/**
* Programmatic and command-line interface to AspectJ compiler.
@@ -268,6 +269,7 @@ public class Main {
* @param holder the MessageHandler sink for messages.
*/
public void run(String[] args, IMessageHolder holder) {
+ Dump.saveMessageHolder(holder);
if (LangUtil.isEmpty(args)) {
args = new String[] { "-?" };
} else if (controller.running()) {
diff --git a/org.aspectj.ajdt.core/testdata/DumpTestCase/src/Aspect.aj b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/Aspect.aj
new file mode 100644
index 000000000..94b3bf683
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/Aspect.aj
@@ -0,0 +1,6 @@
+public aspect Aspect {
+
+ after () returning : Pointcuts.main () && within(HelloWorld) {
+ System.out.println(thisJoinPoint);
+ }
+}
diff --git a/org.aspectj.ajdt.core/testdata/DumpTestCase/src/DeclareError.aj b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/DeclareError.aj
new file mode 100644
index 000000000..7a1fad261
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/DeclareError.aj
@@ -0,0 +1,6 @@
+public aspect DeclareError {
+
+ declare error : Pointcuts.main() && within(HelloWorld) :
+ "main()";
+
+}
diff --git a/org.aspectj.ajdt.core/testdata/DumpTestCase/src/DeclareWarning.aj b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/DeclareWarning.aj
new file mode 100644
index 000000000..7ba2b1f51
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/DeclareWarning.aj
@@ -0,0 +1,5 @@
+public aspect DeclareWarning {
+
+ declare warning : Pointcuts.main() && within(HelloWorld) :
+ "main()";
+}
diff --git a/org.aspectj.ajdt.core/testdata/DumpTestCase/src/HelloWorld.java b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/HelloWorld.java
new file mode 100644
index 000000000..37732b8d5
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/HelloWorld.java
@@ -0,0 +1,6 @@
+public class HelloWorld {
+
+ public static void main(String[] args) {
+ System.out.println("Hello World!");
+ }
+}
diff --git a/org.aspectj.ajdt.core/testdata/DumpTestCase/src/Pointcuts.aj b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/Pointcuts.aj
new file mode 100644
index 000000000..5b589abfd
--- /dev/null
+++ b/org.aspectj.ajdt.core/testdata/DumpTestCase/src/Pointcuts.aj
@@ -0,0 +1,5 @@
+public class Pointcuts {
+
+ public pointcut main () :
+ execution(void main(String[]));
+}
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java
index 5dcc167df..d89573909 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java
@@ -31,6 +31,7 @@ public class AjdtBatchTests extends TestCase {
suite.addTestSuite(MultipleCompileTestCase.class);
suite.addTestSuite(JavadocTest.class);
suite.addTestSuite(PartiallyExposedHierarchyTestCase.class);
+ suite.addTestSuite(CompilerDumpTestCase.class);
// XXX suite.addTestSuite(VerifyWeaveTestCase.class);
//suite.addTestSuite(WorkingCommandTestCase.class);
//$JUnit-END$
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompilerDumpTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompilerDumpTestCase.java
new file mode 100644
index 000000000..6a1b7cfa9
--- /dev/null
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CompilerDumpTestCase.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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 org.aspectj.ajdt.internal.compiler.batch;
+
+import java.io.File;
+
+import org.aspectj.bridge.IMessage;
+import org.aspectj.tools.ajc.AjcTestCase;
+import org.aspectj.tools.ajc.CompilationResult;
+import org.aspectj.weaver.Dump;
+
+import junit.framework.TestCase;
+
+public class CompilerDumpTestCase extends AjcTestCase {
+
+ public static final String PROJECT_DIR = "DumpTestCase";
+
+ private File baseDir;
+ private File dumpFile;
+ private IMessage.Kind savedDumpCondition;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ baseDir = new File("../org.aspectj.ajdt.core/testdata",PROJECT_DIR);
+ dumpFile = null;
+ savedDumpCondition = Dump.getDumpOnExit();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ if (dumpFile != null && dumpFile.exists()) {
+ boolean deleted = dumpFile.delete();
+ assertTrue("Dump file '" + dumpFile.getPath() + "' could not be deleted",deleted);
+ }
+ Dump.setDumpOnExit(savedDumpCondition);
+ }
+
+ /**
+ * Aim: Dump after successful compile to ensure it contains the command
+ * line information.
+ *
+ * Inputs to the compiler:
+ * HelloWorld.java Pointcuts.aj Aspect.aj
+ *
+ * Expected result = Compile succeeds.
+ */
+ public void testDump () {
+ String[] args = new String[] { "src/HelloWorld.java", "src/Pointcuts.aj", "src/Aspect.aj" };
+ CompilationResult result = ajc(baseDir,args);
+ assertNoMessages(result);
+ String fileName = Dump.dump("DumpTestCase.testDump()");
+ dumpFile = new File(fileName);
+ org.aspectj.weaver.DumpTestCase.assertContents(dumpFile,"Command Line","HelloWorld.java");
+ }
+
+ /**
+ * Aim: Dump after successful compile to ensure it contains warning
+ * messages.
+ *
+ * Inputs to the compiler:
+ * HelloWorld.java Pointcuts.aj Aspect.aj DeclareWarning.aj
+ *
+ * Expected result = Compile succeeds.
+ */
+ public void testDumpWithWarnings () {
+ String[] args = new String[] { "src/HelloWorld.java", "src/Pointcuts.aj", "src/DeclareWarning.aj" };
+ CompilationResult result = ajc(baseDir,args);
+ String fileName = Dump.dump("DumpTestCase.testDumpWithWarnings()");
+ dumpFile = new File(fileName);
+ org.aspectj.weaver.DumpTestCase.assertContents(dumpFile,"Compiler Messages","warning");
+ }
+
+ /**
+ * Aim: Dump due to errors.
+ *
+ * Inputs to the compiler:
+ * HelloWorld.java Pointcuts.aj Aspect.aj DeclareError.aj
+ *
+ * Expected result = Compile fails and dump file created.
+ */
+ public void testWithErrors () {
+ Dump.setDumpOnExit(IMessage.ERROR);
+ String previousFileName = Dump.getLastDumpFileName();
+ String[] args = new String[] { "src/HelloWorld.java", "src/Pointcuts.aj", "src/DeclareError.aj" };
+ CompilationResult result = ajc(baseDir,args);
+ String fileName = Dump.getLastDumpFileName();
+ assertTrue("Dump file should be created",!fileName.equals(previousFileName));
+ dumpFile = new File(fileName);
+ org.aspectj.weaver.DumpTestCase.assertContents(dumpFile,"Compiler Messages","error");
+ }
+
+}