comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java @ 23363:56479400913e

jdk.vm.ci needs to securely export services (JDK-8155023)
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 Apr 2016 15:16:47 +0200
parents jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java@9273bb6ba33e
children 8153a654bd10
comparison
equal deleted inserted replaced
23362:ed9eec30efc1 23363:56479400913e
1 /*
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package jdk.vm.ci.hotspot.services;
24
25 import jdk.vm.ci.code.CompiledCode;
26 import jdk.vm.ci.code.InstalledCode;
27 import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
28 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
29 import jdk.vm.ci.meta.JVMCIMetaAccessContext;
30 import jdk.vm.ci.meta.ResolvedJavaType;
31
32 /**
33 * Service-provider class for responding to VM events and for creating
34 * {@link JVMCIMetaAccessContext}s.
35 */
36 public abstract class HotSpotVMEventListener {
37
38 private static Void checkPermission() {
39 SecurityManager sm = System.getSecurityManager();
40 if (sm != null)
41 sm.checkPermission(new RuntimePermission("jvmci"));
42 return null;
43 }
44
45 @SuppressWarnings("unused")
46 HotSpotVMEventListener(Void ignore) {
47 }
48
49 /**
50 * Initializes a new instance of this class.
51 *
52 * @throws SecurityException if a security manager has been installed and it denies
53 * {@code RuntimePermission("jvmci")}
54 */
55 protected HotSpotVMEventListener() {
56 this(checkPermission());
57 }
58
59 /**
60 * Notifies this client that the VM is shutting down.
61 */
62 public void notifyShutdown() {
63 }
64
65 /**
66 * Notify on successful install into the code cache.
67 *
68 * @param hotSpotCodeCacheProvider
69 * @param installedCode
70 * @param compiledCode
71 */
72 public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
73 }
74
75 /**
76 * Create a custom {@link JVMCIMetaAccessContext} to be used for managing the lifetime of loaded
77 * metadata. It a custom one isn't created then the default implementation will be a single
78 * context with globally shared instances of {@link ResolvedJavaType} that are never released.
79 *
80 * @param runtime the runtime instance that will use the returned context
81 * @return a custom context or null
82 */
83 public JVMCIMetaAccessContext createMetaAccessContext(HotSpotJVMCIRuntime runtime) {
84 return null;
85 }
86 }