8231179: Investigate why tools/javac/options/BCPOrSystemNotSpecified.java fails on Window

Reviewed-by: vromero
This commit is contained in:
Guoxiong Li 2021-04-24 02:18:31 +00:00 committed by Vicente Romero
parent d87a4c3b56
commit 4b7f027407
2 changed files with 9 additions and 4 deletions

View File

@ -50,7 +50,6 @@ tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java
tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java 8057687 generic-all emit correct byte code an attributes for type annotations
tools/javac/warnings/suppress/TypeAnnotations.java 8057683 generic-all improve ordering of errors with type annotations
tools/javac/modules/SourceInSymlinkTest.java 8180263 windows-all fails when run on a subst drive
tools/javac/options/BCPOrSystemNotSpecified.java 8231179 windows-all fails when creating a test bootclasspath
###########################################################################
#

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, 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
@ -28,6 +28,7 @@
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.compiler/com.sun.tools.javac.file
* @build toolbox.ToolBox toolbox.JavacTask toolbox.TestRunner
* @run main BCPOrSystemNotSpecified
*/
@ -43,6 +44,7 @@ import java.nio.file.Files;
import java.util.EnumSet;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
import toolbox.JavacTask;
@ -51,6 +53,8 @@ import toolbox.Task.Expect;
import toolbox.TestRunner;
import toolbox.ToolBox;
import com.sun.tools.javac.file.PathFileObject;
public class BCPOrSystemNotSpecified extends TestRunner {
private final ToolBox tb = new ToolBox();
@ -192,7 +196,7 @@ public class BCPOrSystemNotSpecified extends TestRunner {
}
private void prepareBCP(Path target) throws IOException {
try (JavaFileManager jfm = ToolProvider.getSystemJavaCompiler()
try (StandardJavaFileManager jfm = ToolProvider.getSystemJavaCompiler()
.getStandardFileManager(null, null, null)) {
for (String pack : new String[] {"", "java.lang", "java.lang.annotation", "jdk.internal.javac"}) {
JavaFileManager.Location javaBase =
@ -206,7 +210,9 @@ public class BCPOrSystemNotSpecified extends TestRunner {
Files.createDirectories(targetDir);
try (InputStream in = file.openInputStream()) {
String sourcePath = file.getName();
int sepPos = sourcePath.lastIndexOf(fileSep);
// Here, we should use file system separator instead of the operating system separator.
String fileSystemSep = jfm.asPath(file).getFileSystem().getSeparator();
int sepPos = sourcePath.lastIndexOf(fileSystemSep);
String fileName = sourcePath.substring(sepPos + 1);
Files.copy(in, targetDir.resolve(fileName));
}