jdk/src/share/classes/sun/misc/Version.java.template
changeset 19409 d7c7b9d56631
parent 16731 c6f7eeb4acc0
child 23010 6dadb192ad81
equal deleted inserted replaced
19408:a40090569cc5 19409:d7c7b9d56631
   337     // and its capabilities.
   337     // and its capabilities.
   338     //
   338     //
   339     // Return false if not available which implies an old VM (Tiger or before).
   339     // Return false if not available which implies an old VM (Tiger or before).
   340     private static native boolean getJvmVersionInfo();
   340     private static native boolean getJvmVersionInfo();
   341     private static native void getJdkVersionInfo();
   341     private static native void getJdkVersionInfo();
   342 
       
   343     // Possible runtime profiles, ordered from small to large
       
   344     private final static String[] PROFILES = { "compact1", "compact2", "compact3" };
       
   345 
       
   346     /**
       
   347      * Returns the name of the profile that this runtime implements. The empty
       
   348      * string is returned for the full Java Runtime.
       
   349      */
       
   350     public static String profileName() {
       
   351         return java_profile_name;
       
   352     }
       
   353 
       
   354     /**
       
   355      * Indicates if this runtime implements the full Java Runtime.
       
   356      */
       
   357     public static boolean isFullJre() {
       
   358         return java_profile_name.length() == 0;
       
   359     }
       
   360 
       
   361     // cached index of this profile's name in PROFILES (1-based)
       
   362     private static int thisRuntimeIndex;
       
   363 
       
   364     /**
       
   365      * Indicates if this runtime supports the given profile. Profile names are
       
   366      * case sensitive. 
       
   367      *
       
   368      * @return {@code true} if the given profile is supported
       
   369      */
       
   370     public static boolean supportsProfile(String requiredProfile) {
       
   371         int x = thisRuntimeIndex - 1;
       
   372         if (x < 0) {
       
   373             String profile = profileName();
       
   374             if (profile.length() > 0) {
       
   375                 x = 0;
       
   376                 while (x < PROFILES.length) {
       
   377                     if (PROFILES[x].equals(profile))
       
   378                         break;
       
   379                     x++;
       
   380                 }
       
   381                 if (x >= PROFILES.length)
       
   382                     throw new InternalError(profile + " not known to sun.misc.Version");
       
   383 
       
   384                 // okay if another thread has already set it
       
   385                 thisRuntimeIndex = x + 1;
       
   386             }
       
   387             // else we are a full JRE
       
   388         }
       
   389 
       
   390         int y = 0;
       
   391         while (y < PROFILES.length) {
       
   392             if (PROFILES[y].equals(requiredProfile))
       
   393                 break;
       
   394             y++;
       
   395         }
       
   396         if (y >= PROFILES.length) {
       
   397             // profile not found so caller has requested something that is not defined
       
   398             return false;
       
   399         }
       
   400 
       
   401         return x < 0 || x >= y;
       
   402     }
       
   403 
       
   404 }
   342 }
   405 
   343 
   406 // Help Emacs a little because this file doesn't end in .java.
   344 // Help Emacs a little because this file doesn't end in .java.
   407 //
   345 //
   408 // Local Variables: ***
   346 // Local Variables: ***