8149402: "-group" option issue for classes from default package
authorksrini
Thu, 07 Dec 2017 14:21:25 -0800
changeset 48215 b8b124236073
parent 48214 c3bf1ae9c51d
child 48216 e3b6cb90d7ce
8149402: "-group" option issue for classes from default package Reviewed-by: jjg
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java
test/langtools/jdk/javadoc/doclet/testGroupOption/C.java
test/langtools/jdk/javadoc/doclet/testGroupOption/InUnnamedPackage.java
test/langtools/jdk/javadoc/doclet/testGroupOption/TestGroupOption.java
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java	Thu Dec 07 14:23:52 2017 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java	Thu Dec 07 14:21:25 2017 -0800
@@ -290,7 +290,7 @@
             groupList.add(defaultGroupName);
         }
         for (PackageElement pkg : packages) {
-            String pkgName = pkg.isUnnamed() ? null : configuration.utils.getPackageName(pkg);
+            String pkgName = configuration.utils.getPackageName(pkg);
             String groupName = pkg.isUnnamed() ? null : elementNameGroupMap.get(pkgName);
             // if this package is not explicitly assigned to a group,
             // try matching it to group specified by regular expression
--- a/test/langtools/jdk/javadoc/doclet/testGroupOption/C.java	Thu Dec 07 14:23:52 2017 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class C {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testGroupOption/InUnnamedPackage.java	Thu Dec 07 14:21:25 2017 -0800
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class InUnnamedPackage {}
--- a/test/langtools/jdk/javadoc/doclet/testGroupOption/TestGroupOption.java	Thu Dec 07 14:23:52 2017 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testGroupOption/TestGroupOption.java	Thu Dec 07 14:21:25 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug      4924383
- * @summary  Test to make sure the -group option does not cause a bad warning
- *           to be printed. Test for the group defined using patterns.
+ * @bug      4924383 8149402
+ * @summary  Test to make sure the -group option works correctly
+ *           with the given pattern usages.
  * @author   jamieh
  * @library  ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -55,8 +55,7 @@
                 "-group");
     }
 
-    // @Test
-    // @ignore 8149402
+     @Test
     // Make sure the "Other packages" section is printed and the header for empty section is not.
     // Make sure that the headers of group that is defined using patterns are printed.
     void test2() {
@@ -66,7 +65,7 @@
                 "-group", "Group abc*", "abc*",
                 "-group", "Empty group", "qwerty*",
                 "-group", "Group a*", "a*",
-                "pkg1", "pkg2", "pkg3", "abc1",  "abc2", "abc3", "other", testSrc("C.java"));
+                "pkg1", "pkg2", "pkg3", "abc1",  "abc2", "abc3", "other", testSrc("InUnnamedPackage.java"));
         checkExit(Exit.OK);
 
         checkOutput("overview-summary.html", true, "Group pkg*", "Group abc*", "Other Packages");