Search in sources :

Example 1 with CEnumConstant

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);
}
Also used : CEnum(org.graalvm.nativeimage.c.constant.CEnum) JavaConstant(jdk.vm.ci.meta.JavaConstant) CEnumConstant(org.graalvm.nativeimage.c.constant.CEnumConstant)

Aggregations

JavaConstant (jdk.vm.ci.meta.JavaConstant)1 CEnum (org.graalvm.nativeimage.c.constant.CEnum)1 CEnumConstant (org.graalvm.nativeimage.c.constant.CEnumConstant)1