author | jcbeyler |
Thu, 19 Jul 2018 18:21:24 -0700 | |
changeset 51210 | e750c1a054fa |
parent 50590 | 5fa19bad622d |
child 51712 | f0f5d23449d3 |
permissions | -rw-r--r-- |
49130
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
1 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
2 |
/* |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
3 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
5 |
* |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
9 |
* |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
14 |
* accompanied this code). |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
15 |
* |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
19 |
* |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
22 |
* questions. |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
23 |
*/ |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
24 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
25 |
/* |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
26 |
* @test |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
27 |
* @bug 8193660 |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
28 |
* @summary Check SOURCE line in "release" file for closedjdk |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
29 |
* @run main CheckSource |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
30 |
*/ |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
31 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
32 |
import java.io.BufferedReader; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
33 |
import java.io.File; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
34 |
import java.io.FileReader; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
35 |
import java.io.FileNotFoundException; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
36 |
import java.io.IOException; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
37 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
38 |
public class CheckSource { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
39 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
40 |
CheckSource(String dataFile, boolean isOpenJDK) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
41 |
// Read data files |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
42 |
readFile(dataFile, isOpenJDK); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
43 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
44 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
45 |
private void readFile(String fileName, boolean isOpenJDK) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
46 |
String fishForSOURCE = null; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
47 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
48 |
File file = new File(fileName); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
49 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
50 |
// open the stream to read in for Entries |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
51 |
try (BufferedReader buffRead = |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
52 |
new BufferedReader(new FileReader(fileName))) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
53 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
54 |
// this is the string read |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
55 |
String readIn; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
56 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
57 |
// let's read some strings! |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
58 |
while ((readIn = buffRead.readLine()) != null) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
59 |
readIn = readIn.trim(); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
60 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
61 |
// throw out blank lines |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
62 |
if (readIn.length() == 0) |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
63 |
continue; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
64 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
65 |
// grab SOURCE line |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
66 |
if (readIn.startsWith("SOURCE=")) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
67 |
fishForSOURCE = readIn; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
68 |
break; |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
69 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
70 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
71 |
} catch (FileNotFoundException fileExcept) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
72 |
throw new RuntimeException("File " + fileName + |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
73 |
" not found reading data!", fileExcept); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
74 |
} catch (IOException ioExcept) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
75 |
throw new RuntimeException("Unexpected problem reading data!", |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
76 |
ioExcept); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
77 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
78 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
79 |
// was SOURCE even found? |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
80 |
if (fishForSOURCE == null) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
81 |
throw new RuntimeException("SOURCE line was not found!"); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
82 |
} else { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
83 |
// OK it was found, did it have correct sources? |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
84 |
System.out.println("The source string found: " + fishForSOURCE); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
85 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
86 |
// First it MUST have .: regardless of closed or openJDK |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
87 |
if (!fishForSOURCE.contains(".:")) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
88 |
throw new RuntimeException("The test failed, .: not found!"); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
89 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
90 |
// take out the .: source path |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
91 |
fishForSOURCE = fishForSOURCE.replace(".:", ""); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
92 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
93 |
// if its closedJDK it MUST have open: |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
94 |
if (!isOpenJDK && !fishForSOURCE.contains("open:")) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
95 |
throw new RuntimeException("The test failed, open: not found!"); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
96 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
97 |
// take out the open: source path |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
98 |
fishForSOURCE = fishForSOURCE.replace("open:", ""); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
99 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
100 |
// if any other source exists, that's an error |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
101 |
if (fishForSOURCE.contains(":")) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
102 |
throw new RuntimeException("The test failed, additional sources found!"); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
103 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
104 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
105 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
106 |
// Everything was fine |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
107 |
System.out.println("The test passed!"); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
108 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
109 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
110 |
public static void main(String args[]) { |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
111 |
String jdkPath = System.getProperty("test.jdk"); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
112 |
String runtime = System.getProperty("java.runtime.name"); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
113 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
114 |
System.out.println("JDK Path : " + jdkPath); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
115 |
System.out.println("Runtime Name : " + runtime); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
116 |
|
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
117 |
new CheckSource(jdkPath + "/release", |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
118 |
runtime.contains("OpenJDK")); |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
119 |
} |
4c2e97e4975a
8193660: Check SOURCE line in "release" file for closedjdk
shurailine
parents:
diff
changeset
|
120 |
} |