File tree 1 file changed +21
-1
lines changed
compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -94,18 +94,38 @@ private static void addProviders(String arch, Class<?> service) {
94
94
// Skip provider for another architecture
95
95
continue ;
96
96
}
97
+ if (provider .getClass ().getAnnotation (LibGraalSupport .HostedOnly .class ) != null ) {
98
+ // Skip hosted-only providers
99
+ continue ;
100
+ }
97
101
providers .add (provider );
98
102
}
99
103
}
100
104
105
+ /**
106
+ * Determines if {@code c} is annotated by {@link LibGraalService}.
107
+ */
108
+ static boolean isLibGraalService (Class <?> c ) {
109
+ if (c != null && c .getAnnotation (LibGraalService .class ) != null ) {
110
+ if (c .getAnnotation (LibGraalSupport .HostedOnly .class ) != null ) {
111
+ throw new GraalError ("Class %s cannot be annotated by both %s and %s as they are mutually exclusive)" ,
112
+ c .getName (),
113
+ LibGraalService .class .getName (),
114
+ LibGraalSupport .HostedOnly .class .getName ());
115
+ }
116
+ return true ;
117
+ }
118
+ return false ;
119
+ }
120
+
101
121
static {
102
122
LibGraalSupport libgraal = LibGraalSupport .INSTANCE ;
103
123
if (libgraal != null ) {
104
124
libgraalServices = new HashMap <>();
105
125
String arch = getJVMCIArch ();
106
126
libgraal .getClassModuleMap ().keySet ().stream ()//
107
127
.map (GraalServices ::loadClassOrNull )//
108
- .filter (c -> c != null && c . getAnnotation ( LibGraalService . class ) != null )//
128
+ .filter (GraalServices :: isLibGraalService )//
109
129
.forEach (service -> addProviders (arch , service ));
110
130
} else {
111
131
libgraalServices = null ;
You can’t perform that action at this time.
0 commit comments