< prev index next >
test/lib/jdk/test/lib/OSVersion.java
Print this page
rev 59383 : [mq]: final
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -44,13 +44,10 @@
public static final OSVersion WINDOWS_VISTA = new OSVersion(6, 0);
private final int[] versionTokens;
public static OSVersion current() {
- if (Platform.isSolaris()) {
- return new OSVersion(getSolarisVersion());
- }
return new OSVersion(Platform.getOsVersion());
}
public OSVersion(int major, int minor) {
versionTokens = new int[] {major, minor};
@@ -62,30 +59,10 @@
.filter(onlyDigits.asPredicate())
.mapToInt(Integer::parseInt)
.toArray();
}
- private static String getSolarisVersion() {
- try {
- return Utils.distro();
- } 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");
- }
-
@Override
public int compareTo(OSVersion o) {
return Arrays.compare(this.versionTokens, o.versionTokens);
}
< prev index next >