public static Platform detect ( ) throws UnsupportedPlatformException { String osArch = getProperty ( "os.arch" ) ; String osName = getProperty ( "os.name" ) ; for ( Arch arch : Arch . values ( ) ) { if ( arch . pattern . matcher ( osArch ) . matches ( ) ) { for ( OS os : OS . values ( ) ) { if ( os . pattern . matcher ( osName ) . matches ( ) ) { return new Platform ( arch , os ) ; } } } } String msg = String . format ( "Unsupported platform %s %s" , osArch , osName ) ; throw new UnsupportedPlatformException ( msg ) ; }
Attempt to detect the current platform .