From c509c6f751a553cc85d0210a408681f4f3ae05cb Mon Sep 17 00:00:00 2001 From: jhugunin Date: Tue, 27 May 2003 17:35:13 +0000 Subject: [PATCH] fix and test for Bugzilla Bug 38131 ajc needs -d . option while correctly compiling classes from subpackage --- .../internal/core/builder/AjBuildManager.java | 7 +++-- .../testdata/src1/WrongPackage.java | 10 ++++++ .../compiler/batch/BasicCommandTestCase.java | 31 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 org.aspectj.ajdt.core/testdata/src1/WrongPackage.java 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 336f02da8..973be83e1 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 @@ -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 index 000000000..5237fca51 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/WrongPackage.java @@ -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 diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java index 464303753..dff6f8144 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java @@ -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(); + + + } } -- 2.39.5