11/*
2- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3232import java .io .FileInputStream ;
3333import java .io .FileNotFoundException ;
3434import java .io .IOException ;
35- import java .nio .file .FileSystems ;
3635import java .nio .file .Files ;
3736import java .nio .file .Path ;
3837import java .nio .file .Paths ;
@@ -55,7 +54,7 @@ public static void main(String[] args) throws Exception {
5554 return ;
5655 }
5756
58- Path jdk8Path = getJdk8Path (jdk8Home );
57+ Path jdk8Path = Paths . get (jdk8Home );
5958 if (!isJdk8 (jdk8Path )) {
6059 System .err .println ("This test is only for JDK 8. Skip testing" );
6160 return ;
@@ -102,16 +101,14 @@ private static void execCmd(List<String> command){
102101 }
103102 }
104103
105- private static Path getJdk8Path (String jdk8Home ) {
106- Path jdk8Path = Paths .get (jdk8Home );
107- // It is possible to point to the path of java executable by ${JT_JAVA}
108- return Files .isDirectory (jdk8Path )? jdk8Path : jdk8Path .getParent ().getParent ();
109- }
110-
111- private static boolean isJdk8 (Path jdk8Home ) throws FileNotFoundException , IOException {
112- File file = jdk8Home .resolve ("release" ).toFile ();
104+ private static boolean isJdk8 (Path jdk8HomePath ) throws IOException {
105+ File releaseFile = jdk8HomePath .resolve ("release" ).toFile ();
106+ if (!releaseFile .exists ()) {
107+ throw new RuntimeException (releaseFile .getPath () +
108+ " doesn't exist" );
109+ }
113110 Properties props = new Properties ();
114- try (FileInputStream in = new FileInputStream (file )) {
111+ try (FileInputStream in = new FileInputStream (releaseFile )) {
115112 props .load (in );
116113 }
117114
0 commit comments