use of com.oracle.svm.core.util.LazyFinalReference in project graal by oracle.
the class Target_java_lang_reflect_RecordComponent method initEnumConstantsAtRuntime.
@Platforms(Platform.HOSTED_ONLY.class)
public void initEnumConstantsAtRuntime(Class<?> enumClass) {
/* Adapted from `Class.getEnumConstantsShared`. */
try {
Method values = ReflectionUtil.lookupMethod(enumClass, "values");
enumConstantsReference = new LazyFinalReference<>(() -> initEnumConstantsAtRuntime(values));
} catch (ReflectionUtilError e) {
/*
* This can happen when users concoct enum-like classes that don't comply with the enum
* spec.
*/
enumConstantsReference = null;
} catch (NoClassDefFoundError e) {
/*
* This can happen when an enum references a missing class. So, in order to match the
* JVM behaviour, we rethrow the error at runtime.
*/
String message = e.getMessage();
enumConstantsReference = new LazyFinalReference<>(() -> throwNoClassDefFoundErrorAtRuntime(message));
}
}
Aggregations