use of com.oracle.graal.pointsto.infrastructure.WrappedJavaType in project graal by oracle.
the class InfoTreeBuilder method createEnumInfo.
private void createEnumInfo(ResolvedJavaType type) {
if (!nativeLibs.isEnum(type)) {
nativeLibs.addError("Annotation @" + CEnum.class.getSimpleName() + " can only be used on an Java enumeration", type);
return;
}
CEnum annotation = type.getAnnotation(CEnum.class);
String name = annotation.value();
if (!name.isEmpty()) {
if (annotation.addEnumKeyword()) {
name = "enum " + name;
}
} else {
name = "int";
}
EnumInfo enumInfo = new EnumInfo(name, type);
/* Use the wrapped type to avoid registering all CEnum annotated classes as reachable. */
ResolvedJavaType wrappedType = ((WrappedJavaType) type).getWrapped();
for (ResolvedJavaField field : wrappedType.getStaticFields()) {
assert Modifier.isStatic(field.getModifiers());
if (Modifier.isFinal(field.getModifiers()) && field.getType().equals(wrappedType)) {
createEnumConstantInfo(enumInfo, field);
}
}
for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
if (getMethodAnnotation(method, CEnumValue.class) != null) {
createEnumValueInfo(enumInfo, method);
}
if (getMethodAnnotation(method, CEnumLookup.class) != null) {
createEnumLookupInfo(enumInfo, method);
}
}
nativeCodeInfo.adoptChild(enumInfo);
nativeLibs.registerElementInfo(type, enumInfo);
}
Aggregations