< prev index next >

test/lib/jdk/test/lib/Platform.java

Print this page
rev 59103 : imported patch hotspot


  96     public static boolean is32bit() {
  97         return dataModel.equals("32");
  98     }
  99 
 100     public static boolean is64bit() {
 101         return dataModel.equals("64");
 102     }
 103 
 104     public static boolean isAix() {
 105         return isOs("aix");
 106     }
 107 
 108     public static boolean isLinux() {
 109         return isOs("linux");
 110     }
 111 
 112     public static boolean isOSX() {
 113         return isOs("mac");
 114     }
 115 
 116     public static boolean isSolaris() {
 117         return isOs("sunos");
 118     }
 119 
 120     public static boolean isWindows() {
 121         return isOs("win");
 122     }
 123 
 124     private static boolean isOs(String osname) {
 125         return osName.toLowerCase().startsWith(osname.toLowerCase());
 126     }
 127 
 128     public static String getOsName() {
 129         return osName;
 130     }
 131 
 132     // Os version support.
 133     private static void init_version() {
 134         String[] osVersionTokens = osVersion.split("\\.");
 135         try {
 136             if (osVersionTokens.length > 0) {
 137                 osVersionMajor = Integer.parseInt(osVersionTokens[0]);
 138                 if (osVersionTokens.length > 1) {
 139                     osVersionMinor = Integer.parseInt(osVersionTokens[1]);
 140                 }
 141             }
 142         } catch (NumberFormatException e) {
 143             osVersionMajor = osVersionMinor = 0;
 144         }
 145     }
 146 
 147     public static String getOsVersion() {
 148         return osVersion;
 149     }
 150 
 151     // Returns major version number from os.version system property.
 152     // E.g. 5 on Solaris 10 and 3 on SLES 11.3 (for the linux kernel version).
 153     public static int getOsVersionMajor() {
 154         if (osVersionMajor == -1) init_version();
 155         return osVersionMajor;
 156     }
 157 
 158     // Returns minor version number from os.version system property.
 159     // E.g. 10 on Solaris 10 and 0 on SLES 11.3 (for the linux kernel version).
 160     public static int getOsVersionMinor() {
 161         if (osVersionMinor == -1) init_version();
 162         return osVersionMinor;
 163     }
 164 
 165     public static boolean isDebugBuild() {
 166         return (jdkDebug.toLowerCase().contains("debug"));
 167     }
 168 
 169     public static boolean isSlowDebugBuild() {
 170         return (jdkDebug.toLowerCase().equals("slowdebug"));
 171     }
 172 
 173     public static boolean isFastDebugBuild() {
 174         return (jdkDebug.toLowerCase().equals("fastdebug"));
 175     }
 176 
 177     public static String getVMVersion() {
 178         return vmVersion;
 179     }
 180 
 181     public static boolean isAArch64() {
 182         return isArch("aarch64");
 183     }
 184 
 185     public static boolean isARM() {
 186         return isArch("arm.*");
 187     }
 188 
 189     public static boolean isPPC() {
 190         return isArch("ppc.*");
 191     }
 192 
 193     // Returns true for IBM z System running linux.
 194     public static boolean isS390x() {
 195         return isArch("s390.*") || isArch("s/390.*") || isArch("zArch_64");
 196     }
 197 
 198     // Returns true for sparc and sparcv9.
 199     public static boolean isSparc() {
 200         return isArch("sparc.*");
 201     }
 202 
 203     public static boolean isX64() {
 204         // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
 205         return isArch("(amd64)|(x86_64)");
 206     }
 207 
 208     public static boolean isX86() {
 209         // On Linux it's 'i386', Windows 'x86' without '_64' suffix.
 210         return isArch("(i386)|(x86(?!_64))");
 211     }
 212 
 213     public static String getOsArch() {
 214         return osArch;
 215     }
 216 
 217     public static boolean isRoot() {
 218         return userName.equals("root");
 219     }
 220 
 221     /**
 222      * Return a boolean for whether SA and jhsdb are ported/available
 223      * on this platform.
 224      */
 225     public static boolean hasSA() {
 226         if (isAix()) {
 227             return false; // SA not implemented.
 228         } else if (isSolaris()) {
 229             return false; // Testing disabled due to JDK-8193639.
 230         } else if (isLinux()) {
 231             if (isS390x() || isARM()) {
 232                 return false; // SA not implemented.
 233             }
 234         }
 235         // Other platforms expected to work:
 236         return true;
 237     }
 238 
 239     /**
 240      * Return true if the test JDK is signed, otherwise false. Only valid on OSX.
 241      */
 242     public static boolean isSignedOSX() throws IOException {
 243         // We only care about signed binaries for 10.14 and later (actually 10.14.5, but
 244         // for simplicity we'll also include earlier 10.14 versions).
 245         if (getOsVersionMajor() == 10 && getOsVersionMinor() < 14) {
 246             return false; // assume not signed
 247         }
 248 
 249         // Find the path to the java binary.


 344     }
 345 
 346     private static String variant() {
 347         if (Platform.isServer()) {
 348             return "server";
 349         } else if (Platform.isClient()) {
 350             return "client";
 351         } else if (Platform.isMinimal()) {
 352             return "minimal";
 353         } else {
 354             throw new Error("TESTBUG: unsupported vm variant");
 355         }
 356     }
 357 
 358 
 359     public static boolean isDefaultCDSArchiveSupported() {
 360         return (is64bit()  &&
 361                 isServer() &&
 362                 (isLinux()   ||
 363                  isOSX()     ||
 364                  isSolaris() ||
 365                  isWindows()) &&
 366                 !isZero()    &&
 367                 !isMinimal() &&
 368                 !isAArch64() &&
 369                 !isARM());
 370     }
 371 
 372     /*
 373      * This should match the #if condition in ClassListParser::load_class_from_source().
 374      */
 375     public static boolean areCustomLoadersSupportedForCDS() {
 376         return (is64bit() && (isLinux() || isSolaris() || isOSX()));
 377     }
 378 }


  96     public static boolean is32bit() {
  97         return dataModel.equals("32");
  98     }
  99 
 100     public static boolean is64bit() {
 101         return dataModel.equals("64");
 102     }
 103 
 104     public static boolean isAix() {
 105         return isOs("aix");
 106     }
 107 
 108     public static boolean isLinux() {
 109         return isOs("linux");
 110     }
 111 
 112     public static boolean isOSX() {
 113         return isOs("mac");
 114     }
 115 




 116     public static boolean isWindows() {
 117         return isOs("win");
 118     }
 119 
 120     private static boolean isOs(String osname) {
 121         return osName.toLowerCase().startsWith(osname.toLowerCase());
 122     }
 123 
 124     public static String getOsName() {
 125         return osName;
 126     }
 127 
 128     // Os version support.
 129     private static void init_version() {
 130         String[] osVersionTokens = osVersion.split("\\.");
 131         try {
 132             if (osVersionTokens.length > 0) {
 133                 osVersionMajor = Integer.parseInt(osVersionTokens[0]);
 134                 if (osVersionTokens.length > 1) {
 135                     osVersionMinor = Integer.parseInt(osVersionTokens[1]);
 136                 }
 137             }
 138         } catch (NumberFormatException e) {
 139             osVersionMajor = osVersionMinor = 0;
 140         }
 141     }
 142 
 143     public static String getOsVersion() {
 144         return osVersion;
 145     }
 146 
 147     // Returns major version number from os.version system property.
 148     // E.g. 3 on SLES 11.3 (for the linux kernel version).
 149     public static int getOsVersionMajor() {
 150         if (osVersionMajor == -1) init_version();
 151         return osVersionMajor;
 152     }
 153 
 154     // Returns minor version number from os.version system property.
 155     // E.g. 0 on SLES 11.3 (for the linux kernel version).
 156     public static int getOsVersionMinor() {
 157         if (osVersionMinor == -1) init_version();
 158         return osVersionMinor;
 159     }
 160 
 161     public static boolean isDebugBuild() {
 162         return (jdkDebug.toLowerCase().contains("debug"));
 163     }
 164 
 165     public static boolean isSlowDebugBuild() {
 166         return (jdkDebug.toLowerCase().equals("slowdebug"));
 167     }
 168 
 169     public static boolean isFastDebugBuild() {
 170         return (jdkDebug.toLowerCase().equals("fastdebug"));
 171     }
 172 
 173     public static String getVMVersion() {
 174         return vmVersion;
 175     }
 176 
 177     public static boolean isAArch64() {
 178         return isArch("aarch64");
 179     }
 180 
 181     public static boolean isARM() {
 182         return isArch("arm.*");
 183     }
 184 
 185     public static boolean isPPC() {
 186         return isArch("ppc.*");
 187     }
 188 
 189     // Returns true for IBM z System running linux.
 190     public static boolean isS390x() {
 191         return isArch("s390.*") || isArch("s/390.*") || isArch("zArch_64");
 192     }
 193 





 194     public static boolean isX64() {
 195         // On OSX it's 'x86_64' and on other (Linux and Windows) platforms it's 'amd64'
 196         return isArch("(amd64)|(x86_64)");
 197     }
 198 
 199     public static boolean isX86() {
 200         // On Linux it's 'i386', Windows 'x86' without '_64' suffix.
 201         return isArch("(i386)|(x86(?!_64))");
 202     }
 203 
 204     public static String getOsArch() {
 205         return osArch;
 206     }
 207 
 208     public static boolean isRoot() {
 209         return userName.equals("root");
 210     }
 211 
 212     /**
 213      * Return a boolean for whether SA and jhsdb are ported/available
 214      * on this platform.
 215      */
 216     public static boolean hasSA() {
 217         if (isAix()) {
 218             return false; // SA not implemented.


 219         } else if (isLinux()) {
 220             if (isS390x() || isARM()) {
 221                 return false; // SA not implemented.
 222             }
 223         }
 224         // Other platforms expected to work:
 225         return true;
 226     }
 227 
 228     /**
 229      * Return true if the test JDK is signed, otherwise false. Only valid on OSX.
 230      */
 231     public static boolean isSignedOSX() throws IOException {
 232         // We only care about signed binaries for 10.14 and later (actually 10.14.5, but
 233         // for simplicity we'll also include earlier 10.14 versions).
 234         if (getOsVersionMajor() == 10 && getOsVersionMinor() < 14) {
 235             return false; // assume not signed
 236         }
 237 
 238         // Find the path to the java binary.


 333     }
 334 
 335     private static String variant() {
 336         if (Platform.isServer()) {
 337             return "server";
 338         } else if (Platform.isClient()) {
 339             return "client";
 340         } else if (Platform.isMinimal()) {
 341             return "minimal";
 342         } else {
 343             throw new Error("TESTBUG: unsupported vm variant");
 344         }
 345     }
 346 
 347 
 348     public static boolean isDefaultCDSArchiveSupported() {
 349         return (is64bit()  &&
 350                 isServer() &&
 351                 (isLinux()   ||
 352                  isOSX()     ||

 353                  isWindows()) &&
 354                 !isZero()    &&
 355                 !isMinimal() &&
 356                 !isAArch64() &&
 357                 !isARM());
 358     }
 359 
 360     /*
 361      * This should match the #if condition in ClassListParser::load_class_from_source().
 362      */
 363     public static boolean areCustomLoadersSupportedForCDS() {
 364         return (is64bit() && (isLinux() || isOSX()));
 365     }
 366 }
< prev index next >