< prev index next >
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java
Print this page
*** 24,45 ****
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Formatter;
import java.util.Iterator;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
/**
! * A mechanism for accessing service providers via JVMCI.
*/
public final class Services {
private Services() {
}
private static int getJavaSpecificationVersion() {
String value = System.getProperty("java.specification.version");
if (value.startsWith("1.")) {
value = value.substring(2);
}
--- 24,79 ----
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Formatter;
import java.util.Iterator;
+ import java.util.Map;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
/**
! * Provides utilities needed by JVMCI clients.
! *
! * This class must be compilable on JDK 8 and so use of API added in JDK 9 is made via reflection.
*/
public final class Services {
private Services() {
}
+ /**
+ * Gets an unmodifiable copy of the system properties saved when {@link System} is initialized.
+ */
+ @SuppressWarnings("unchecked")
+ public static Map<String, String> getSavedProperties() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new JVMCIPermission());
+ }
+ try {
+ Class<?> vmClass = Class.forName("jdk.internal.misc.VM");
+ Method m = vmClass.getMethod("getSavedProperties");
+ return (Map<String, String>) m.invoke(null);
+ } catch (Exception e) {
+ throw new InternalError(e);
+ }
+ }
+
+ /**
+ * Causes the JVMCI subsystem to be initialized if it isn't already initialized.
+ */
+ public static void initializeJVMCI() {
+ try {
+ Class.forName("jdk.vm.ci.runtime.JVMCI");
+ } catch (ClassNotFoundException e) {
+ throw new InternalError(e);
+ }
+ }
+
+ // EVERYTHING BELOW HERE TO BE REMOVED AFTER NECESSARY GRAAL UPDATE
+
private static int getJavaSpecificationVersion() {
String value = System.getProperty("java.specification.version");
if (value.startsWith("1.")) {
value = value.substring(2);
}
*** 183,188 ****
--- 217,223 ----
errorMessage.format("Currently used VM configuration is: %s", vmName);
throw new UnsupportedOperationException(errorMessage.toString());
}
return singleProvider;
}
+
}
< prev index next >