--- old/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java 2018-11-06 17:31:05.000000000 +0100 +++ new/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java 2018-11-06 17:31:04.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -22,8 +22,10 @@ */ package jdk.vm.ci.services; -import java.lang.reflect.Method; import java.util.Map; +import java.util.Set; + +import jdk.internal.misc.VM; /** * Provides utilities needed by JVMCI clients. @@ -61,18 +63,7 @@ private Services() { } - @SuppressWarnings("unchecked") - private static Map initSavedProperties() throws InternalError { - try { - Class vmClass = Class.forName("jdk.internal.misc.VM"); - Method m = vmClass.getMethod("getSavedProperties"); - return (Map) m.invoke(null); - } catch (Exception e) { - throw new InternalError(e); - } - } - - static final Map SAVED_PROPERTIES = initSavedProperties(); + static final Map SAVED_PROPERTIES = VM.getSavedProperties(); static final boolean JVMCI_ENABLED = Boolean.parseBoolean(SAVED_PROPERTIES.get("jdk.internal.vm.ci.enabled")); /** @@ -107,4 +98,20 @@ throw new InternalError(e); } } + + /** + * Opens all JVMCI packages to {@code otherModule}. + */ + static void openJVMCITo(Module otherModule) { + Module jvmci = Services.class.getModule(); + if (jvmci != otherModule) { + Set packages = jvmci.getPackages(); + for (String pkg : packages) { + boolean opened = jvmci.isOpen(pkg, otherModule); + if (!opened) { + jvmci.addOpens(pkg, otherModule); + } + } + } + } }