< prev index next >

test/jdk/java/lang/ClassLoader/LibraryPathProperty.java

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8067951 8236075
  27  * @summary Unit test for internal ClassLoaderHelper#parsePath().
  28  *          Quoted entries should get unquoted on Windows.
  29  *          Empty entries should be replaced with dot.
  30  * @library /test/lib
  31  * @modules java.base/java.lang:open
  32  * @build jdk.test.lib.Platform
  33  * @run main LibraryPathProperty
  34  */
  35 
  36 import java.lang.reflect.Method;
  37 import java.io.File;
  38 import java.util.Arrays;
  39 import jdk.test.lib.Platform;
  40 
  41 public class LibraryPathProperty {
  42 
  43     static final String SP = File.pathSeparator;
  44     static Method method;
  45 
  46     public static void main(String[] args) throws Throwable {
  47         Class<?> klass = Class.forName("java.lang.ClassLoaderHelper");
  48         method = klass.getDeclaredMethod("parsePath", String.class);
  49         method.setAccessible(true);
  50 
  51         test("", ".");
  52         test(SP, ".", ".");
  53         test("a" + SP, "a", ".");
  54         test(SP + "b", ".", "b");
  55         test("a" + SP + SP + "b", "a", ".", "b");
  56 
  57         if (Platform.isWindows()) {
  58             // on Windows parts of paths may be quoted
  59             test("\"\"", ".");
  60             test("\"\"" + SP, ".", ".");
  61             test(SP + "\"\"", ".", ".");
  62             test("a" + SP + "\"b\"" + SP, "a", "b", ".");
  63             test(SP + "\"a\"" + SP + SP + "b", ".", "a", ".", "b");
  64             test("\"a\"" + SP + "\"b\"", "a", "b");
  65             test("\"/a/\"b" + SP + "c", "/a/b", "c");
  66             test("\"/a;b\"" + SP + "c", "/a;b", "c");
  67             test("\"/a:b\"" + SP + "c", "/a:b", "c");


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8067951 8236075
  27  * @summary Unit test for internal ClassLoaderHelper#parsePath().
  28  *          Quoted entries should get unquoted on Windows.
  29  *          Empty entries should be replaced with dot.
  30  * @library /test/lib
  31  * @modules java.base/jdk.internal.loader:open
  32  * @build jdk.test.lib.Platform
  33  * @run main LibraryPathProperty
  34  */
  35 
  36 import java.lang.reflect.Method;
  37 import java.io.File;
  38 import java.util.Arrays;
  39 import jdk.test.lib.Platform;
  40 
  41 public class LibraryPathProperty {
  42 
  43     static final String SP = File.pathSeparator;
  44     static Method method;
  45 
  46     public static void main(String[] args) throws Throwable {
  47         Class<?> klass = Class.forName("jdk.internal.loader.ClassLoaderHelper");
  48         method = klass.getDeclaredMethod("parsePath", String.class);
  49         method.setAccessible(true);
  50 
  51         test("", ".");
  52         test(SP, ".", ".");
  53         test("a" + SP, "a", ".");
  54         test(SP + "b", ".", "b");
  55         test("a" + SP + SP + "b", "a", ".", "b");
  56 
  57         if (Platform.isWindows()) {
  58             // on Windows parts of paths may be quoted
  59             test("\"\"", ".");
  60             test("\"\"" + SP, ".", ".");
  61             test(SP + "\"\"", ".", ".");
  62             test("a" + SP + "\"b\"" + SP, "a", "b", ".");
  63             test(SP + "\"a\"" + SP + SP + "b", ".", "a", ".", "b");
  64             test("\"a\"" + SP + "\"b\"", "a", "b");
  65             test("\"/a/\"b" + SP + "c", "/a/b", "c");
  66             test("\"/a;b\"" + SP + "c", "/a;b", "c");
  67             test("\"/a:b\"" + SP + "c", "/a:b", "c");
< prev index next >