|
20 | 20 | import io.micronaut.core.annotation.AnnotationUtil;
|
21 | 21 | import io.micronaut.core.annotation.AnnotationClassValue;
|
22 | 22 | import io.micronaut.core.annotation.Internal;
|
| 23 | +import io.micronaut.core.reflect.ClassUtils; |
23 | 24 | import io.micronaut.core.reflect.ReflectionUtils;
|
24 | 25 | import io.micronaut.core.util.CollectionUtils;
|
25 | 26 | import io.micronaut.inject.writer.AbstractClassFileWriter;
|
|
30 | 31 |
|
31 | 32 | import java.io.IOException;
|
32 | 33 | import java.io.OutputStream;
|
33 |
| -import java.util.Collections; |
34 |
| -import java.util.HashMap; |
35 |
| -import java.util.List; |
36 |
| -import java.util.Map; |
| 34 | +import java.lang.reflect.Array; |
| 35 | +import java.util.*; |
37 | 36 |
|
38 | 37 | /**
|
39 | 38 | * Responsible for writing class files that are instances of {@link AnnotationMetadata}.
|
@@ -130,8 +129,8 @@ public class AnnotationMetadataWriter extends AbstractClassFileWriter {
|
130 | 129 | /**
|
131 | 130 | * Constructs a new writer for the given class name and metadata.
|
132 | 131 | *
|
133 |
| - * @param className The class name for which the metadata relates |
134 |
| - * @param annotationMetadata The annotation metadata |
| 132 | + * @param className The class name for which the metadata relates |
| 133 | + * @param annotationMetadata The annotation metadata |
135 | 134 | * @param writeAnnotationDefaults Whether annotations defaults should be written
|
136 | 135 | */
|
137 | 136 | public AnnotationMetadataWriter(String className, AnnotationMetadata annotationMetadata, boolean writeAnnotationDefaults) {
|
@@ -408,13 +407,13 @@ private static void pushValue(Type declaringType, ClassVisitor declaringClassWri
|
408 | 407 | Type t = Type.getType(declaringClass);
|
409 | 408 | methodVisitor.getStatic(t, value.toString(), t);
|
410 | 409 | } else if (value.getClass().isArray()) {
|
411 |
| - Object[] array = (Object[]) value; |
412 |
| - int len = array.length; |
413 |
| - pushNewArray(methodVisitor, ((Object[]) value).getClass().getComponentType(), len); |
414 |
| - for (int i = 0; i < array.length; i++) { |
415 |
| - int index = i; |
| 410 | + final Class<?> componentType = ReflectionUtils.getWrapperType(value.getClass().getComponentType()); |
| 411 | + int len = Array.getLength(value); |
| 412 | + pushNewArray(methodVisitor, componentType, len); |
| 413 | + for (int i = 0; i < len; i++) { |
| 414 | + final Object v = Array.get(value, i); |
416 | 415 | pushStoreInArray(methodVisitor, i, len, () ->
|
417 |
| - pushValue(declaringType, declaringClassWriter, methodVisitor, array[index], loadTypeMethods) |
| 416 | + pushValue(declaringType, declaringClassWriter, methodVisitor, v, loadTypeMethods) |
418 | 417 | );
|
419 | 418 | }
|
420 | 419 | } else if (value instanceof List) {
|
|
0 commit comments