comparison graal/com.oracle.jvmci.options/src/com/oracle/jvmci/options/OptionsLoader.java @ 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
author Doug Simon <doug.simon@oracle.com>
date Sat, 06 Jun 2015 09:23:37 +0200
parents 93f282187d90
children
comparison
equal deleted inserted replaced
21759:75daca0c6a0f 21760:55058b8000ea
22 */ 22 */
23 package com.oracle.jvmci.options; 23 package com.oracle.jvmci.options;
24 24
25 import java.util.*; 25 import java.util.*;
26 26
27 import com.oracle.jvmci.service.*;
28
29 /** 27 /**
30 * Helper class used to load option descriptors. Only to be used in the slow-path. 28 * Helper class used to load option descriptors. Only to be used in the slow-path.
31 */ 29 */
32 public class OptionsLoader { 30 public class OptionsLoader {
33 public static final SortedMap<String, OptionDescriptor> options = new TreeMap<>(); 31 public static final SortedMap<String, OptionDescriptor> options = new TreeMap<>();
34 32
35 /** 33 /**
36 * Initializes {@link #options} from {@link Options} services. 34 * Initializes {@link #options} from {@link Options} services.
37 */ 35 */
38 static { 36 static {
39 for (Options opts : Services.load(Options.class)) { 37 for (Options opts : ServiceLoader.load(Options.class, OptionsLoader.class.getClassLoader())) {
40 for (OptionDescriptor desc : opts) { 38 for (OptionDescriptor desc : opts) {
41 String name = desc.getName(); 39 String name = desc.getName();
42 OptionDescriptor existing = options.put(name, desc); 40 OptionDescriptor existing = options.put(name, desc);
43 assert existing == null : "Option named \"" + name + "\" has multiple definitions: " + existing.getLocation() + " and " + desc.getLocation(); 41 assert existing == null : "Option named \"" + name + "\" has multiple definitions: " + existing.getLocation() + " and " + desc.getLocation();
44 } 42 }