< prev index next >

test/hotspot/jtreg/runtime/LoadClass/LongBCP.java

Print this page
rev 55820 : 8191521: handle long relative path specified in -Xbootclasspath/a on windows
Reviewed-by:
   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  */


 109         // relative path length within the file system limit
 110         int fn_max_length = 255;
 111         // In AUFS file system, the maximal file name length is 242
 112         FileStore store = Files.getFileStore(new File(".").toPath());
 113         String fs_type = store.type();
 114         if ("aufs".equals(fs_type)) {
 115             fn_max_length = 242;
 116         }
 117         char[] chars = new char[fn_max_length];
 118         Arrays.fill(chars, 'y');
 119         String subPath = new String(chars);
 120         destDir = Paths.get(".", subPath);
 121 
 122         CompilerUtils.compile(sourceDir, destDir);
 123 
 124         bootCP = "-Xbootclasspath/a:" + destDir.toString();
 125         pb = ProcessTools.createJavaProcessBuilder(
 126             bootCP, "Hello");
 127 
 128         output = new OutputAnalyzer(pb.start());
 129         if (!Platform.isWindows()) {
 130             output.shouldContain("Hello World")
 131                   .shouldHaveExitValue(0);
 132         } else {
 133             output.shouldContain("Could not find or load main class Hello")
 134                   .shouldHaveExitValue(1);
 135         }
 136 
 137         // total relative path length exceeds MAX_PATH
 138         destDir = Paths.get(destDir.toString(), "yyyyyyyy");
 139 
 140         CompilerUtils.compile(sourceDir, destDir);
 141 
 142         bootCP = "-Xbootclasspath/a:" + destDir.toString();
 143         pb = ProcessTools.createJavaProcessBuilder(
 144             bootCP, "Hello");
 145 
 146         output = new OutputAnalyzer(pb.start());
 147         if (!Platform.isWindows()) {
 148             output.shouldContain("Hello World")
 149                   .shouldHaveExitValue(0);
 150         } else {
 151             output.shouldContain("Could not find or load main class Hello")
 152                   .shouldHaveExitValue(1);
 153         }
 154     }
 155 }
   1 /*
   2  * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  */


 109         // relative path length within the file system limit
 110         int fn_max_length = 255;
 111         // In AUFS file system, the maximal file name length is 242
 112         FileStore store = Files.getFileStore(new File(".").toPath());
 113         String fs_type = store.type();
 114         if ("aufs".equals(fs_type)) {
 115             fn_max_length = 242;
 116         }
 117         char[] chars = new char[fn_max_length];
 118         Arrays.fill(chars, 'y');
 119         String subPath = new String(chars);
 120         destDir = Paths.get(".", subPath);
 121 
 122         CompilerUtils.compile(sourceDir, destDir);
 123 
 124         bootCP = "-Xbootclasspath/a:" + destDir.toString();
 125         pb = ProcessTools.createJavaProcessBuilder(
 126             bootCP, "Hello");
 127 
 128         output = new OutputAnalyzer(pb.start());

 129         output.shouldContain("Hello World")
 130               .shouldHaveExitValue(0);




 131 
 132         // total relative path length exceeds MAX_PATH
 133         destDir = Paths.get(destDir.toString(), "yyyyyyyy");
 134 
 135         CompilerUtils.compile(sourceDir, destDir);
 136 
 137         bootCP = "-Xbootclasspath/a:" + destDir.toString();
 138         pb = ProcessTools.createJavaProcessBuilder(
 139             bootCP, "Hello");
 140 
 141         output = new OutputAnalyzer(pb.start());

 142         output.shouldContain("Hello World")
 143               .shouldHaveExitValue(0);




 144     }
 145 }
< prev index next >