8205116: jdeps --system $java.home fails with IAE

Reviewed-by: alanb, lancea
This commit is contained in:
Mandy Chung 2018-06-15 13:08:32 -07:00
parent edbda00716
commit 1a4997b484
2 changed files with 17 additions and 3 deletions
src/jdk.jdeps/share/classes/com/sun/tools/jdeps
test/langtools/tools/jdeps

@ -347,7 +347,7 @@ public class JdepsConfiguration implements AutoCloseable {
this.root = null;
this.systemModules = Collections.emptyMap();
} else {
if (Files.isRegularFile(Paths.get(javaHome, "lib", "modules")))
if (!Files.isRegularFile(Paths.get(javaHome, "lib", "modules")))
throw new IllegalArgumentException("Invalid java.home: " + javaHome);
// alternate java.home

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018, 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
@ -23,7 +23,7 @@
/*
* @test
* @bug 8168386
* @bug 8168386 8205116
* @summary Test option validation
* @modules jdk.jdeps
* @library lib
@ -89,4 +89,18 @@ public class Options {
assertTrue(jdeps.run(true) != 0);
return jdeps;
}
@Test
public void testSystemOption() {
JdepsRunner jdeps;
// valid path
jdeps = new JdepsRunner("--check", "java.base", "--system", System.getProperty("java.home"));
assertTrue(jdeps.run(true) == 0);
// invalid path
jdeps = new JdepsRunner("--check", "java.base", "--system", "bad");
assertTrue(jdeps.run(true) != 0);
jdeps.outputContains("invalid path: bad");
}
}