Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.services/src/jdk/vm/ci/services/JVMCIServiceLocator.java @ 24155:88bd5f7522a1 jvmci-0.30
update hgignore and undo change to hotspot/.project
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 07 Jul 2017 15:08:58 +0200 |
parents | 5cf445d2acf6 |
children |
rev | line source |
---|---|
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package jdk.vm.ci.services; |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import java.util.ArrayList; |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import java.util.List; |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 /** |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 * Service-provider class for the runtime to locate providers of JVMCI services where the latter are |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 * not in packages exported by the JVMCI module. As part of instantiating |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 * {@link JVMCIServiceLocator}, all JVMCI packages will be {@linkplain Services#exportJVMCITo(Class) |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 * exported} to the module defining the class of the instantiated object. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 * |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 * While the {@link #getProvider(Class)} method can be used directly, it's usually easier to use |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 * {@link #getProviders(Class)}. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 */ |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 public abstract class JVMCIServiceLocator { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 private static Void checkPermission() { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 SecurityManager sm = System.getSecurityManager(); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 if (sm != null) { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 sm.checkPermission(new JVMCIPermission()); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 return null; |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 @SuppressWarnings("unused") |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 private JVMCIServiceLocator(Void ignore) { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 /** |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 * Creates a capability for accessing JVMCI. Once successfully instantiated, JVMCI exports all |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 * its packages to the module defining the type of this object. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 * |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 * @throws SecurityException if a security manager has been installed and it denies |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 * {@link JVMCIPermission} |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 */ |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 protected JVMCIServiceLocator() { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 this(checkPermission()); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 Services.exportJVMCITo(getClass()); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 /** |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 * Gets the provider of the service defined by {@code service} or {@code null} if this object |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 * does not have a provider for {@code service}. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 */ |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 public abstract <S> S getProvider(Class<S> service); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 /** |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 * Gets the providers of the service defined by {@code service} by querying the |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 * {@link JVMCIServiceLocator} providers obtained by {@link Services#load(Class)}. |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 */ |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 public static <S> List<S> getProviders(Class<S> service) { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 List<S> providers = new ArrayList<>(); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 for (JVMCIServiceLocator access : Services.load(JVMCIServiceLocator.class)) { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 S provider = access.getProvider(service); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 if (provider != null) { |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 providers.add(provider); |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 return providers; |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 } |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 } |