comparison jvmci/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/services/JVMCICompilerFactory.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.runtime/src/jdk/vm/ci/runtime/JVMCICompilerFactory.java@7eaa740eaca2
children 8153a654bd10
comparison
equal deleted inserted replaced
23362:ed9eec30efc1 23363:56479400913e
1 /*
2 * Copyright (c) 2015, 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.runtime.services;
24
25 import jdk.vm.ci.runtime.JVMCICompiler;
26 import jdk.vm.ci.runtime.JVMCIRuntime;
27
28 /**
29 * Service-provider class for creating JVMCI compilers.
30 */
31 public abstract class JVMCICompilerFactory {
32
33 private static Void checkPermission() {
34 SecurityManager sm = System.getSecurityManager();
35 if (sm != null)
36 sm.checkPermission(new RuntimePermission("jvmci"));
37 return null;
38 }
39
40 @SuppressWarnings("unused")
41 private JVMCICompilerFactory(Void ignore) {
42 }
43
44 /**
45 * Initializes a new instance of this class.
46 *
47 * @throws SecurityException if a security manager has been installed and it denies
48 * {@code RuntimePermission("jvmci")}
49 */
50 protected JVMCICompilerFactory() {
51 this(checkPermission());
52 }
53
54 /**
55 * Get the name of this compiler. The name is used by JVMCI to determine which factory to use.
56 */
57 public abstract String getCompilerName();
58
59 /**
60 * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime)
61 * create} a compiler and it should now perform any heavy weight initialization that it deferred
62 * during construction.
63 */
64 public void onSelection() {
65 }
66
67 /**
68 * Create a new instance of a {@link JVMCICompiler}.
69 */
70 public abstract JVMCICompiler createCompiler(JVMCIRuntime runtime);
71
72 /**
73 * In a tiered system it might be advantageous for startup to keep the JVMCI compiler from
74 * compiling itself so provide a hook to request that certain packages are compiled only by an
75 * optimizing first tier. The prefixes should class or package names using / as the separator,
76 * i.e. jdk/vm/ci for instance.
77 *
78 * @return 0 or more Strings identifying packages that should by compiled by the first tier
79 * only.
80 */
81 public String[] getTrivialPrefixes() {
82 return null;
83 }
84 }