Changeset 14682
- Timestamp:
- 04/17/14 11:49:30 (9 years ago)
- Location:
- trunk/abcl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Java.java
r14466 r14682 1041 1041 } 1042 1042 1043 private static boolean isAssignable(Class<?> from, Class<?> to) { 1044 from = maybeBoxClass(from); 1045 to = maybeBoxClass(to); 1046 if (to.isAssignableFrom(from)) { 1047 return true; 1048 } 1049 if (Byte.class.equals(from)) { 1050 return Short.class.equals(to) || Integer.class.equals(to) || Long.class.equals(to) || Float.class.equals(to) || Double.class.equals(to); 1051 } else if (Short.class.equals(from) || Character.class.equals(from)) { 1052 return Integer.class.equals(to) || Long.class.equals(to) || Float.class.equals(to) || Double.class.equals(to); 1053 } else if (Integer.class.equals(from)) { 1054 return Long.class.equals(to) || Float.class.equals(to) || Double.class.equals(to); 1055 } else if (Long.class.equals(from)) { 1056 return Float.class.equals(to) || Double.class.equals(to); 1057 } else if (Float.class.equals(from)) { 1058 return Double.class.equals(to); 1059 } 1060 return false; 1061 } 1062 1043 1063 private static boolean isApplicableMethod(Class<?>[] methodTypes, 1044 1064 Object[] args) { … … 1046 1066 Class<?> methodType = methodTypes[i]; 1047 1067 Object arg = args[i]; 1048 if (methodType.isPrimitive()) { 1049 Class<?> x = getBoxedClass(methodType); 1050 if (!x.isInstance(arg)) { 1051 return false; 1052 } 1053 } else if (arg != null && !methodType.isInstance(arg)) { 1068 if (!isAssignable(arg.getClass(), methodType)) { 1054 1069 return false; 1055 1070 } … … 1060 1075 private static boolean isMoreSpecialized(Class<?>[] xtypes, Class<?>[] ytypes) { 1061 1076 for (int i = 0; i < xtypes.length; ++i) { 1062 Class<?> xtype = xtypes[i]; 1063 if (xtype.isPrimitive()) { 1064 xtype = getBoxedClass(xtype); 1065 } 1066 Class<?> ytype = ytypes[i]; 1067 if (ytype.isPrimitive()) { 1068 ytype = getBoxedClass(ytype); 1069 } 1077 Class<?> xtype = maybeBoxClass(xtypes[i]); 1078 Class<?> ytype = maybeBoxClass(ytypes[i]); 1070 1079 if (xtype.equals(ytype)) { 1071 1080 continue; 1072 1081 } 1073 if ( ytype.isAssignableFrom(xtype)) {1082 if (isAssignable(xtype, ytype)) { 1074 1083 return true; 1075 1084 } -
trunk/abcl/test/lisp/abcl/java-tests.lisp
r11605 r14682 196 196 t) 197 197 198 (deftest jcall.5 199 (jcall "join" (jstatic "currentThread" "java.lang.Thread") 1 1) 200 nil) 201 202 (deftest jcall.6 203 (jcall "offsetByCodePoints" "foobar" 0 #\Nul) 204 0) 205 198 206 (deftest jfield.1 199 207 (type-of (jfield "java.lang.Integer" "TYPE"))
Note: See TracChangeset
for help on using the changeset viewer.