Skip to content

Commit 5c364fc

Browse files
committed
Merge branch 'issue-74'
2 parents 7dc2afa + cd12d5b commit 5c364fc

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

runtime/src/main/java/com4j/DispatchComMethod.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com4j;
22

33
import java.lang.reflect.Method;
4+
import java.util.HashMap;
5+
import java.util.Map;
46

57
/**
68
* {@link ComMethod} that invokes through {@code IDispatch.Invoke}.
@@ -13,7 +15,6 @@ final class DispatchComMethod extends ComMethod {
1315
final int flag;
1416
final Class<?> retType;
1517

16-
1718
DispatchComMethod( Method m ) {
1819
super(m);
1920

@@ -24,7 +25,10 @@ final class DispatchComMethod extends ComMethod {
2425

2526
flag = getFlag();
2627

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;
2832
}
2933

3034
private int getFlag() {
@@ -58,4 +62,17 @@ Object invoke(long ptr, Object[] args) {
5862
private static final int DISPATCH_PROPERTYPUT = 0x4;
5963
@SuppressWarnings("unused")
6064
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+
}
6178
}

0 commit comments

Comments
 (0)