8042699: sjavac does not track dependencies
authorohrstrom
Wed, 07 May 2014 23:55:41 +0200
changeset 24295 130c062a5087
parent 24294 1599838bcaba
child 24296 296e59a84663
8042699: sjavac does not track dependencies Summary: Using / in some places and . in other places break package comparisons. The fix standardizes on dots. Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/sjavac/Source.java
langtools/test/tools/sjavac/SJavac.java
langtools/test/tools/sjavac/SJavacWrapper.java
--- a/langtools/src/share/classes/com/sun/tools/sjavac/Source.java	Wed May 07 14:22:14 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/Source.java	Wed May 07 23:55:41 2014 +0200
@@ -313,7 +313,7 @@
             int sp = fn.lastIndexOf(File.separatorChar);
             String pkg = "";
             if (sp != -1) {
-                pkg = fn.substring(0,sp);
+                pkg = fn.substring(0,sp).replace('/','.');
             }
             // Is this a module-info.java file?
             if (fn.endsWith("module-info.java")) {
--- a/langtools/test/tools/sjavac/SJavac.java	Wed May 07 14:22:14 2014 -0700
+++ b/langtools/test/tools/sjavac/SJavac.java	Wed May 07 23:55:41 2014 +0200
@@ -95,15 +95,15 @@
         System.out.println("\nInitial compile of gensrc.");
         System.out.println("----------------------------");
         populate(gensrc,
-            "alfa/AINT.java",
-            "package alfa; public interface AINT { void aint(); }",
+            "alfa/omega/AINT.java",
+            "package alfa.omega; public interface AINT { void aint(); }",
 
-            "alfa/A.java",
-            "package alfa; public class A implements AINT { "+
+            "alfa/omega/A.java",
+            "package alfa.omega; public class A implements AINT { "+
                  "public final static int DEFINITION = 17; public void aint() { } }",
 
-            "alfa/AA.java",
-            "package alfa;"+
+            "alfa/omega/AA.java",
+            "package alfa.omega;"+
             "// A package private class, not contributing to the public api.\n"+
             "class AA {"+
             "   // A properly nested static inner class.\n"+
@@ -127,7 +127,7 @@
             "package beta;public interface BINT { void foo(); }",
 
             "beta/B.java",
-            "package beta; import alfa.A; public class B {"+
+            "package beta; import alfa.omega.A; public class B {"+
             "private int b() { return A.DEFINITION; } native void foo(); }");
 
         compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
@@ -151,16 +151,16 @@
         System.out.println("\nTesting that deleting AA.java deletes all");
         System.out.println("generated inner class as well as AA.class");
         System.out.println("-----------------------------------------");
-        removeFrom(gensrc, "alfa/AA.java");
+        removeFrom(gensrc, "alfa/omega/AA.java");
         compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
                 "--server:portfile=testserver,background=false", "--log=debug");
         Map<String,Long> new_bin_state = collectState(bin);
         verifyThatFilesHaveBeenRemoved(previous_bin_state, new_bin_state,
-                                       "bin/alfa/AA$1.class",
-                                       "bin/alfa/AA$AAAA.class",
-                                       "bin/alfa/AA$AAA.class",
-                                       "bin/alfa/AAAAA.class",
-                                       "bin/alfa/AA.class");
+                                       "bin/alfa/omega/AA$1.class",
+                                       "bin/alfa/omega/AA$AAAA.class",
+                                       "bin/alfa/omega/AA$AAA.class",
+                                       "bin/alfa/omega/AAAAA.class",
+                                       "bin/alfa/omega/AA.class");
 
         previous_bin_state = new_bin_state;
         Map<String,Long> new_headers_state = collectState(headers);
@@ -175,8 +175,8 @@
         System.out.println("Since we did not modify the native api of B.");
         System.out.println("-------------------------------------------------------------");
 
-        populate(gensrc,"alfa/A.java",
-                       "package alfa; public class A implements AINT { "+
+        populate(gensrc,"alfa/omega/A.java",
+                       "package alfa.omega; public class A implements AINT { "+
                  "public final static int DEFINITION = 18; public void aint() { } private void foo() { } }");
 
         compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
@@ -184,8 +184,8 @@
         Map<String,Long> new_bin_state = collectState(bin);
 
         verifyNewerFiles(previous_bin_state, new_bin_state,
-                         "bin/alfa/A.class",
-                         "bin/alfa/AINT.class",
+                         "bin/alfa/omega/A.class",
+                         "bin/alfa/omega/AINT.class",
                          "bin/beta/B.class",
                          "bin/beta/BINT.class",
                          "bin/javac_state");
@@ -202,7 +202,7 @@
         System.out.println("---------------------------------------------------------");
 
         populate(gensrc,"beta/B.java",
-                       "package beta; import alfa.A; public class B {"+
+                       "package beta; import alfa.omega.A; public class B {"+
                        "private int b() { return A.DEFINITION; } }");
 
         compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
@@ -226,7 +226,7 @@
         System.out.println("------------------------------------------------------------------------");
 
         populate(gensrc,"beta/B.java",
-                       "package beta; import alfa.A; public class B {"+
+                       "package beta; import alfa.omega.A; public class B {"+
                        "private int b() { return A.DEFINITION; } "+
                  "@java.lang.annotation.Native final static int alfa = 42; }");
 
@@ -252,7 +252,7 @@
         System.out.println("-------------------------------------------------------------------");
 
         populate(gensrc,"beta/B.java",
-                       "package beta; import alfa.A; public class B {"+
+                       "package beta; import alfa.omega.A; public class B {"+
                        "private int b() { return A.DEFINITION; } "+
                  "@java.lang.annotation.Native final static int alfa = 43; }");
 
@@ -282,8 +282,8 @@
         delete(bin);
         previous_bin_state = collectState(bin);
 
-        populate(gensrc,"alfa/A.java",
-                 "package alfa; import beta.B; import gamma.C; public class A { B b; C c; }",
+        populate(gensrc,"alfa/omega/A.java",
+                 "package alfa.omega; import beta.B; import gamma.C; public class A { B b; C c; }",
                  "beta/B.java",
                  "package beta; public class B { broken",
                  "gamma/C.java",
@@ -297,7 +297,7 @@
                 "--server:portfile=testserver,background=false");
         Map<String,Long> new_bin_state = collectState(bin);
         verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
-                                     "bin/alfa/A.class",
+                                     "bin/alfa/omega/A.class",
                                      "bin/beta/B.class",
                                      "bin/gamma/C.class",
                                      "bin/javac_state");
@@ -325,8 +325,8 @@
         delete(bin);
         previous_bin_state = collectState(bin);
 
-        populate(gensrc,"alfa/A.java",
-                 "package alfa; import beta.B; import gamma.C; public class A { B b; C c; }");
+        populate(gensrc,"alfa/omega/A.java",
+                 "package alfa.omega; import beta.B; import gamma.C; public class A { B b; C c; }");
         populate(gensrc2,"beta/B.java",
                  "package beta; public class B { broken",
                  "gamma/C.java",
@@ -341,7 +341,7 @@
         System.out.println("The first compile went well!");
         Map<String,Long> new_bin_state = collectState(bin);
         verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
-                                     "bin/alfa/A.class",
+                                     "bin/alfa/omega/A.class",
                                      "bin/javac_state");
 
         System.out.println("----- Compile with exluded beta went well!");
@@ -365,18 +365,18 @@
         delete(bin);
         previous_bin_state = collectState(bin);
 
-        populate(gensrc,"alfa/A.java",
-                 "package alfa; public class A { beta.B b; }",
+        populate(gensrc,"alfa/omega/A.java",
+                 "package alfa.omega; public class A { beta.B b; }",
                  "beta/B.java",
                  "package beta; public class B { gamma.C c; }",
                  "gamma/C.java",
-                 "package gamma; public class C { alfa.A a; }");
+                 "package gamma; public class C { alfa.omega.A a; }");
 
         compile("gensrc", "-d", "bin", "-h", "headers", "-j", "3",
                 "--server:portfile=testserver,background=false","--log=debug");
         Map<String,Long> new_bin_state = collectState(bin);
         verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
-                                     "bin/alfa/A.class",
+                                     "bin/alfa/omega/A.class",
                                      "bin/beta/B.class",
                                      "bin/gamma/C.class",
                                      "bin/javac_state");
@@ -396,17 +396,17 @@
         previous_bin_state = collectState(bin);
 
         populate(gensrc,
-                 "alfa/A.java",
-                 "package alfa; public class A { beta.B b; }",
+                 "alfa/omega/A.java",
+                 "package alfa.omega; public class A { beta.B b; }",
                  "beta/B.java",
                  "package beta; public class B { }");
 
-        compile("-x", "beta", "-src", "gensrc", "-x", "alfa", "-sourcepath", "gensrc",
+        compile("-x", "beta", "-src", "gensrc", "-x", "alfa/omega", "-sourcepath", "gensrc",
                 "-d", "bin", "--server:portfile=testserver,background=false");
 
         Map<String,Long> new_bin_state = collectState(bin);
         verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
-                                     "bin/alfa/A.class",
+                                     "bin/alfa/omega/A.class",
                                      "bin/javac_state");
     }
 
--- a/langtools/test/tools/sjavac/SJavacWrapper.java	Wed May 07 14:22:14 2014 -0700
+++ b/langtools/test/tools/sjavac/SJavacWrapper.java	Wed May 07 23:55:41 2014 +0200
@@ -26,6 +26,7 @@
  * @summary Test all aspects of sjavac.
  *
  * @bug 8004658
+ * @bug 8042699
  * @summary Add internal smart javac wrapper to solve JEP 139
  *
  * @run main SJavacWrapper