mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 18:44:38 +02:00
8167965: (jdeprscan) using --release option with 8 or earlier throws exception
Reviewed-by: mchung
This commit is contained in:
parent
7fa122e6f9
commit
1f91f70a58
2 changed files with 60 additions and 2 deletions
|
@ -384,14 +384,14 @@ public class Main implements DiagnosticListener<JavaFileObject> {
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
} else {
|
} else {
|
||||||
// TODO: kind of a hack...
|
// TODO: kind of a hack...
|
||||||
// Create a throwaway compilation task with options "-release N"
|
// Create a throwaway compilation task with options "--release N"
|
||||||
// which has the side effect of setting the file manager's
|
// which has the side effect of setting the file manager's
|
||||||
// PLATFORM_CLASS_PATH to the right value.
|
// PLATFORM_CLASS_PATH to the right value.
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm =
|
StandardJavaFileManager fm =
|
||||||
compiler.getStandardFileManager(this, null, StandardCharsets.UTF_8);
|
compiler.getStandardFileManager(this, null, StandardCharsets.UTF_8);
|
||||||
JavaCompiler.CompilationTask task =
|
JavaCompiler.CompilationTask task =
|
||||||
compiler.getTask(null, fm, this, List.of("-release", release), null, null);
|
compiler.getTask(null, fm, this, List.of("--release", release), null, null);
|
||||||
List<Path> paths = new ArrayList<>();
|
List<Path> paths = new ArrayList<>();
|
||||||
for (Path p : fm.getLocationAsPaths(StandardLocation.PLATFORM_CLASS_PATH)) {
|
for (Path p : fm.getLocationAsPaths(StandardLocation.PLATFORM_CLASS_PATH)) {
|
||||||
try (Stream<Path> str = Files.walk(p)) {
|
try (Stream<Path> str = Files.walk(p)) {
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8167965
|
||||||
|
* @summary Test proper handling of the --release option.
|
||||||
|
* @modules jdk.jdeps/com.sun.tools.jdeprscan
|
||||||
|
* @build jdk.jdeprscan.TestRelease
|
||||||
|
* @run testng jdk.jdeprscan.TestRelease
|
||||||
|
*/
|
||||||
|
|
||||||
|
package jdk.jdeprscan;
|
||||||
|
|
||||||
|
import com.sun.tools.jdeprscan.Main;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class TestRelease {
|
||||||
|
static boolean invoke(String arg) {
|
||||||
|
return Main.call(System.out, System.err, "--list", "--release", arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuccess() {
|
||||||
|
assertTrue(invoke("6"));
|
||||||
|
assertTrue(invoke("7"));
|
||||||
|
assertTrue(invoke("8"));
|
||||||
|
assertTrue(invoke("9"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailure() {
|
||||||
|
assertFalse(invoke("5"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue