Skip to content

Commit 4798d30

Browse files
committed
Annotation type fix for primitive return values
1 parent af68d5c commit 4798d30

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

sources/net.sf.j2s.java.core/src/sun/reflect/annotation/AnnotationParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ private static Object setLocalAnnotationValue(Annotation a, String key, Object o
277277
val = Enum.valueOf((Class<Enum>) type, (String) val);
278278
} else if (type.isPrimitive()) {
279279
val = boxValue(val, type);
280+
/** @j2sNative val = val.valueOf(); */
280281
} else if (type == Class.class) {
281282
val = Class.forName(((String) val).replace(".class", ""));
282283
} else {

sources/net.sf.j2s.java.core/src/sun/reflect/annotation/AnnotationType.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private AnnotationType(final Class<? extends Annotation> annotationClass) {
105105
for (Method method : methods) {
106106
String name = method.getName();
107107
Class<?> type = method.getReturnType();
108-
memberTypes.put(name, invocationHandlerReturnType(type));
108+
memberTypes.put(name, type);//invocationHandlerReturnType(type));
109109
members.put(name, method);
110110

111111
Object defaultValue = method.getDefaultValue();
@@ -142,23 +142,24 @@ private AnnotationType(final Class<? extends Annotation> annotationClass) {
142142
* for an annotation).
143143
*/
144144
public static Class<?> invocationHandlerReturnType(Class<?> type) {
145+
// No! That is not how it works.
145146
// Translate primitives to wrappers
146-
if (type == byte.class)
147-
return Byte.class;
148-
if (type == char.class)
149-
return Character.class;
150-
if (type == double.class)
151-
return Double.class;
152-
if (type == float.class)
153-
return Float.class;
154-
if (type == int.class)
155-
return Integer.class;
156-
if (type == long.class)
157-
return Long.class;
158-
if (type == short.class)
159-
return Short.class;
160-
if (type == boolean.class)
161-
return Boolean.class;
147+
// if (type == byte.class)
148+
// return Byte.class;
149+
// if (type == char.class)
150+
// return Character.class;
151+
// if (type == double.class)
152+
// return Double.class;
153+
// if (type == float.class)
154+
// return Float.class;
155+
// if (type == int.class)
156+
// return Integer.class;
157+
// if (type == long.class)
158+
// return Long.class;
159+
// if (type == short.class)
160+
// return Short.class;
161+
// if (type == boolean.class)
162+
// return Boolean.class;
162163

163164
// Otherwise, just return declared type
164165
return type;

0 commit comments

Comments
 (0)