]> source.dussan.org Git - aspectj.git/commitdiff
fix and test for Bugzilla Bug 38131
authorjhugunin <jhugunin>
Tue, 27 May 2003 17:35:13 +0000 (17:35 +0000)
committerjhugunin <jhugunin>
Tue, 27 May 2003 17:35:13 +0000 (17:35 +0000)
   ajc needs -d . option while correctly compiling classes from subpackage

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/testdata/src1/WrongPackage.java [new file with mode: 0644]
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java

index 336f02da8c8a2b6c9478e0a6aac5577871a16558..973be83e1b09e1b3fdd22c6d7ba60a4e6b7d6471 100644 (file)
@@ -419,9 +419,12 @@ public class AjBuildManager {
                                
                                File destinationPath = buildConfig.getOutputDir();
                                if (destinationPath == null) {
-                                       destinationPath = new File(extractDestinationPathFromSourceFile(unitResult));
+                                       filename = new File(filename).getName();
+                                       filename = new File(extractDestinationPathFromSourceFile(unitResult), filename).getPath();
+                               } else {
+                                       filename = new File(destinationPath, filename).getPath();
                                }
-                               filename = new File(destinationPath, filename).getPath();
+                               
                                //System.out.println("classfile: " + filename);
                                unwovenClassFiles.add(new UnwovenClassFile(filename, classFile.getBytes()));
                        }
diff --git a/org.aspectj.ajdt.core/testdata/src1/WrongPackage.java b/org.aspectj.ajdt.core/testdata/src1/WrongPackage.java
new file mode 100644 (file)
index 0000000..5237fca
--- /dev/null
@@ -0,0 +1,10 @@
+package a.b.c;
+
+public class WrongPackage {
+    public static void main(String[] args) {
+       Runnable r = new Runnable() {
+               public void run() {}
+       };
+       r.run();
+    }
+}
\ No newline at end of file
index 46430375342918354be7b698890ce889123ebb6b..dff6f8144ab6af3501055267451c8738f34667cf 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.aspectj.ajdt.internal.compiler.batch;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -139,4 +140,34 @@ public class BasicCommandTestCase extends CommandTestCase {
 
                assertEquals("error for org.aspectj.lang.JoinPoint not found", 1, myHandler.getErrors().length);
        }
+       
+       public void testImplicitOutputDir() {
+               List args = new ArrayList();
+               
+               args.add("-classpath");
+               args.add("../runtime/bin;../lib/junit/junit.jar;../testing-client/bin");
+               
+               File f1 = new File("testdata/src1/p1/Foo.class");
+               File f2 = new File("testdata/src1/WrongPackage.class");
+               File f3 = new File("testdata/src1/WrongPackage$1.class");
+               
+               if (f1.exists()) f1.delete();
+               if (f2.exists()) f2.delete();
+               if (f3.exists()) f3.delete();
+               
+               args.add("testdata/src1/p1/Foo.java");
+               args.add("testdata/src1/WrongPackage.java");
+               
+               runCompiler(args, NO_ERRORS);
+               
+               assertTrue(f1.getPath(), f1.exists());
+               assertTrue(f2.getPath(), f2.exists());
+               assertTrue(f3.getPath(), f3.exists());
+               
+               if (f1.exists()) f1.delete();
+               if (f2.exists()) f2.delete();
+               if (f3.exists()) f3.delete();
+               
+
+       }
 }