Skip to content

Commit 2f9c6bf

Browse files
committed
[GR-60601] Fix persiting enum values in annotations
PullRequest: graal/19665
2 parents a8009c1 + 142d7a0 commit 2f9c6bf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/SVMImageLayerWriter.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,7 @@ private void persistAnnotationValues(Annotation annotation, Class<? extends Anno
156156
}
157157

158158
private void persistAnnotationValue(Object v, AnnotationValue.Builder b) {
159-
if (v.getClass().isEnum()) {
160-
var ba = b.initEnum();
161-
ba.setClassName(v.getClass().getName());
162-
ba.setName(v.toString());
163-
} else if (v.getClass().isArray()) {
159+
if (v.getClass().isArray()) {
164160
if (v instanceof Object[] array) {
165161
var ba = b.initMembers();
166162
ba.setClassName(v.getClass().getComponentType().getName());
@@ -187,6 +183,11 @@ private void persistAnnotationValue(Object v, AnnotationValue.Builder b) {
187183
case Annotation innerAnnotation ->
188184
persistAnnotationValues(innerAnnotation, innerAnnotation.annotationType(), b.initAnnotation()::initValues);
189185
case String s -> b.setString(s);
186+
case Enum<?> e -> {
187+
var ba = b.initEnum();
188+
ba.setClassName(e.getDeclaringClass().getName());
189+
ba.setName(e.name());
190+
}
190191
default -> throw AnalysisError.shouldNotReachHere("Unknown annotation value: " + v);
191192
}
192193
}

0 commit comments

Comments
 (0)