test/sun/misc/Version/Version.java

Print this page
rev 9165 : 8032678: [TESTBUG] sun/misc/Version/Version.java doesn't understand two-digit HotSpot minor version numbers
   1 /*
   2  * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  99         // valid format of the version string is:
 100         // n.n.n[_uu[c]][-<identifer>]-bxx
 101         int major = 0;
 102         int minor = 0;
 103         int micro = 0;
 104         int update = 0;
 105         String special = "";
 106         int build = 0;
 107         CharSequence cs = version;
 108         if (cs.length() >= 5) {
 109             if (Character.isDigit(cs.charAt(0)) && cs.charAt(1) == '.' &&
 110                 Character.isDigit(cs.charAt(2)) && cs.charAt(3) == '.' &&
 111                 Character.isDigit(cs.charAt(4))) {
 112                 major = Character.digit(cs.charAt(0), 10);
 113                 minor = Character.digit(cs.charAt(2), 10);
 114                 micro = Character.digit(cs.charAt(4), 10);
 115                 cs = cs.subSequence(5, cs.length());
 116             } else if (Character.isDigit(cs.charAt(0)) &&
 117                        Character.isDigit(cs.charAt(1)) && cs.charAt(2) == '.' &&
 118                        Character.isDigit(cs.charAt(3))) {
 119                 // HSX has nn.n (major.minor) version
 120                 major = Integer.valueOf(version.substring(0, 2)).intValue();





 121                 minor = Character.digit(cs.charAt(3), 10);
 122                 cs = cs.subSequence(4, cs.length());

 123             }
 124             if (cs.charAt(0) == '_' && cs.length() >= 3 &&
 125                 Character.isDigit(cs.charAt(1)) &&
 126                 Character.isDigit(cs.charAt(2))) {
 127                 int nextChar = 3;
 128                 String uu = cs.subSequence(1, 3).toString();
 129                 update = Integer.valueOf(uu).intValue();
 130                 if (cs.length() >= 4) {
 131                     char c = cs.charAt(3);
 132                     if (c >= 'a' && c <= 'z') {
 133                         special = Character.toString(c);
 134                         nextChar++;
 135                     }
 136                 }
 137                 cs = cs.subSequence(nextChar, cs.length());
 138             }
 139             if (cs.charAt(0) == '-') {
 140                 // skip the first character
 141                 // valid format: <identifier>-bxx or bxx
 142                 // non-product VM will have -debug|-release appended
   1 /*
   2  * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  99         // valid format of the version string is:
 100         // n.n.n[_uu[c]][-<identifer>]-bxx
 101         int major = 0;
 102         int minor = 0;
 103         int micro = 0;
 104         int update = 0;
 105         String special = "";
 106         int build = 0;
 107         CharSequence cs = version;
 108         if (cs.length() >= 5) {
 109             if (Character.isDigit(cs.charAt(0)) && cs.charAt(1) == '.' &&
 110                 Character.isDigit(cs.charAt(2)) && cs.charAt(3) == '.' &&
 111                 Character.isDigit(cs.charAt(4))) {
 112                 major = Character.digit(cs.charAt(0), 10);
 113                 minor = Character.digit(cs.charAt(2), 10);
 114                 micro = Character.digit(cs.charAt(4), 10);
 115                 cs = cs.subSequence(5, cs.length());
 116             } else if (Character.isDigit(cs.charAt(0)) &&
 117                        Character.isDigit(cs.charAt(1)) && cs.charAt(2) == '.' &&
 118                        Character.isDigit(cs.charAt(3))) {
 119                 // HSX has nn.n[n] (major.minor) version
 120                 major = Integer.valueOf(version.substring(0, 2)).intValue();
 121                 if (Character.isDigit(cs.charAt(4))) {
 122                     minor = Integer.valueOf(version.substring(3, 5)).intValue();
 123                     cs = cs.subSequence(5, cs.length());
 124                 }
 125                 else {
 126                     minor = Character.digit(cs.charAt(3), 10);
 127                     cs = cs.subSequence(4, cs.length());
 128                 }
 129             }
 130             if (cs.charAt(0) == '_' && cs.length() >= 3 &&
 131                 Character.isDigit(cs.charAt(1)) &&
 132                 Character.isDigit(cs.charAt(2))) {
 133                 int nextChar = 3;
 134                 String uu = cs.subSequence(1, 3).toString();
 135                 update = Integer.valueOf(uu).intValue();
 136                 if (cs.length() >= 4) {
 137                     char c = cs.charAt(3);
 138                     if (c >= 'a' && c <= 'z') {
 139                         special = Character.toString(c);
 140                         nextChar++;
 141                     }
 142                 }
 143                 cs = cs.subSequence(nextChar, cs.length());
 144             }
 145             if (cs.charAt(0) == '-') {
 146                 // skip the first character
 147                 // valid format: <identifier>-bxx or bxx
 148                 // non-product VM will have -debug|-release appended