Changeset 11559


Ignore:
Timestamp:
01/15/09 23:52:27 (12 years ago)
Author:
astalla
Message:

Better handling of java<->lisp value conversion in (get/set)
jproperty-value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/scripting/j/src/org/armedbear/lisp/Java.java

    r11552 r11559  
    705705        Object obj = javaObject.javaInstance();
    706706        PropertyDescriptor pd = getPropertyDescriptor(obj, propertyName);
    707         return new JavaObject(pd.getReadMethod().invoke(obj));
     707        Object value = pd.getReadMethod().invoke(obj);
     708        if(value instanceof LispObject) {
     709            return (LispObject) value;
     710        } else if(value != null) {
     711            return new JavaObject(value);
     712        } else {
     713            return NIL;
     714        }
    708715      } catch (Exception e) {
    709716        ConditionThrowable t = new ConditionThrowable("Exception reading property");
     
    723730    obj = javaObject.javaInstance();
    724731    PropertyDescriptor pd = getPropertyDescriptor(obj, propertyName);
    725     pd.getWriteMethod().invoke(obj, value.javaInstance());
     732    Object jValue;
     733    if(value == NIL) {
     734        if(Boolean.TYPE.equals(pd.getPropertyType()) ||
     735           Boolean.class.equals(pd.getPropertyType())) {
     736      jValue = false;
     737        } else {
     738      jValue = null;
     739        }
     740    } else {
     741        jValue = value.javaInstance();
     742    }
     743    pd.getWriteMethod().invoke(obj, jValue);
    726744    return value;
    727745      } catch (Exception e) {
Note: See TracChangeset for help on using the changeset viewer.