1
1
package com4j ;
2
2
3
3
import java .lang .reflect .Method ;
4
+ import java .util .HashMap ;
5
+ import java .util .Map ;
4
6
5
7
/**
6
8
* {@link ComMethod} that invokes through {@code IDispatch.Invoke}.
@@ -13,7 +15,6 @@ final class DispatchComMethod extends ComMethod {
13
15
final int flag ;
14
16
final Class <?> retType ;
15
17
16
-
17
18
DispatchComMethod ( Method m ) {
18
19
super (m );
19
20
@@ -24,7 +25,10 @@ final class DispatchComMethod extends ComMethod {
24
25
25
26
flag = getFlag ();
26
27
27
- retType = m .getReturnType ();
28
+ Class retType = m .getReturnType ();
29
+ if (retType .isPrimitive () && boxTypeMap .containsKey (retType ))
30
+ retType = boxTypeMap .get (retType );
31
+ this .retType = retType ;
28
32
}
29
33
30
34
private int getFlag () {
@@ -58,4 +62,17 @@ Object invoke(long ptr, Object[] args) {
58
62
private static final int DISPATCH_PROPERTYPUT = 0x4 ;
59
63
@ SuppressWarnings ("unused" )
60
64
private static final int DISPATCH_PROPERTYPUTREF = 0x8 ;
65
+
66
+ private static final Map <Class ,Class > boxTypeMap = new HashMap <Class ,Class >();
67
+
68
+ static {
69
+ boxTypeMap .put (byte .class ,Byte .class );
70
+ boxTypeMap .put (short .class ,Short .class );
71
+ boxTypeMap .put (int .class ,Integer .class );
72
+ boxTypeMap .put (long .class ,Long .class );
73
+ boxTypeMap .put (float .class ,Float .class );
74
+ boxTypeMap .put (double .class ,Double .class );
75
+ boxTypeMap .put (boolean .class ,Boolean .class );
76
+ boxTypeMap .put (char .class ,Character .class );
77
+ }
61
78
}
0 commit comments