1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
32
32
import java .io .FileInputStream ;
33
33
import java .io .FileNotFoundException ;
34
34
import java .io .IOException ;
35
- import java .nio .file .FileSystems ;
36
35
import java .nio .file .Files ;
37
36
import java .nio .file .Path ;
38
37
import java .nio .file .Paths ;
@@ -55,7 +54,7 @@ public static void main(String[] args) throws Exception {
55
54
return ;
56
55
}
57
56
58
- Path jdk8Path = getJdk8Path (jdk8Home );
57
+ Path jdk8Path = Paths . get (jdk8Home );
59
58
if (!isJdk8 (jdk8Path )) {
60
59
System .err .println ("This test is only for JDK 8. Skip testing" );
61
60
return ;
@@ -102,16 +101,14 @@ private static void execCmd(List<String> command){
102
101
}
103
102
}
104
103
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
+ }
113
110
Properties props = new Properties ();
114
- try (FileInputStream in = new FileInputStream (file )) {
111
+ try (FileInputStream in = new FileInputStream (releaseFile )) {
115
112
props .load (in );
116
113
}
117
114
0 commit comments