comparison graal/com.oracle.jvmci.service/src/com/oracle/jvmci/service/Services.java @ 21633:9966b358bc2b

Services: don't throw exceptions or print warnings when there are no implementations for a non-required service
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Mon, 01 Jun 2015 15:14:20 +0200
parents 2f92172fa320
children 6d9c8d0d0f7c
comparison
equal deleted inserted replaced
21632:abcb811659e0 21633:9966b358bc2b
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.oracle.jvmci.service; 23 package com.oracle.jvmci.service;
24 24
25 import static java.lang.String.*;
26
27 import java.util.*; 25 import java.util.*;
28 26
29 import sun.reflect.*; 27 import sun.reflect.*;
30 28
31 /** 29 /**
37 public class Services { 35 public class Services {
38 36
39 private static final ClassValue<List<Service>> cache = new ClassValue<List<Service>>() { 37 private static final ClassValue<List<Service>> cache = new ClassValue<List<Service>>() {
40 @Override 38 @Override
41 protected List<Service> computeValue(Class<?> type) { 39 protected List<Service> computeValue(Class<?> type) {
42 Service[] names = getServiceImpls(type); 40 return Arrays.asList(getServiceImpls(type));
43 if (names == null || names.length == 0) {
44 throw new InternalError(
45 format("No implementations for %s found (ensure %s extends %s and that in suite.py the \"annotationProcessors\" attribute for the project enclosing %s includes \"com.oracle.jvmci.service.processor\")",
46 type.getSimpleName(), type.getSimpleName(), Service.class, type.getSimpleName()));
47 }
48 return Arrays.asList(names);
49 } 41 }
50 }; 42 };
51 43
52 /** 44 /**
53 * Gets an {@link Iterable} of the implementations available for a given service. 45 * Gets an {@link Iterable} of the implementations available for a given service.