author | amurillo |
Wed, 15 Aug 2012 16:49:38 -0700 | |
changeset 13465 | d3fc5d192448 |
parent 9000 | f6166b27446e |
child 14342 | 8435a30053c1 |
permissions | -rw-r--r-- |
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
1 |
/* |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
4 |
* |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
8 |
* |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
13 |
* accompanied this code). |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
14 |
* |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
18 |
* |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
21 |
* questions. |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
22 |
*/ |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
23 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
24 |
/* @test |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
25 |
* @bug 6994413 |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
26 |
* @summary Check the JDK and JVM version returned by sun.misc.Version |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
27 |
* matches the versions defined in the system properties |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
28 |
* @compile -XDignore.symbol.file Version.java |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
29 |
* @run main Version |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
30 |
*/ |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
31 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
32 |
import static sun.misc.Version.*; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
33 |
public class Version { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
34 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
35 |
public static void main(String[] args) throws Exception { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
36 |
VersionInfo jdk = newVersionInfo(System.getProperty("java.runtime.version")); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
37 |
VersionInfo v1 = new VersionInfo(jdkMajorVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
38 |
jdkMinorVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
39 |
jdkMicroVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
40 |
jdkUpdateVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
41 |
jdkSpecialVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
42 |
jdkBuildNumber()); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
43 |
System.out.println("JDK version = " + jdk + " " + v1); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
44 |
if (!jdk.equals(v1)) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
45 |
throw new RuntimeException("Unmatched version: " + jdk + " vs " + v1); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
46 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
47 |
VersionInfo jvm = newVersionInfo(System.getProperty("java.vm.version")); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
48 |
VersionInfo v2 = new VersionInfo(jvmMajorVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
49 |
jvmMinorVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
50 |
jvmMicroVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
51 |
jvmUpdateVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
52 |
jvmSpecialVersion(), |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
53 |
jvmBuildNumber()); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
54 |
System.out.println("JVM version = " + jvm + " " + v2); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
55 |
if (!jvm.equals(v2)) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
56 |
throw new RuntimeException("Unmatched version: " + jvm + " vs " + v2); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
57 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
58 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
59 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
60 |
static class VersionInfo { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
61 |
final int major; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
62 |
final int minor; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
63 |
final int micro; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
64 |
final int update; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
65 |
final String special; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
66 |
final int build; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
67 |
VersionInfo(int major, int minor, int micro, |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
68 |
int update, String special, int build) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
69 |
this.major = major; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
70 |
this.minor = minor; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
71 |
this.micro = micro; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
72 |
this.update = update; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
73 |
this.special = special; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
74 |
this.build = build; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
75 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
76 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
77 |
public boolean equals(VersionInfo v) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
78 |
return (this.major == v.major && this.minor == v.minor && |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
79 |
this.micro == v.micro && this.update == v.update && |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
80 |
this.special.equals(v.special) && this.build == v.build); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
81 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
82 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
83 |
public String toString() { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
84 |
StringBuilder sb = new StringBuilder(); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
85 |
sb.append(major + "." + minor + "." + micro); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
86 |
if (update > 0) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
87 |
sb.append("_" + update); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
88 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
89 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
90 |
if (!special.isEmpty()) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
91 |
sb.append(special); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
92 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
93 |
sb.append("-b" + build); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
94 |
return sb.toString(); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
95 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
96 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
97 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
98 |
private static VersionInfo newVersionInfo(String version) throws Exception { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
99 |
// valid format of the version string is: |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
100 |
// n.n.n[_uu[c]][-<identifer>]-bxx |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
101 |
int major = 0; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
102 |
int minor = 0; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
103 |
int micro = 0; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
104 |
int update = 0; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
105 |
String special = ""; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
106 |
int build = 0; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
107 |
CharSequence cs = version; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
108 |
if (cs.length() >= 5) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
109 |
if (Character.isDigit(cs.charAt(0)) && cs.charAt(1) == '.' && |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
110 |
Character.isDigit(cs.charAt(2)) && cs.charAt(3) == '.' && |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
111 |
Character.isDigit(cs.charAt(4))) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
112 |
major = Character.digit(cs.charAt(0), 10); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
113 |
minor = Character.digit(cs.charAt(2), 10); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
114 |
micro = Character.digit(cs.charAt(4), 10); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
115 |
cs = cs.subSequence(5, cs.length()); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
116 |
} else if (Character.isDigit(cs.charAt(0)) && |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
117 |
Character.isDigit(cs.charAt(1)) && cs.charAt(2) == '.' && |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
118 |
Character.isDigit(cs.charAt(3))) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
119 |
// HSX has nn.n (major.minor) version |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
120 |
major = Integer.valueOf(version.substring(0, 2)).intValue(); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
121 |
minor = Character.digit(cs.charAt(3), 10); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
122 |
cs = cs.subSequence(4, cs.length()); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
123 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
124 |
if (cs.charAt(0) == '_' && cs.length() >= 3 && |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
125 |
Character.isDigit(cs.charAt(1)) && |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
126 |
Character.isDigit(cs.charAt(2))) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
127 |
int nextChar = 3; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
128 |
String uu = cs.subSequence(1, 3).toString(); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
129 |
update = Integer.valueOf(uu).intValue(); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
130 |
if (cs.length() >= 4) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
131 |
char c = cs.charAt(3); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
132 |
if (c >= 'a' && c <= 'z') { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
133 |
special = Character.toString(c); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
134 |
nextChar++; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
135 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
136 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
137 |
cs = cs.subSequence(nextChar, cs.length()); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
138 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
139 |
if (cs.charAt(0) == '-') { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
140 |
// skip the first character |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
141 |
// valid format: <identifier>-bxx or bxx |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
142 |
// non-product VM will have -debug|-release appended |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
143 |
cs = cs.subSequence(1, cs.length()); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
144 |
String[] res = cs.toString().split("-"); |
9000
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
145 |
for (int i = res.length - 1; i >= 0; i--) { |
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
146 |
String s = res[i]; |
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
147 |
if (s.charAt(0) == 'b') { |
9000
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
148 |
try { |
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
149 |
build = Integer.parseInt(s.substring(1, s.length())); |
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
150 |
break; |
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
151 |
} catch (NumberFormatException nfe) { |
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
152 |
// ignore |
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
153 |
} |
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
154 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
155 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
156 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
157 |
} |
9000
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
158 |
VersionInfo vi = new VersionInfo(major, minor, micro, update, special, build); |
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
159 |
System.out.printf("newVersionInfo: input=%s output=%s\n", version, vi); |
f6166b27446e
7029680: fix test/sun/misc/Version/Version.java build parsing
smarks
parents:
7042
diff
changeset
|
160 |
return vi; |
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
161 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
diff
changeset
|
162 |
} |