Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/nio/file/Path/PathOps.java
38828 views
/*1* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test24* @bug 4313887 6838333 6925932 7006126 803794525* @summary Unit test for java.nio.file.Path path operations26*/2728import java.nio.file.*;2930public class PathOps {3132static final java.io.PrintStream out = System.out;3334private String input;35private Path path;36private Exception exc;3738private PathOps(String first, String... more) {39out.println();40input = first;41try {42path = FileSystems.getDefault().getPath(first, more);43out.format("%s -> %s", first, path);44} catch (Exception x) {45exc = x;46out.format("%s -> %s", first, x);47}48out.println();49}5051Path path() {52return path;53}5455void fail() {56throw new RuntimeException("PathOps failed");57}5859void checkPath() {60if (path == null) {61throw new InternalError("path is null");62}63}6465void check(Object result, String expected) {66out.format("\tExpected: %s\n", expected);67out.format("\tActual: %s\n", result);68if (result == null) {69if (expected == null) return;70} else {71// compare string representations72if (expected != null && result.toString().equals(expected.toString()))73return;74}75fail();76}7778void check(Object result, boolean expected) {79check(result, Boolean.toString(expected));80}8182PathOps root(String expected) {83out.println("check root");84checkPath();85check(path.getRoot(), expected);86return this;87}8889PathOps parent(String expected) {90out.println("check parent");91checkPath();92check(path.getParent(), expected);93return this;94}9596PathOps name(String expected) {97out.println("check name");98checkPath();99check(path.getFileName(), expected);100return this;101}102103PathOps element(int index, String expected) {104out.format("check element %d\n", index);105checkPath();106check(path.getName(index), expected);107return this;108}109110PathOps subpath(int startIndex, int endIndex, String expected) {111out.format("test subpath(%d,%d)\n", startIndex, endIndex);112checkPath();113check(path.subpath(startIndex, endIndex), expected);114return this;115}116117PathOps starts(String prefix) {118out.format("test startsWith with %s\n", prefix);119checkPath();120Path s = FileSystems.getDefault().getPath(prefix);121check(path.startsWith(s), true);122return this;123}124125PathOps notStarts(String prefix) {126out.format("test not startsWith with %s\n", prefix);127checkPath();128Path s = FileSystems.getDefault().getPath(prefix);129check(path.startsWith(s), false);130return this;131}132133PathOps ends(String suffix) {134out.format("test endsWith %s\n", suffix);135checkPath();136Path s = FileSystems.getDefault().getPath(suffix);137check(path.endsWith(s), true);138return this;139}140141PathOps notEnds(String suffix) {142out.format("test not endsWith %s\n", suffix);143checkPath();144Path s = FileSystems.getDefault().getPath(suffix);145check(path.endsWith(s), false);146return this;147}148149PathOps absolute() {150out.println("check path is absolute");151checkPath();152check(path.isAbsolute(), true);153return this;154}155156PathOps notAbsolute() {157out.println("check path is not absolute");158checkPath();159check(path.isAbsolute(), false);160return this;161}162163PathOps resolve(String other, String expected) {164out.format("test resolve %s\n", other);165checkPath();166check(path.resolve(other), expected);167return this;168}169170PathOps resolveSibling(String other, String expected) {171out.format("test resolveSibling %s\n", other);172checkPath();173check(path.resolveSibling(other), expected);174return this;175}176177PathOps relativize(String other, String expected) {178out.format("test relativize %s\n", other);179checkPath();180Path that = FileSystems.getDefault().getPath(other);181check(path.relativize(that), expected);182return this;183}184185PathOps normalize(String expected) {186out.println("check normalized path");187checkPath();188check(path.normalize(), expected);189return this;190}191192PathOps string(String expected) {193out.println("check string representation");194checkPath();195check(path, expected);196return this;197}198199PathOps invalid() {200if (!(exc instanceof InvalidPathException)) {201out.println("InvalidPathException not thrown as expected");202fail();203}204return this;205}206207static PathOps test(String first, String... more) {208return new PathOps(first, more);209}210211// -- PathOpss --212213static void header(String s) {214out.println();215out.println();216out.println("-- " + s + " --");217}218219static void doWindowsTests() {220header("Windows specific tests");221222// construction223test("C:\\")224.string("C:\\");225test("C:\\", "")226.string("C:\\");227test("C:\\", "foo")228.string("C:\\foo");229test("C:\\", "\\foo")230.string("C:\\foo");231test("C:\\", "foo\\")232.string("C:\\foo");233test("foo", "bar", "gus")234.string("foo\\bar\\gus");235test("")236.string("");237test("", "C:\\")238.string("C:\\");239test("", "foo", "", "bar", "", "\\gus")240.string("foo\\bar\\gus");241242// all components present243test("C:\\a\\b\\c")244.root("C:\\")245.parent("C:\\a\\b")246.name("c");247test("C:a\\b\\c")248.root("C:")249.parent("C:a\\b")250.name("c");251test("\\\\server\\share\\a")252.root("\\\\server\\share\\")253.parent("\\\\server\\share\\")254.name("a");255256// root component only257test("C:\\")258.root("C:\\")259.parent(null)260.name(null);261test("C:")262.root("C:")263.parent(null)264.name(null);265test("\\\\server\\share\\")266.root("\\\\server\\share\\")267.parent(null)268.name(null);269270// no root component271test("a\\b")272.root(null)273.parent("a")274.name("b");275276// name component only277test("foo")278.root(null)279.parent(null)280.name("foo");281test("")282.root(null)283.parent(null)284.name("");285286// startsWith287test("C:\\")288.starts("C:\\")289.starts("c:\\")290.notStarts("C")291.notStarts("C:")292.notStarts("");293test("C:")294.starts("C:")295.starts("c:")296.notStarts("C")297.notStarts("");298test("\\")299.starts("\\");300test("C:\\foo\\bar")301.starts("C:\\")302.starts("C:\\foo")303.starts("C:\\FOO")304.starts("C:\\foo\\bar")305.starts("C:\\Foo\\Bar")306.notStarts("C:")307.notStarts("C")308.notStarts("C:foo")309.notStarts("");310test("\\foo\\bar")311.starts("\\")312.starts("\\foo")313.starts("\\foO")314.starts("\\foo\\bar")315.starts("\\fOo\\BaR")316.notStarts("foo")317.notStarts("foo\\bar")318.notStarts("");319test("foo\\bar")320.starts("foo")321.starts("foo\\bar")322.notStarts("\\")323.notStarts("");324test("\\\\server\\share")325.starts("\\\\server\\share")326.starts("\\\\server\\share\\")327.notStarts("\\")328.notStarts("");329test("")330.starts("")331.notStarts("\\");332333// endsWith334test("C:\\")335.ends("C:\\")336.ends("c:\\")337.notEnds("\\")338.notEnds("");339test("C:")340.ends("C:")341.ends("c:")342.notEnds("");343test("\\")344.ends("\\")345.notEnds("");346test("C:\\foo\\bar")347.ends("bar")348.ends("BAR")349.ends("foo\\bar")350.ends("Foo\\Bar")351.ends("C:\\foo\\bar")352.ends("c:\\foO\\baR")353.notEnds("r")354.notEnds("\\foo\\bar")355.notEnds("");356test("\\foo\\bar")357.ends("bar")358.ends("BaR")359.ends("foo\\bar")360.ends("foO\\baR")361.ends("\\foo\\bar")362.ends("\\Foo\\Bar")363.notEnds("oo\\bar")364.notEnds("");365test("foo\\bar")366.ends("bar")367.ends("BAR")368.ends("foo\\bar")369.ends("Foo\\Bar")370.notEnds("ar")371.notEnds("");372test("\\\\server\\share")373.ends("\\\\server\\share")374.ends("\\\\server\\share\\")375.notEnds("shared")376.notEnds("\\")377.notEnds("");378test("")379.ends("")380.notEnds("\\");381382// elements383test("C:\\a\\b\\c")384.element(0, "a")385.element(1, "b")386.element(2, "c");387test("foo.bar\\gus.alice")388.element(0, "foo.bar")389.element(1, "gus.alice");390test("")391.element(0, "");392393// subpath394test("C:\\foo")395.subpath(0, 1, "foo");396test("C:foo")397.subpath(0, 1, "foo");398test("foo")399.subpath(0, 1, "foo");400test("C:\\foo\\bar\\gus")401.subpath(0, 1, "foo")402.subpath(0, 2, "foo\\bar")403.subpath(0, 3, "foo\\bar\\gus")404.subpath(1, 2, "bar")405.subpath(1, 3, "bar\\gus")406.subpath(2, 3, "gus");407test("\\\\server\\share\\foo")408.subpath(0, 1, "foo");409test("")410.subpath(0, 1, "");411412// isAbsolute413test("foo").notAbsolute();414test("C:").notAbsolute();415test("C:\\").absolute();416test("C:\\abc").absolute();417test("\\\\server\\share\\").absolute();418test("").notAbsolute();419420// resolve421test("C:\\")422.resolve("foo", "C:\\foo")423.resolve("D:\\bar", "D:\\bar")424.resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")425.resolve("C:foo", "C:\\foo")426.resolve("D:foo", "D:foo")427.resolve("", "C:\\");428test("\\")429.resolve("foo", "\\foo")430.resolve("D:bar", "D:bar")431.resolve("C:\\bar", "C:\\bar")432.resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")433.resolve("\\foo", "\\foo")434.resolve("", "\\");435test("\\foo")436.resolve("bar", "\\foo\\bar")437.resolve("D:bar", "D:bar")438.resolve("C:\\bar", "C:\\bar")439.resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")440.resolve("\\bar", "\\bar")441.resolve("", "\\foo");442test("foo")443.resolve("bar", "foo\\bar")444.resolve("D:\\bar", "D:\\bar")445.resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")446.resolve("C:bar", "C:bar")447.resolve("D:foo", "D:foo")448.resolve("", "foo");449test("C:")450.resolve("foo", "C:foo")451.resolve("", "C:");452test("\\\\server\\share\\foo")453.resolve("bar", "\\\\server\\share\\foo\\bar")454.resolve("\\bar", "\\\\server\\share\\bar")455.resolve("D:\\bar", "D:\\bar")456.resolve("\\\\other\\share\\bar", "\\\\other\\share\\bar")457.resolve("D:bar", "D:bar")458.resolve("", "\\\\server\\share\\foo");459test("")460.resolve("", "")461.resolve("foo", "foo")462.resolve("C:\\", "C:\\")463.resolve("C:foo", "C:foo")464.resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar");465466// resolveSibling467test("foo")468.resolveSibling("bar", "bar")469.resolveSibling("D:\\bar", "D:\\bar")470.resolveSibling("\\\\server\\share\\bar", "\\\\server\\share\\bar")471.resolveSibling("C:bar", "C:bar")472.resolveSibling("D:foo", "D:foo")473.resolveSibling("", "");474test("foo\\bar")475.resolveSibling("gus", "foo\\gus")476.resolveSibling("D:\\bar", "D:\\bar")477.resolveSibling("\\\\server\\share\\bar", "\\\\server\\share\\bar")478.resolveSibling("C:bar", "C:bar")479.resolveSibling("D:foo", "D:foo")480.resolveSibling("", "foo");481test("C:\\foo")482.resolveSibling("gus", "C:\\gus")483.resolveSibling("D:\\bar", "D:\\bar")484.resolveSibling("\\\\server\\share\\bar", "\\\\server\\share\\bar")485.resolveSibling("C:bar", "C:\\bar")486.resolveSibling("D:foo", "D:foo")487.resolveSibling("", "C:\\");488test("C:\\foo\\bar")489.resolveSibling("gus", "C:\\foo\\gus")490.resolveSibling("D:\\bar", "D:\\bar")491.resolveSibling("\\\\server\\share\\bar", "\\\\server\\share\\bar")492.resolveSibling("C:bar", "C:\\foo\\bar")493.resolveSibling("D:foo", "D:foo")494.resolveSibling("", "C:\\foo");495test("\\\\server\\share\\foo")496.resolveSibling("bar", "\\\\server\\share\\bar")497.resolveSibling("\\bar", "\\\\server\\share\\bar")498.resolveSibling("D:\\bar", "D:\\bar")499.resolveSibling("\\\\other\\share\\bar", "\\\\other\\share\\bar")500.resolveSibling("D:bar", "D:bar")501.resolveSibling("", "\\\\server\\share\\");502test("")503.resolveSibling("", "")504.resolveSibling("foo", "foo")505.resolveSibling("C:\\", "C:\\");506507// relativize508test("foo\\bar")509.relativize("foo\\bar", "")510.relativize("foo", "..");511test("C:\\a\\b\\c")512.relativize("C:\\a", "..\\..")513.relativize("C:\\a\\b\\c", "");514test("\\\\server\\share\\foo")515.relativize("\\\\server\\share\\bar", "..\\bar")516.relativize("\\\\server\\share\\foo", "");517test("")518.relativize("", "");519520// normalize521test("C:\\")522.normalize("C:\\");523test("C:\\.")524.normalize("C:\\");525test("C:\\..")526.normalize("C:\\");527test("\\\\server\\share")528.normalize("\\\\server\\share\\");529test("\\\\server\\share\\.")530.normalize("\\\\server\\share\\");531test("\\\\server\\share\\..")532.normalize("\\\\server\\share\\");533test("C:")534.normalize("C:");535test("C:.")536.normalize("C:");537test("C:..")538.normalize("C:..");539test("\\")540.normalize("\\");541test("\\.")542.normalize("\\");543test("\\..")544.normalize("\\");545test("foo")546.normalize("foo");547test("foo\\.")548.normalize("foo");549test("foo\\..")550.normalize("");551test("C:\\foo")552.normalize("C:\\foo");553test("C:\\foo\\.")554.normalize("C:\\foo");555test("C:\\.\\foo")556.normalize("C:\\foo");557test("C:\\foo\\..")558.normalize("C:\\");559test("C:\\..\\foo")560.normalize("C:\\foo");561test("\\\\server\\share\\foo")562.normalize("\\\\server\\share\\foo");563test("\\\\server\\share\\foo\\.")564.normalize("\\\\server\\share\\foo");565test("\\\\server\\share\\.\\foo")566.normalize("\\\\server\\share\\foo");567test("\\\\server\\share\\foo\\..")568.normalize("\\\\server\\share\\");569test("\\\\server\\share\\..\\foo")570.normalize("\\\\server\\share\\foo");571test("C:foo")572.normalize("C:foo");573test("C:foo\\.")574.normalize("C:foo");575test("C:.\\foo")576.normalize("C:foo");577test("C:foo\\..")578.normalize("C:");579test("C:..\\foo")580.normalize("C:..\\foo");581test("\\foo")582.normalize("\\foo");583test("\\foo\\.")584.normalize("\\foo");585test("\\.\\foo")586.normalize("\\foo");587test("\\foo\\..")588.normalize("\\");589test("\\..\\foo")590.normalize("\\foo");591test(".")592.normalize("");593test("..")594.normalize("..");595test("\\..\\..")596.normalize("\\");597test("..\\..\\foo")598.normalize("..\\..\\foo");599test("foo\\bar\\..")600.normalize("foo");601test("foo\\bar\\.\\..")602.normalize("foo");603test("foo\\bar\\gus\\..\\..")604.normalize("foo");605test(".\\foo\\.\\bar\\.\\gus\\..\\.\\..")606.normalize("foo");607test("")608.normalize("");609610// UNC corner cases611test("\\\\server\\share\\")612.root("\\\\server\\share\\")613.parent(null)614.name(null);615test("\\\\server")616.invalid();617test("\\\\server\\")618.invalid();619test("\\\\server\\share")620.root("\\\\server\\share\\")621.parent(null)622.name(null);623624// invalid625test(":\\foo")626.invalid();627test("C::")628.invalid();629test("C:\\?") // invalid character630.invalid();631test("C:\\*") // invalid character632.invalid();633test("C:\\abc\u0001\\foo")634.invalid();635test("C:\\\u0019\\foo")636.invalid();637test("\\\\server\u0019\\share")638.invalid();639test("\\\\server\\share\u0019")640.invalid();641test("foo\u0000\bar")642.invalid();643test("C:\\foo ") // trailing space644.invalid();645test("C:\\foo \\bar")646.invalid();647//test("C:\\foo.") // trailing dot648//.invalid();649//test("C:\\foo...\\bar")650//.invalid();651652// normalization at construction time (remove redundant and replace slashes)653test("C:/a/b/c")654.string("C:\\a\\b\\c")655.root("C:\\")656.parent("C:\\a\\b");657test("C://a//b//c")658.string("C:\\a\\b\\c")659.root("C:\\")660.parent("C:\\a\\b");661662// hashCode663header("hashCode");664int h1 = test("C:\\foo").path().hashCode();665int h2 = test("c:\\FOO").path().hashCode();666if (h1 != h2)667throw new RuntimeException("PathOps failed");668}669670static void doUnixTests() {671header("Unix specific tests");672673// construction674test("/")675.string("/");676test("/", "")677.string("/");678test("/", "foo")679.string("/foo");680test("/", "/foo")681.string("/foo");682test("/", "foo/")683.string("/foo");684test("foo", "bar", "gus")685.string("foo/bar/gus");686test("")687.string("");688test("", "/")689.string("/");690test("", "foo", "", "bar", "", "/gus")691.string("foo/bar/gus");692693// all components694test("/a/b/c")695.root("/")696.parent("/a/b")697.name("c");698699// root component only700test("/")701.root("/")702.parent(null)703.name(null);704705// no root component706test("a/b")707.root(null)708.parent("a")709.name("b");710711// name component only712test("foo")713.root(null)714.parent(null)715.name("foo");716test("")717.root(null)718.parent(null)719.name("");720721// startsWith722test("/")723.starts("/")724.notStarts("")725.notStarts("/foo");726test("/foo")727.starts("/")728.starts("/foo")729.notStarts("/f");730test("/foo/bar")731.starts("/")732.starts("/foo")733.starts("/foo/bar")734.notStarts("/f")735.notStarts("foo")736.notStarts("foo/bar");737test("foo")738.starts("foo")739.notStarts("")740.notStarts("f");741test("foo/bar")742.starts("foo")743.starts("foo/bar")744.notStarts("f")745.notStarts("/foo")746.notStarts("/foo/bar");747test("")748.starts("")749.notStarts("/");750751// endsWith752test("/")753.ends("/")754.notEnds("")755.notEnds("foo")756.notEnds("/foo");757test("/foo")758.ends("foo")759.ends("/foo")760.notEnds("fool");761test("/foo/bar")762.ends("bar")763.ends("foo/bar")764.ends("/foo/bar")765.notEnds("ar")766.notEnds("barack")767.notEnds("/bar")768.notEnds("o/bar");769test("foo")770.ends("foo")771.notEnds("")772.notEnds("oo")773.notEnds("oola");774test("foo/bar")775.ends("bar")776.ends("foo/bar")777.notEnds("r")778.notEnds("barmaid")779.notEnds("/bar");780test("foo/bar/gus")781.ends("gus")782.ends("bar/gus")783.ends("foo/bar/gus")784.notEnds("g")785.notEnds("/gus")786.notEnds("r/gus")787.notEnds("barack/gus")788.notEnds("bar/gust");789test("")790.ends("")791.notEnds("/");792793// elements794test("a/b/c")795.element(0, "a")796.element(1, "b")797.element(2, "c");798test("")799.element(0, "");800801// subpath802test("/foo")803.subpath(0, 1, "foo");804test("foo")805.subpath(0, 1, "foo");806test("/foo/bar")807.subpath(0, 1, "foo")808.subpath(1, 2, "bar")809.subpath(0, 2, "foo/bar");810test("foo/bar")811.subpath(0, 1, "foo")812.subpath(1, 2, "bar")813.subpath(0, 2, "foo/bar");814test("/foo/bar/gus")815.subpath(0, 1, "foo")816.subpath(1, 2, "bar")817.subpath(2, 3, "gus")818.subpath(0, 2, "foo/bar")819.subpath(1, 3, "bar/gus")820.subpath(0, 3, "foo/bar/gus");821test("foo/bar/gus")822.subpath(0, 1, "foo")823.subpath(1, 2, "bar")824.subpath(2, 3, "gus")825.subpath(0, 2, "foo/bar")826.subpath(1, 3, "bar/gus")827.subpath(0, 3, "foo/bar/gus");828test("")829.subpath(0, 1, "");830831// isAbsolute832test("/")833.absolute();834test("/tmp")835.absolute();836test("tmp")837.notAbsolute();838test("")839.notAbsolute();840841842// resolve843test("/tmp")844.resolve("foo", "/tmp/foo")845.resolve("/foo", "/foo")846.resolve("", "/tmp");847test("tmp")848.resolve("foo", "tmp/foo")849.resolve("/foo", "/foo")850.resolve("", "tmp");851test("")852.resolve("", "")853.resolve("foo", "foo")854.resolve("/foo", "/foo");855856// resolveSibling857test("foo")858.resolveSibling("bar", "bar")859.resolveSibling("/bar", "/bar")860.resolveSibling("", "");861test("foo/bar")862.resolveSibling("gus", "foo/gus")863.resolveSibling("/gus", "/gus")864.resolveSibling("", "foo");865test("/foo")866.resolveSibling("gus", "/gus")867.resolveSibling("/gus", "/gus")868.resolveSibling("", "/");869test("/foo/bar")870.resolveSibling("gus", "/foo/gus")871.resolveSibling("/gus", "/gus")872.resolveSibling("", "/foo");873test("")874.resolveSibling("foo", "foo")875.resolveSibling("/foo", "/foo")876.resolve("", "");877878// relativize879test("/a/b/c")880.relativize("/a/b/c", "")881.relativize("/a/b/c/d/e", "d/e")882.relativize("/a/x", "../../x")883.relativize("/x", "../../../x");884test("a/b/c")885.relativize("a/b/c/d", "d")886.relativize("a/x", "../../x")887.relativize("x", "../../../x")888.relativize("", "../../..");889test("")890.relativize("a", "a")891.relativize("a/b/c", "a/b/c")892.relativize("", "");893894// normalize895test("/")896.normalize("/");897test("foo")898.normalize("foo");899test("/foo")900.normalize("/foo");901test("")902.normalize("");903test(".")904.normalize("");905test("..")906.normalize("..");907test("/..")908.normalize("/");909test("/../..")910.normalize("/");911test("foo/.")912.normalize("foo");913test("./foo")914.normalize("foo");915test("foo/..")916.normalize("");917test("../foo")918.normalize("../foo");919test("../../foo")920.normalize("../../foo");921test("foo/bar/..")922.normalize("foo");923test("foo/bar/gus/../..")924.normalize("foo");925test("/foo/bar/gus/../..")926.normalize("/foo");927928// invalid929test("foo\u0000bar")930.invalid();931test("\u0000foo")932.invalid();933test("bar\u0000")934.invalid();935test("//foo\u0000bar")936.invalid();937test("//\u0000foo")938.invalid();939test("//bar\u0000")940.invalid();941942// normalization of input943test("//foo//bar")944.string("/foo/bar")945.root("/")946.parent("/foo")947.name("bar");948}949950static void npes() {951header("NullPointerException");952953Path path = FileSystems.getDefault().getPath("foo");954955try {956path.resolve((String)null);957throw new RuntimeException("NullPointerException not thrown");958} catch (NullPointerException npe) {959}960961try {962path.relativize(null);963throw new RuntimeException("NullPointerException not thrown");964} catch (NullPointerException npe) {965}966967try {968path.compareTo(null);969throw new RuntimeException("NullPointerException not thrown");970} catch (NullPointerException npe) {971}972973try {974path.startsWith((Path)null);975throw new RuntimeException("NullPointerException not thrown");976} catch (NullPointerException npe) {977}978979try {980path.endsWith((Path)null);981throw new RuntimeException("NullPointerException not thrown");982} catch (NullPointerException npe) {983}984985}986987public static void main(String[] args) {988// all platforms989npes();990991// operating system specific992String osname = System.getProperty("os.name");993if (osname.startsWith("Windows")) {994doWindowsTests();995} else {996doUnixTests();997}998999}1000}100110021003