New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8263940: NPE when creating default file system when default file system provider is packaged as JAR file on class path #5103
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -23,7 +23,7 @@ | ||
|
||
/** | ||
* @test | ||
* @bug 8266345 | ||
* @bug 4313887 7006126 8142968 8178380 8183320 8210112 8266345 8263940 | ||
* @modules jdk.jartool | ||
* @library /test/lib | ||
* @build SetDefaultProvider TestProvider m/* jdk.test.lib.process.ProcessTools | ||
@@ -37,11 +37,14 @@ | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.spi.ToolProvider; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import jdk.test.lib.process.ProcessTools; | ||
|
||
import org.testng.annotations.BeforeTest; | ||
import org.testng.annotations.Test; | ||
import static org.testng.Assert.*; | ||
|
||
@@ -73,6 +76,45 @@ public void testClassPath() throws Exception { | ||
assertTrue(exitValue == 0); | ||
} | ||
|
||
/** | ||
* Test override of default FileSystemProvider with a | ||
* FileSystemProvider jar and the main application on the class path. | ||
*/ | ||
public void testClassPathWithFileSystemProviderJar() throws Exception { | ||
String testClasses = System.getProperty("test.classes"); | ||
Path jar = Path.of("testFileSystemProvider.jar"); | ||
Files.deleteIfExists(jar); | ||
createFileSystemProviderJar(jar, Path.of(testClasses)); | ||
String classpath = jar + File.pathSeparator + testClasses | ||
+ File.separator + "modules" + File.separator + "m"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ends up with two copies of TestFIleSystemProvider on the class path. I think we should compile TestProvider to a different directory. That will eliminate the need to filter the classes when creating the JAR file. |
||
int exitValue = exec(SET_DEFAULT_FSP, "-cp", classpath, "p.Main"); | ||
assertTrue(exitValue == 0); | ||
} | ||
|
||
/** | ||
* Creates a JAR containing the FileSystemProvider used to override the | ||
* default FileSystemProvider | ||
*/ | ||
private void createFileSystemProviderJar(Path jar, Path dir) throws IOException { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this test, the supporting methods are at the end of the source file, probably should keep it consistent. |
||
List<String> args = new ArrayList<>(); | ||
args.add("--create"); | ||
args.add("--file=" + jar); | ||
try (Stream<Path> stream = Files.list(dir)) { | ||
List<String> paths = stream | ||
.map(path -> path.getFileName().toString()) | ||
.filter(f -> f.startsWith("TestProvider")) | ||
.toList(); | ||
for(var p : paths) { | ||
args.add("-C"); | ||
args.add(dir.toString()); | ||
args.add(p); | ||
} | ||
} | ||
int ret = JAR_TOOL.run(System.out, System.out, args.toArray(new String[0])); | ||
assertTrue(ret == 0); | ||
} | ||
|
||
/** | ||
* Test override of default FileSystemProvider with the main application | ||
* on the class path and a SecurityManager enabled. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for correcting the @bug tag.