]> source.dussan.org Git - aspectj.git/commitdiff
fix for reported bug with invalid classpath entries (from the environment)
authorjhugunin <jhugunin>
Wed, 7 May 2003 20:29:39 +0000 (20:29 +0000)
committerjhugunin <jhugunin>
Wed, 7 May 2003 20:29:39 +0000 (20:29 +0000)
being reported as errors.  These are now just info messages.

org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java

index b64b095f69dd7163eef99c3eae75c5d9fd9a2003..c5dd98dea55a2eb28fbc1da12b076c4b1a816d54 100644 (file)
@@ -122,13 +122,25 @@ public class BuildArgParser extends Main {
                 }
             }
                                
-                       List javaArgList = parser.getUnparsedArgs();
+                       List javaArgList = new ArrayList();
+                       
                        //      disable all special eclipse warnings by default
                        //??? might want to instead override getDefaultOptions()
-                       javaArgList.add(0, "-warn:none"); 
-                       if (javaArgList.size() != 0) {
+                       javaArgList.add("-warn:none");
+                       
+                       // these next four lines are some nonsense to fool the eclipse batch compiler
+                       // without these it will go searching for reasonable values from properties
+                       //TODO fix org.eclipse.jdt.internal.compiler.batch.Main so this hack isn't needed
+                       javaArgList.add("-classpath");
+                       javaArgList.add(System.getProperty("user.dir"));
+                       javaArgList.add("-bootclasspath");
+                       javaArgList.add(System.getProperty("user.dir"));
+                       
+                       javaArgList.addAll(parser.getUnparsedArgs());
+
+//                     if (javaArgList.size() != 0) {
                                super.configure((String[])javaArgList.toArray(new String[javaArgList.size()]));
-                       }
+//                     }
                        
                        if (buildConfig.getSourceRoots() != null) {
                                for (Iterator i = buildConfig.getSourceRoots().iterator(); i.hasNext(); ) {
@@ -210,13 +222,12 @@ public class BuildArgParser extends Main {
         }
         addExtDirs(extdirs, ret);
 
-               if ((classpaths == null || classpaths.length == 0) ||
-                       (classpaths != null && classpaths[0] == ".")) {
+               if (parser.classpath == null) {
                        //??? this puts the compiler's classes on the classpath
                        //??? this is ajc-1.0 compatible
                        addClasspath(System.getProperty("java.class.path", ""), ret);
                } else {
-               ret.addAll(Arrays.asList(classpaths));
+               addClasspath(parser.classpath, ret);
                }       
                
                //??? eclipse seems to put outdir on the classpath
@@ -253,7 +264,8 @@ public class BuildArgParser extends Main {
     
     // !!! extract error handling to be common so that the IDEs can use it
     private class AjcConfigParser extends ConfigParser {
-        private String bootclasspath = null;
+               private String bootclasspath = null;
+               private String classpath = null;
         private String extdirs = null;
         private List unparsedArgs = new ArrayList();
                private AjBuildConfig buildConfig;
@@ -408,9 +420,16 @@ public class BuildArgParser extends Main {
                                if (args.size() > nextArgIndex) {
                                        bootclasspath = ((ConfigParser.Arg)args.get(nextArgIndex)).getValue();
                                        args.remove(args.get(nextArgIndex));    
-                } else {
-                    showError("-bootclasspath requires classpath entries");
-                }
+                               } else {
+                                       showError("-bootclasspath requires classpath entries");
+                               }
+                       } else if (arg.equals("-classpath")) {
+                               if (args.size() > nextArgIndex) {
+                                       classpath = ((ConfigParser.Arg)args.get(nextArgIndex)).getValue();
+                                       args.remove(args.get(nextArgIndex));    
+                               } else {
+                                       showError("-classpath requires classpath entries");
+                               }
                        } else if (arg.equals("-extdirs")) {
                                if (args.size() > nextArgIndex) {
                                        extdirs = ((ConfigParser.Arg)args.get(nextArgIndex)).getValue();
@@ -421,12 +440,12 @@ public class BuildArgParser extends Main {
             // error on directory unless -d, -{boot}classpath, or -extdirs
             } else if (arg.equals("-d")) {
                 dirLookahead(arg, args, nextArgIndex);
-            } else if (arg.equals("-classpath")) {
-                dirLookahead(arg, args, nextArgIndex);
-            } else if (arg.equals("-bootclasspath")) {
-                dirLookahead(arg, args, nextArgIndex);
-            } else if (arg.equals("-extdirs")) {
-                dirLookahead(arg, args, nextArgIndex);
+//            } else if (arg.equals("-classpath")) {
+//                dirLookahead(arg, args, nextArgIndex);
+//            } else if (arg.equals("-bootclasspath")) {
+//                dirLookahead(arg, args, nextArgIndex);
+//            } else if (arg.equals("-extdirs")) {
+//                dirLookahead(arg, args, nextArgIndex);
             } else if (new File(arg).isDirectory()) {
                 showError("dir arg not permitted: " + arg);
                        } else {
index ca597f2c8a66967972188227a20a95f8050b6af0..a340565a67dd0a2a0857dbf0b82d2c5d18cb66e3 100644 (file)
@@ -58,7 +58,8 @@ public class BuildArgParserTestCase extends TestCase {
                        config.getClasspath().contains("2.jar"));
     
                config = parser.genBuildConfig(new String[] { "-1.3" }, messageWriter);
-            err = parser.getOtherMessages(true);       
+               // these errors are deffered to the compiler now
+            //err = parser.getOtherMessages(true);       
             //!!!assertTrue(err, null == err);
                assertTrue(
                        config.getClasspath().toString(),
@@ -79,8 +80,9 @@ public class BuildArgParserTestCase extends TestCase {
                        
                config = parser.genBuildConfig(new String[] { 
                        "-classpath", ENTRY, "-1.4" }, messageWriter);
-            err = parser.getOtherMessages(true);       
-            assertTrue("expected errors for missing jars", null != err);
+                       //                      these errors are deffered to the compiler now
+            //err = parser.getOtherMessages(true);       
+            //assertTrue("expected errors for missing jars", null != err);
                assertTrue(
                        config.getClasspath().toString(),
                        config.getClasspath().contains("1.jar"));
index 14736ab994dcde7abf55e5ffb9c49def4e68dd5e..46430375342918354be7b698890ce889123ebb6b 100644 (file)
 package org.aspectj.ajdt.internal.compiler.batch;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.aspectj.ajdt.ajc.AjdtCommand;
 import org.aspectj.bridge.ICommand;
+import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.MessageHandler;
 
 /**
@@ -100,6 +102,26 @@ public class BasicCommandTestCase extends CommandTestCase {
                
                runCompiler(args, new int[] {2});
        }
+       public void testMissingJarError() {
+               List args = new ArrayList();
+
+               args.add("-d");
+               args.add("out");
+               
+               args.add("-classpath");
+               args.add("../runtime/bin;../lib/junit/junit.jar;../testing-client/bin;not_found_anywhere.jar");
+               args.add("testdata/src1/ThisAndModifiers.java");
+               
+               ICommand command = new AjdtCommand();
+               MessageHandler myHandler = new MessageHandler();
+               //myHandler.setInterceptor(org.aspectj.tools.ajc.Main.MessagePrinter.TERSE);
+               boolean result = command.runCommand((String[])args.toArray(new String[args.size()]), myHandler);
+
+               //System.err.println("messages: " + Arrays.asList(myHandler.getMessages(IMessage.INFO, true)));
+               // DON'T yet have a way of testing that we actually got a particular info message
+               assertEquals("only info for missing jar", 0, myHandler.getErrors().length);
+
+       }
        public void testMissingRuntimeError() {
                List args = new ArrayList();
 
@@ -108,7 +130,7 @@ public class BasicCommandTestCase extends CommandTestCase {
                
                args.add("-classpath");
                args.add("../lib/junit/junit.jar;../testing-client/bin");
-               args.add("testdata/src1/Xlint.java");
+               args.add("testdata/src1/ThisAndModifiers.java");
                
                ICommand command = new AjdtCommand();
                MessageHandler myHandler = new MessageHandler();