aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoriignatyev <none@none>2014-04-11 00:34:56 +0400
committeriignatyev <none@none>2014-04-11 00:34:56 +0400
commit492d6307194e4c8d2c9fdad943173152db36c477 (patch)
treeb354f271c291dc6e922a10cea4e0790a5029904d /test
parent00a304ee38dfc71b8425669b4f8e6ca9d812072a (diff)
8039497: Testlibrary should be updated to provide information about all VM types as well as access to Unsafe
Reviewed-by: kvn, iignatyev Contributed-by: filipp.zhinkin@oracle.com
Diffstat (limited to 'test')
-rw-r--r--test/testlibrary/com/oracle/java/testlibrary/Platform.java24
-rw-r--r--test/testlibrary/com/oracle/java/testlibrary/Utils.java23
2 files changed, 39 insertions, 8 deletions
diff --git a/test/testlibrary/com/oracle/java/testlibrary/Platform.java b/test/testlibrary/com/oracle/java/testlibrary/Platform.java
index 34b2f20f9..fa4b36361 100644
--- a/test/testlibrary/com/oracle/java/testlibrary/Platform.java
+++ b/test/testlibrary/com/oracle/java/testlibrary/Platform.java
@@ -30,13 +30,25 @@ public class Platform {
private static final String osArch = System.getProperty("os.arch");
private static final String vmName = System.getProperty("java.vm.name");
- public static boolean isClient() {
- return vmName.endsWith(" Client VM");
- }
+ public static boolean isClient() {
+ return vmName.endsWith(" Client VM");
+ }
+
+ public static boolean isServer() {
+ return vmName.endsWith(" Server VM");
+ }
+
+ public static boolean isGraal() {
+ return vmName.endsWith(" Graal VM");
+ }
+
+ public static boolean isMinimal() {
+ return vmName.endsWith(" Minimal VM");
+ }
- public static boolean isServer() {
- return vmName.endsWith(" Server VM");
- }
+ public static boolean isEmbedded() {
+ return vmName.contains("Embedded");
+ }
public static boolean is32bit() {
return dataModel.equals("32");
diff --git a/test/testlibrary/com/oracle/java/testlibrary/Utils.java b/test/testlibrary/com/oracle/java/testlibrary/Utils.java
index 5f2b3e95d..ba4bea5e9 100644
--- a/test/testlibrary/com/oracle/java/testlibrary/Utils.java
+++ b/test/testlibrary/com/oracle/java/testlibrary/Utils.java
@@ -38,6 +38,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import java.lang.reflect.Field;
+import sun.misc.Unsafe;
/**
* Common library for various test helper functions.
@@ -59,6 +61,8 @@ public final class Utils {
*/
public static final String JAVA_OPTIONS = System.getProperty("test.java.opts", "").trim();
+ private static Unsafe unsafe = null;
+
/**
* Returns the value of 'test.timeout.factor' system property
* converted to {@code double}.
@@ -109,10 +113,10 @@ public final class Utils {
/**
* Returns the default JTReg arguments for a jvm running a test without
- * options that matches regular expresions in {@code filters}.
+ * options that matches regular expressions in {@code filters}.
* This is the combination of JTReg arguments test.vm.opts and test.java.opts.
* @param filters Regular expressions used to filter out options.
- * @return An array of options, or an empty array if no opptions.
+ * @return An array of options, or an empty array if no options.
*/
public static String[] getFilteredTestJavaOpts(String... filters) {
String options[] = getTestJavaOpts();
@@ -294,6 +298,21 @@ public final class Utils {
return output;
}
+ /**
+ * @return Unsafe instance.
+ */
+ public static synchronized Unsafe getUnsafe() {
+ if (unsafe == null) {
+ try {
+ Field f = Unsafe.class.getDeclaredField("theUnsafe");
+ f.setAccessible(true);
+ unsafe = (Unsafe) f.get(null);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ throw new RuntimeException("Unable to get Unsafe instance.", e);
+ }
+ }
+ return unsafe;
+ }
private static final char[] hexArray = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
/**