You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2018/09/14 18:10:15 UTC
[geode] branch develop updated: GEODE-3: not use our own
SystemUtils to find java version (#2472)
This is an automated email from the ASF dual-hosted git repository.
jinmeiliao pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 28379f8 GEODE-3: not use our own SystemUtils to find java version (#2472)
28379f8 is described below
commit 28379f8b6486d34b22a2ab2dc1be27c4adac4dec
Author: jinmeiliao <ji...@pivotal.io>
AuthorDate: Fri Sep 14 11:10:07 2018 -0700
GEODE-3: not use our own SystemUtils to find java version (#2472)
---
.../org/apache/geode/internal/SharedLibrary.java | 2 +-
.../apache/geode/internal/lang/SystemUtils.java | 46 ----------------------
.../management/internal/cli/util/JdkTool.java | 2 +-
.../geode/internal/lang/SystemUtilsJUnitTest.java | 26 ------------
.../AnalyzeSerializablesJUnitTestBase.java | 9 +++--
5 files changed, 7 insertions(+), 78 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/SharedLibrary.java b/geode-core/src/main/java/org/apache/geode/internal/SharedLibrary.java
index 8716062..13fa860 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/SharedLibrary.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/SharedLibrary.java
@@ -108,7 +108,7 @@ public class SharedLibrary {
// If our heap is > 32G (64G on java 8) then assume large oops. Otherwise assume
// compressed oops.
long SMALL_OOP_BOUNDARY = 32L;
- if (SystemUtils.isJavaVersionAtLeast("1.8")) {
+ if (org.apache.commons.lang.SystemUtils.isJavaVersionAtLeast(1.8f)) {
SMALL_OOP_BOUNDARY = 64L;
}
if (Runtime.getRuntime().maxMemory() > (SMALL_OOP_BOUNDARY * 1024 * 1024 * 1024)) {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java b/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
index 92ac898..53f8660 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
@@ -51,46 +51,6 @@ public class SystemUtils {
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
/**
- * Utility method to determine whether the installed Java Runtime Environment (JRE) is minimally
- * at the specified, expected version. Typically, Java versions are of the form "1.6.0_31"... In
- * the Azul JVM java.version does not have the "_NN" suffix. Instead it has the azul product
- * version as the suffix like so "-zing_NN.NN.N.N". So on azul we instead use the
- * "java.specification.version" sys prop and only compare the major and minor version numbers. All
- * the stuff after the second "." in expectedVersion is ignored.
- *
- * @param expectedVersion an string value specifying the minimum expected version of the Java
- * Runtime.
- * @return a boolean value indicating if the Java Runtime meets the expected version requirement.
- * @see java.lang.System#getProperty(String) with "java.version".
- */
- public static boolean isJavaVersionAtLeast(String expectedVersion) {
- String actualVersionDigits;
- if (isAzulJVM()) {
- actualVersionDigits =
- StringUtils.getDigitsOnly(System.getProperty("java.specification.version"));
- int dotIdx = expectedVersion.indexOf('.');
- if (dotIdx != -1) {
- dotIdx = expectedVersion.indexOf('.', dotIdx + 1);
- if (dotIdx != -1) {
- // strip off everything after the second dot.
- expectedVersion = expectedVersion.substring(0, dotIdx);
- }
- }
- } else {
- actualVersionDigits = StringUtils.getDigitsOnly(System.getProperty("java.version"));
- }
-
- String expectedVersionDigits = StringUtils.rightPad(StringUtils.getDigitsOnly(expectedVersion),
- actualVersionDigits.length(), '0');
-
- try {
- return Long.parseLong(actualVersionDigits) >= Long.parseLong(expectedVersionDigits);
- } catch (NumberFormatException ignore) {
- return false;
- }
- }
-
- /**
* Utility method to determine whether the Java application process is executing on the Apple JVM.
*
* @return a boolean value indicating whether the Java application process is executing and
@@ -302,10 +262,4 @@ public class SystemUtils {
return LINE_SEPARATOR;
}
- /**
- * Returns the value of {@code System.getProperty("java.version")}.
- */
- public static String getJavaVersion() {
- return System.getProperty("java.version");
- }
}
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JdkTool.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JdkTool.java
index 8a16d19..9d719be 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JdkTool.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JdkTool.java
@@ -42,7 +42,7 @@ public class JdkTool {
return getJdkToolPathname("jvisualvm" + getExecutableSuffix(),
new VisualVmNotFoundException(CliStrings.START_JVISUALVM__NOT_FOUND_ERROR_MESSAGE));
} catch (VisualVmNotFoundException e) {
- if (!SystemUtils.isJavaVersionAtLeast("1.6")) {
+ if (!org.apache.commons.lang.SystemUtils.isJavaVersionAtLeast(1.6f)) {
throw new VisualVmNotFoundException(
CliStrings.START_JVISUALVM__EXPECTED_JDK_VERSION_ERROR_MESSAGE);
}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java
index 999cba1..5676252 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java
@@ -24,7 +24,6 @@ import static org.apache.geode.internal.lang.SystemUtils.ORACLE_JVM_VENDOR_NAME;
import static org.apache.geode.internal.lang.SystemUtils.WINDOWS_OS_NAME;
import static org.apache.geode.internal.lang.SystemUtils.getBootClassPath;
import static org.apache.geode.internal.lang.SystemUtils.getClassPath;
-import static org.apache.geode.internal.lang.SystemUtils.getJavaVersion;
import static org.apache.geode.internal.lang.SystemUtils.getOsArchitecture;
import static org.apache.geode.internal.lang.SystemUtils.getOsName;
import static org.apache.geode.internal.lang.SystemUtils.getOsVersion;
@@ -32,15 +31,12 @@ import static org.apache.geode.internal.lang.SystemUtils.isAppleJVM;
import static org.apache.geode.internal.lang.SystemUtils.isHotSpotVM;
import static org.apache.geode.internal.lang.SystemUtils.isJ9VM;
import static org.apache.geode.internal.lang.SystemUtils.isJRockitVM;
-import static org.apache.geode.internal.lang.SystemUtils.isJavaVersionAtLeast;
import static org.apache.geode.internal.lang.SystemUtils.isLinux;
import static org.apache.geode.internal.lang.SystemUtils.isMacOSX;
import static org.apache.geode.internal.lang.SystemUtils.isOracleJVM;
import static org.apache.geode.internal.lang.SystemUtils.isWindows;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
import java.lang.management.ManagementFactory;
@@ -53,28 +49,11 @@ import org.junit.Test;
* functionality of the SystemUtils class.
* <p/>
*
- * @see org.apache.geode.internal.lang.SystemUtils
* @see org.junit.Assert
* @see org.junit.Test
* @since GemFire 6.8
*/
public class SystemUtilsJUnitTest {
-
- // NOTE this test adds some maintenance overhead but ensure the correct functioning of GemFire
- // code that relies on
- // isJavaVersionAtLeast
- @Test
- public void testIsJavaVersionAtLeast() {
- // note, the expected version value should be set to the minimum supported version of the Java
- // Runtime Environment
- // (JRE) for GemFire
- assertTrue(isJavaVersionAtLeast("1.8"));
- // note, the expected version value should be set to the next version of the Java Runtime
- // Environment (JRE)
- // not currently available.
- assertFalse(isJavaVersionAtLeast("1.9"));
- }
-
@Test
public void testIsAppleJVM() {
final boolean expected =
@@ -157,9 +136,4 @@ public class SystemUtilsJUnitTest {
assumeNotNull(value);
assertThat(getBootClassPath()).isEqualTo(value);
}
-
- @Test
- public void getJavaVersionShouldReturnJavaVersionValue() {
- assertThat(getJavaVersion()).isEqualTo(System.getProperty("java.version"));
- }
}
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
index 388cddf..e746d91 100644
--- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
@@ -14,8 +14,7 @@
*/
package org.apache.geode.codeAnalysis;
-import static org.apache.geode.internal.lang.SystemUtils.getJavaVersion;
-import static org.apache.geode.internal.lang.SystemUtils.isJavaVersionAtLeast;
+import static org.apache.commons.lang.SystemUtils.isJavaVersionAtLeast;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.hamcrest.core.Is.is;
@@ -46,6 +45,7 @@ import java.util.Properties;
import java.util.ServiceLoader;
import java.util.Set;
+import org.apache.commons.lang.SystemUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -127,8 +127,9 @@ public abstract class AnalyzeSerializablesJUnitTestBase {
@Before
public void setUp() throws Exception {
assumeThat(
- "AnalyzeSerializables requires Java 8 but tests are running with v" + getJavaVersion(),
- isJavaVersionAtLeast("1.8"), is(true));
+ "AnalyzeSerializables requires Java 8 but tests are running with v"
+ + SystemUtils.JAVA_VERSION,
+ isJavaVersionAtLeast(1.8f), is(true));
TypeRegistry.init();
}