< prev index next >

test/lib/jdk/test/lib/OSVersion.java

Print this page
rev 51613 : 8210039: move OSInfo to top level testlibrary
Reviewed-by: duke
rev 51614 : imported patch 8210039-1

*** 28,37 **** --- 28,40 ---- import java.util.Arrays; import java.io.BufferedReader; import java.io.FileReader; import java.util.regex.Pattern; import java.util.stream.Collectors; + import java.security.AccessController; + import java.security.PrivilegedActionException; + import java.security.PrivilegedExceptionAction; public final class OSVersion implements Comparable<OSVersion> { public static final OSVersion WINDOWS_95 = new OSVersion(4, 0); public static final OSVersion WINDOWS_98 = new OSVersion(4, 10); public static final OSVersion WINDOWS_ME = new OSVersion(4, 90);
*** 67,79 **** } catch (Throwable e) { System.out.println("First attempt failed with: " + e.getMessage()); } // Try to get Solaris version from /etc/release ! try (BufferedReader in = ! new BufferedReader(new FileReader("/etc/release"))) { return in.readLine().trim().split(" ")[2]; } catch (Exception e) { System.out.println("Second attempt failed with: " + e.getMessage()); } throw new RuntimeException("Unable to get Solaris version"); --- 70,84 ---- } catch (Throwable e) { System.out.println("First attempt failed with: " + e.getMessage()); } // Try to get Solaris version from /etc/release ! try (BufferedReader in = new BufferedReader(AccessController.doPrivileged( ! (PrivilegedExceptionAction<FileReader>) () -> new FileReader("/etc/release")))) { return in.readLine().trim().split(" ")[2]; + } catch (PrivilegedActionException e) { + System.out.println("Second attempt failed with: " + e.getException().getMessage()); } catch (Exception e) { System.out.println("Second attempt failed with: " + e.getMessage()); } throw new RuntimeException("Unable to get Solaris version");
< prev index next >