use of org.graalvm.nativeimage.c.constant.CEnumConstant in project graal by oracle.
the class InfoTreeBuilder method createEnumConstantInfo.
private void createEnumConstantInfo(EnumInfo enumInfo, ResolvedJavaField field) {
JavaConstant enumValue = nativeLibs.getConstantReflection().readFieldValue(field, null);
assert enumValue.isNonNull() && nativeLibs.getMetaAccess().lookupJavaType(enumValue).equals(enumInfo.getAnnotatedElement());
CEnumConstant fieldAnnotation = field.getAnnotation(CEnumConstant.class);
String name = "";
boolean includeInLookup = true;
if (fieldAnnotation != null) {
name = fieldAnnotation.value();
includeInLookup = fieldAnnotation.includeInLookup();
}
if (name.length() == 0) {
name = field.getName();
}
EnumConstantInfo constantInfo = new EnumConstantInfo(name, field, includeInLookup, nativeLibs.getSnippetReflection().asObject(Enum.class, enumValue));
enumInfo.adoptChild(constantInfo);
}
Aggregations