annotate jvmci/com.oracle.jvmci.service/src/com/oracle/jvmci/service/Services.java @ 21916:3df76a0300f3

jvmci.make remove generated source from search path; export compilers into a different directory when jvmci is disabled: jre/lib/<arch>/(server|client)-nojvmci/
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Thu, 11 Jun 2015 11:07:28 +0200
parents 763db13bd6f4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
21604
93f282187d90 moved JVMCI service API into separate com.oracle.jvmci.service module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21558
diff changeset
23 package com.oracle.jvmci.service;
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import java.util.*;
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26
21607
71b338926f2e moved JVMCI classes into their own distributions (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
27 import sun.reflect.*;
71b338926f2e moved JVMCI classes into their own distributions (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
28
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 /**
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
30 * An mechanism for accessing {@link Service JVMCI service providers}.
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 */
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 public class Services {
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33
21799
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
34 private static final String SUPPRESS_PROPERTY_NAME = "jvmci.service.suppressNoClassDefFoundError";
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
35
21675
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
36 /**
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
37 * Determines whether to suppress the {@link NoClassDefFoundError} raised if a service provider
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
38 * class specified in a {@code <jre>/jvmci/services/*} file is missing.
21675
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
39 */
21799
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
40 private static final boolean SuppressNoClassDefFoundError = Boolean.getBoolean(SUPPRESS_PROPERTY_NAME);
21675
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
41
21887
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21799
diff changeset
42 private static final ClassValue<List<?>> cache = new ClassValue<List<?>>() {
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 @Override
21887
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21799
diff changeset
44 protected List<?> computeValue(Class<?> type) {
21675
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
45 try {
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
46 return Arrays.asList(getServiceImpls(type));
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
47 } catch (NoClassDefFoundError e) {
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
48 if (SuppressNoClassDefFoundError) {
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
49 return Collections.emptyList();
21799
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
50 } else {
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
51 NoClassDefFoundError newEx = new NoClassDefFoundError(e.getMessage() + " (suppress with -D" + SUPPRESS_PROPERTY_NAME + "=true)");
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
52 if (e.getCause() != null) {
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
53 newEx.initCause(e.getCause());
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
54 }
10f28849c1ec improve error message when JVMCI services are not found
Doug Simon <doug.simon@oracle.com>
parents: 21798
diff changeset
55 throw newEx;
21675
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
56 }
2e8c01def9a5 moved [AMD64|SPARC]HotSpotJVMCIBackendFactory into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21662
diff changeset
57 }
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 }
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 };
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 /**
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
62 * Gets an {@link Iterable} of the JVMCI providers available for a given service.
21636
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
63 *
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
64 * @throws SecurityException if a security manager is present and it denies
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
65 * <tt>{@link RuntimePermission}("jvmciServices")</tt>
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 */
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67 @SuppressWarnings("unchecked")
21607
71b338926f2e moved JVMCI classes into their own distributions (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21604
diff changeset
68 @CallerSensitive
21887
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21799
diff changeset
69 public static <S> Iterable<S> load(Class<S> service) {
21636
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
70 SecurityManager sm = System.getSecurityManager();
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
71 if (sm != null) {
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
72 sm.checkPermission(new RuntimePermission("jvmciServices"));
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
73 }
21760
55058b8000ea updated javadoc to document that JVMCI services are disjoint from the standard service loading mechanism and tightened generic type constraint such that Services and @ServiceProcessor can only be used with classes implementing Service
Doug Simon <doug.simon@oracle.com>
parents: 21675
diff changeset
74 try {
55058b8000ea updated javadoc to document that JVMCI services are disjoint from the standard service loading mechanism and tightened generic type constraint such that Services and @ServiceProcessor can only be used with classes implementing Service
Doug Simon <doug.simon@oracle.com>
parents: 21675
diff changeset
75 return (Iterable<S>) cache.get(service);
55058b8000ea updated javadoc to document that JVMCI services are disjoint from the standard service loading mechanism and tightened generic type constraint such that Services and @ServiceProcessor can only be used with classes implementing Service
Doug Simon <doug.simon@oracle.com>
parents: 21675
diff changeset
76 } catch (UnsatisfiedLinkError e) {
55058b8000ea updated javadoc to document that JVMCI services are disjoint from the standard service loading mechanism and tightened generic type constraint such that Services and @ServiceProcessor can only be used with classes implementing Service
Doug Simon <doug.simon@oracle.com>
parents: 21675
diff changeset
77 return Collections.emptyList();
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78 }
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
79 }
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
81 /**
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
82 * Gets the JVMCI provider for a given service for which at most one provider must be available.
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
83 *
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
84 * @param service the service whose provider is being requested
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
85 * @param required specifies if an {@link InternalError} should be thrown if no provider of
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
86 * {@code service} is available
21636
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
87 * @throws SecurityException if a security manager is present and it denies
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
88 * <tt>{@link RuntimePermission}("jvmciServices")</tt>
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
89 */
21887
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21799
diff changeset
90 @SuppressWarnings({"unchecked"})
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
91 @CallerSensitive
21887
543f150e7fa0 com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
Doug Simon <doug.simon@oracle.com>
parents: 21799
diff changeset
92 public static <S> S loadSingle(Class<S> service, boolean required) {
21636
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
93 SecurityManager sm = System.getSecurityManager();
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
94 if (sm != null) {
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
95 sm.checkPermission(new RuntimePermission("jvmciServices"));
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
96 }
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
97 Iterable<S> providers;
21760
55058b8000ea updated javadoc to document that JVMCI services are disjoint from the standard service loading mechanism and tightened generic type constraint such that Services and @ServiceProcessor can only be used with classes implementing Service
Doug Simon <doug.simon@oracle.com>
parents: 21675
diff changeset
98 try {
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
99 providers = (Iterable<S>) cache.get(service);
21760
55058b8000ea updated javadoc to document that JVMCI services are disjoint from the standard service loading mechanism and tightened generic type constraint such that Services and @ServiceProcessor can only be used with classes implementing Service
Doug Simon <doug.simon@oracle.com>
parents: 21675
diff changeset
100 } catch (UnsatisfiedLinkError e) {
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
101 providers = Collections.emptyList();
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
102 }
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
103
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
104 S singleProvider = null;
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
105 for (S provider : providers) {
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
106 if (singleProvider != null) {
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
107 throw new InternalError(String.format("Multiple %s providers found: %s, %s", service.getName(), singleProvider.getClass().getName(), provider.getClass().getName()));
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
108 }
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
109 singleProvider = provider;
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
110 }
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
111 if (singleProvider == null && required) {
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
112 String javaHome = System.getProperty("java.home");
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
113 String vmName = System.getProperty("java.vm.name");
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
114 Formatter errorMessage = new Formatter();
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
115 errorMessage.format("The VM does not expose required service %s.%n", service.getName());
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
116 errorMessage.format("Currently used Java home directory is %s.%n", javaHome);
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
117 errorMessage.format("Currently used VM configuration is: %s", vmName);
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
118 throw new UnsupportedOperationException(errorMessage.toString());
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
119 }
21895
763db13bd6f4 reworded Service documentation to be interms of "providers" instead of "implementations" to better match documentation for the standard ServiceLoader mechanism
Doug Simon <doug.simon@oracle.com>
parents: 21887
diff changeset
120 return singleProvider;
21614
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
121 }
2f92172fa320 Truffle and NFI implementations are now accessed via JVMCI services instead of being hard coded in the VM (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21607
diff changeset
122
21636
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
123 static {
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
124 Reflection.registerMethodsToFilter(Services.class, "getServiceImpls");
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
125 Reflection.registerFieldsToFilter(Services.class, "cache");
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
126 }
6d9c8d0d0f7c added SecurityManager checks and field/method reflection hiding (JBS:GRAAL-51)
Doug Simon <doug.simon@oracle.com>
parents: 21633
diff changeset
127
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 private static native <S> S[] getServiceImpls(Class<?> service);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 }