diff options
author | mkersten <mkersten> | 2003-08-06 21:17:57 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-08-06 21:17:57 +0000 |
commit | 5edccbfaeb8bb4dc5b34d553267365ae3c7eda41 (patch) | |
tree | 7fe52f8582e5a0240443801f2003b09117b419de /ajde | |
parent | 3b729301c726c44f028906ec53e518e2d3081e83 (diff) | |
download | aspectj-5edccbfaeb8bb4dc5b34d553267365ae3c7eda41.tar.gz aspectj-5edccbfaeb8bb4dc5b34d553267365ae3c7eda41.zip |
Fixed bugs:
40943: Binary weaving should copy non-Java resources from "-inja...
36071: 1.1 rc1 should copy resources similar to java compiler
40826: ajbrowser does not report errors properly
40774: task list icons don't show in ajbrowser
Diffstat (limited to 'ajde')
20 files changed, 344 insertions, 42 deletions
diff --git a/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java b/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java index fd63560e3..2934932ee 100644 --- a/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java +++ b/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java @@ -16,8 +16,7 @@ package org.aspectj.ajde; -import java.util.List; -import java.util.Set; +import java.util.*; /** * @author Mik Kersten @@ -70,6 +69,16 @@ public interface ProjectPropertiesAdapter { public Set getInJars(); /** + * Get the set of non-Java resources for this compilation. + * Set members should be of type java.io.File. + * An empty set or null is acceptable for this option. + * From -injars. + * + * @return map from unique resource name to absolute path to source resource (String to File) + */ + public Map getSourcePathResources(); + + /** * Get the output jar file for the compilation results. * Return null to leave classfiles unjar'd in output directory * From -outjar diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java index d77aee408..c1b838e28 100644 --- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java +++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java @@ -488,6 +488,7 @@ public class CompilerAdapter { join(config.getSourceRoots(), properties.getSourceRoots()); join(config.getInJars(), properties.getInJars()); + config.setSourcePathResources(properties.getSourcePathResources()); join(config.getAspectpath(), properties.getAspectPath()); } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessage.java b/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessage.java deleted file mode 100644 index 9ca312d83..000000000 --- a/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessage.java +++ /dev/null @@ -1,34 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * 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: - * Xerox/PARC initial implementation - * ******************************************************************/ - - -package org.aspectj.ajde.ui.swing; - -import org.aspectj.bridge.IMessage; -import org.aspectj.util.LangUtil; - -/** - * @author Mik Kersten - */ -public class CompilerMessage { - public final IMessage message; - - public CompilerMessage(IMessage message) { - LangUtil.throwIaxIfNull(message, "message"); - this.message = message; - } - - public String toString() { - return message.toString(); - } - } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java b/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java index 650eaaae5..9476f3b4e 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java @@ -36,7 +36,7 @@ public class CompilerMessagesCellRenderer extends JLabel implements ListCellRend boolean cellHasFocus) { String label = "<no message>"; String detail = null; - IMessage.Kind kind = IMessage.INFO; + IMessage.Kind kind = IMessage.ERROR; if (value instanceof IMessage) { IMessage cm = (IMessage) value; label = cm.getMessage(); diff --git a/ajde/testdata/bug-36071/bin/test/test.props b/ajde/testdata/bug-36071/bin/test/test.props new file mode 100644 index 000000000..51e670ac7 --- /dev/null +++ b/ajde/testdata/bug-36071/bin/test/test.props @@ -0,0 +1 @@ +test=test
\ No newline at end of file diff --git a/ajde/testdata/bug-36071/config.lst b/ajde/testdata/bug-36071/config.lst new file mode 100644 index 000000000..4fbccffce --- /dev/null +++ b/ajde/testdata/bug-36071/config.lst @@ -0,0 +1,2 @@ +Main.java
+test/TestProperties.java
diff --git a/ajde/testdata/bug-36071/src/Main.java b/ajde/testdata/bug-36071/src/Main.java new file mode 100644 index 000000000..417fc6809 --- /dev/null +++ b/ajde/testdata/bug-36071/src/Main.java @@ -0,0 +1,22 @@ +import java.io.IOException; + +/* + * Created on 30-Jul-03 + * + * To change this generated comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ + +/** + * @author websterm + * + * To change this generated comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class Main { + + public static void main(String[] args) throws IOException { + String propsName = (args.length > 0)? args[0] : "test.props"; + new test.TestProperties().load(propsName); + } +} diff --git a/ajde/testdata/bug-36071/src/aspects/Logging.java b/ajde/testdata/bug-36071/src/aspects/Logging.java new file mode 100644 index 000000000..2e8ba485a --- /dev/null +++ b/ajde/testdata/bug-36071/src/aspects/Logging.java @@ -0,0 +1,27 @@ +/* + * Created on 30-Jul-03 + * + * To change this generated comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package aspects; + +/** + * @author websterm + * + * To change this generated comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public aspect Logging { + + pointcut methods () : + execution(* *..*(..)) && !within(Logging); + + before () : methods () { + System.err.println("> " + thisJoinPoint.getSignature().toLongString()); + } + + after () : methods () { + System.err.println("< " + thisJoinPoint.getSignature().toLongString()); + } +} diff --git a/ajde/testdata/bug-36071/src/test/TestProperties.java b/ajde/testdata/bug-36071/src/test/TestProperties.java new file mode 100644 index 000000000..18139e035 --- /dev/null +++ b/ajde/testdata/bug-36071/src/test/TestProperties.java @@ -0,0 +1,29 @@ +/* + * Created on 30-Jul-03 + * + * To change this generated comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package test; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +/** + * @author websterm + * + * To change this generated comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class TestProperties { + + public void load (String name) throws IOException { + InputStream in = getClass().getResourceAsStream(name); +// System.out.println("? load() in=" + in); + Properties props = new Properties(); + props.load(in); + in.close(); + props.list(System.out); + } +} diff --git a/ajde/testdata/bug-36071/src/test/test.props b/ajde/testdata/bug-36071/src/test/test.props new file mode 100644 index 000000000..51e670ac7 --- /dev/null +++ b/ajde/testdata/bug-36071/src/test/test.props @@ -0,0 +1 @@ +test=test
\ No newline at end of file diff --git a/ajde/testdata/bug-40943/aspects/Logging.java b/ajde/testdata/bug-40943/aspects/Logging.java new file mode 100644 index 000000000..2e8ba485a --- /dev/null +++ b/ajde/testdata/bug-40943/aspects/Logging.java @@ -0,0 +1,27 @@ +/* + * Created on 30-Jul-03 + * + * To change this generated comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package aspects; + +/** + * @author websterm + * + * To change this generated comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public aspect Logging { + + pointcut methods () : + execution(* *..*(..)) && !within(Logging); + + before () : methods () { + System.err.println("> " + thisJoinPoint.getSignature().toLongString()); + } + + after () : methods () { + System.err.println("< " + thisJoinPoint.getSignature().toLongString()); + } +} diff --git a/ajde/testdata/bug-40943/input1.jar b/ajde/testdata/bug-40943/input1.jar Binary files differnew file mode 100644 index 000000000..c6305aa57 --- /dev/null +++ b/ajde/testdata/bug-40943/input1.jar diff --git a/ajde/testdata/bug-40943/input2.jar b/ajde/testdata/bug-40943/input2.jar Binary files differnew file mode 100644 index 000000000..c6305aa57 --- /dev/null +++ b/ajde/testdata/bug-40943/input2.jar diff --git a/ajde/testdata/bug-40943/output.jar b/ajde/testdata/bug-40943/output.jar Binary files differnew file mode 100644 index 000000000..a5f38e68e --- /dev/null +++ b/ajde/testdata/bug-40943/output.jar diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java index 6d09ba59d..e1e53be97 100644 --- a/ajde/testdata/examples/coverage/ModelCoverage.java +++ b/ajde/testdata/examples/coverage/ModelCoverage.java @@ -57,7 +57,7 @@ aspect AdviceNamingCoverage { after(): named() { } after(int i, int j) returning: namedWithArgs(i, j) { } after() throwing: named() { } - after(): named() { } + after(): named() { } before(): named() { } @@ -65,7 +65,7 @@ aspect AdviceNamingCoverage { int around(int i) throws SizeException: namedWithOneArg(i) { return proceed(i); } before(): named() { } - before(int i): call(* *.mumble()) && named() && namedWithOneArg(i) { } + before(int i): call(* XXX.mumble()) && named() && namedWithOneArg(i) { } before(int i): named() && call(* *.mumble()) && namedWithOneArg(i) { } before(): call(* *.mumble()) { } diff --git a/ajde/testdata/examples/coverage/coverage.ajsym b/ajde/testdata/examples/coverage/coverage.ajsym Binary files differindex 25bc2b070..4841e0cfa 100644 --- a/ajde/testdata/examples/coverage/coverage.ajsym +++ b/ajde/testdata/examples/coverage/coverage.ajsym diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java index ecaba129d..f5fa1fc98 100644 --- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -28,6 +28,7 @@ public class AjdeTests extends TestCase { suite.addTestSuite(VersionTest.class); suite.addTestSuite(CompilerMessagesTest.class); suite.addTestSuite(AsmDeclarationsTest.class); + suite.addTestSuite(ResourceCopyTestCase.class); //$JUnit-END$ return suite; diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java index 4a73e6ee6..06297be3f 100644 --- a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java @@ -32,6 +32,7 @@ public class NullIdeManager { private static NullIdeManager ideManager = null; private NullIdeTaskListManager taskListManager = null; + private NullIdeProperties projectProperties = null; public static NullIdeManager getIdeManager() { if ( null == ideManager ) { @@ -43,7 +44,7 @@ public class NullIdeManager { public void init(String testProjectPath) { try { UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(false); - ProjectPropertiesAdapter browserProjectProperties = new NullIdeProperties(testProjectPath); + projectProperties = new NullIdeProperties(testProjectPath); taskListManager = new NullIdeTaskListManager(); EditorAdapter ajdeEditor = new NullIdeEditorAdapter(); IdeUIAdapter uiAdapter = new NullIdeUIAdapter(); @@ -53,7 +54,7 @@ public class NullIdeManager { AjdeUIManager.getDefault().init( ajdeEditor, taskListManager, - browserProjectProperties, + projectProperties, preferencesAdapter, uiAdapter, new IconRegistry(), diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java index 2f12d7866..90203e61f 100644 --- a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java @@ -14,9 +14,11 @@ package org.aspectj.ajde; -import java.io.File; +import java.io.*; import java.util.*; +import org.aspectj.util.FileUtil; + /** * @author Mik Kersten */ @@ -102,6 +104,23 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { public Set getInJars( ) { return inJars; } + + public Map getSourcePathResources() { + File srcBase = new File(getProjectSourcePath()); + File[] fromResources = FileUtil.listFiles(srcBase, new FileFilter() { + public boolean accept(File pathname) { + String name = pathname.getName().toLowerCase(); + return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj"); + } + }); + Map map = new HashMap(); + for (int i = 0; i < fromResources.length; i++) { + String normPath = FileUtil.normalizedPath(fromResources[i] ,srcBase); + map.put(normPath, fromResources[i]); + + } + return map; + } public void setOutJar( String jar ){ this.outJar = jar; } diff --git a/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java b/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java new file mode 100644 index 000000000..2b499edbe --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java @@ -0,0 +1,196 @@ +/* + * Created on 31-Jul-2003 + * + * To change the template for this generated file go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +package org.aspectj.ajde; + +import java.io.*; +import java.util.*; +import java.util.zip.*; + +import org.aspectj.util.FileUtil; + +/** + * @author websterm + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class ResourceCopyTestCase extends AjdeTestCase { + + public static final String PROJECT_DIR = "bug-36071"; + public static final String srcDir = PROJECT_DIR + "/src"; + public static final String binDir = PROJECT_DIR + "/bin"; + + public static final String injar1 = "testdata/bug-40943/input1.jar"; + public static final String injar2 = "testdata/bug-40943/input2.jar"; + public static final String outjar = "testdata/bug-40943/output.jar"; + + /** + * Constructor for JarResourceCopyTestCase. + * @param arg0 + */ + public ResourceCopyTestCase(String arg0) { + super(arg0); + } + + /* + * Ensure the output directpry in clean + */ + protected void setUp() throws Exception { + super.setUp(PROJECT_DIR); + FileUtil.deleteContents(new File(binDir)); + } + + public void testSrcToBin () { + doSynchronousBuild("config.lst"); + assertTrue(new java.io.File("testdata/bug-36071").getAbsolutePath(), compareDirs("src", "bin")); + } + +// public void testInjarsToBin () { +// List args = new ArrayList(); +// args.add("-injars"); +// args.add(injar1); +// +// args.add("-d"); +// args.add(binDir); +// +// args.add("-classpath"); +// args.add("../runtime/bin"); +// +// args.add("testdata/bug-40943/aspects/Logging.java"); +// +// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); +// +// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJarToDirs(injar1,binDir)); +// } +// +// public void testInjarsToOutjar () { +// List args = new ArrayList(); +// args.add("-injars"); +// args.add(injar1); +// +// args.add("-outjar"); +// args.add(outjar); +// +// args.add("-classpath"); +// args.add("../runtime/bin"); +// +// args.add("testdata/bug-40943/aspects/Logging.java"); +// +// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); +// +// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJars(injar1,outjar)); +// } +// +// +// public void test2InjarsToOutjar () { +// System.err.println("? test2InjarsToOutjar()"); +// List args = new ArrayList(); +// args.add("-injars"); +// args.add(injar1 + ";" + injar2); +// +// args.add("-outjar"); +// args.add(outjar); +// +// args.add("-classpath"); +// args.add("../runtime/bin"); +// +// args.add("testdata/bug-40943/aspects/Logging.java"); +// +// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); +// +// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJars(injar1,outjar)); +// } + + /* + * Ensure -outjar conatins all non-Java resouces from injars + */ + public boolean compareDirs (String indirName, String outdirName) { + File srcBase = openFile(indirName); + File binBase = openFile(outdirName); + File[] fromResources = FileUtil.listFiles(srcBase,aspectjResourceFileFilter); + File[] toResources = FileUtil.listFiles(binBase,aspectjResourceFileFilter); + + HashSet resources = new HashSet(); + for (int i = 0; i < fromResources.length; i++) { + resources.add(FileUtil.normalizedPath(fromResources[i],srcBase)); + } + + for (int i = 0; i < toResources.length; i++) { + String fileName = FileUtil.normalizedPath(toResources[i],binBase); + boolean b = resources.remove(fileName); + assertTrue(fileName,b); + } + + assertTrue(resources.toString(), resources.isEmpty()); + return true; + } + + /* + * Ensure -outjar conatins all non-Java resouces from injars + */ + public boolean compareJarToDirs (String injarName , String outdirName) { + File baseDir = new File(binDir); + System.err.println("? compareJarToDirs() baseDir='" + baseDir + "'"); + File[] files = FileUtil.listFiles(baseDir,aspectjResourceFileFilter); + for (int i = 0; i < files.length; i++) { + System.err.println("? compareJarToDirs() name='" + files[i] + "'"); + } + + return false; + } + + /* + * Ensure -outjar conatins all non-Java resouces from injars + */ + public boolean compareJars (String injarName , String outjarName) { + + HashSet resources = new HashSet(); + + try { + File injarFile = new File(injarName); + File outjarFile = new File(outjarName); + assertTrue("outjar older than injar",(outjarFile.lastModified() > injarFile.lastModified())); + + ZipInputStream injar = new ZipInputStream(new java.io.FileInputStream(injarFile)); + ZipEntry entry; + while (null != (entry = injar.getNextEntry())) { + String fileName = entry.getName(); + if (!fileName.endsWith(".class")) { + resources.add(fileName); + } + injar.closeEntry(); + } + injar.close(); + + ZipInputStream outjar = new ZipInputStream(new java.io.FileInputStream(outjarFile)); + while (null != (entry = outjar.getNextEntry())) { + String fileName = entry.getName(); + if (!fileName.endsWith(".class")) { + boolean b = resources.remove(fileName); + assertTrue(fileName,b); + } + outjar.closeEntry(); + } + outjar.close(); + + assertTrue(resources.toString(),resources.isEmpty()); + } + catch (IOException ex) { + fail(ex.toString()); + } + + return true; + } + + public static final FileFilter aspectjResourceFileFilter = new FileFilter() { + public boolean accept(File pathname) { + String name = pathname.getName().toLowerCase(); + return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj"); + } + }; + +} |