29 import com.sun.jdi.InvalidTypeException; 30 import com.sun.jdi.Value; 31 import com.sun.jdi.VirtualMachine; 32 33 abstract class ValueImpl extends MirrorImpl implements Value { 34 35 ValueImpl(VirtualMachine aVm) { 36 super(aVm); 37 } 38 39 static ValueImpl prepareForAssignment(Value value, 40 ValueContainer destination) 41 throws InvalidTypeException, ClassNotLoadedException { 42 if (value == null) { 43 /* 44 * TO DO: Centralize JNI signature knowledge 45 */ 46 if (destination.signature().length() == 1) { 47 throw new InvalidTypeException("Can't set a primitive type to null"); 48 } 49 return null; // no further checking or conversion necessary 50 } else { 51 return ((ValueImpl)value).prepareForAssignmentTo(destination); 52 } 53 } 54 55 static byte typeValueKey(Value val) { 56 if (val == null) { 57 return JDWP.Tag.OBJECT; 58 } else { 59 return ((ValueImpl)val).typeValueKey(); 60 } 61 } 62 63 abstract ValueImpl prepareForAssignmentTo(ValueContainer destination) 64 throws InvalidTypeException, ClassNotLoadedException; 65 66 abstract byte typeValueKey(); 67 } | 29 import com.sun.jdi.InvalidTypeException; 30 import com.sun.jdi.Value; 31 import com.sun.jdi.VirtualMachine; 32 33 abstract class ValueImpl extends MirrorImpl implements Value { 34 35 ValueImpl(VirtualMachine aVm) { 36 super(aVm); 37 } 38 39 static ValueImpl prepareForAssignment(Value value, 40 ValueContainer destination) 41 throws InvalidTypeException, ClassNotLoadedException { 42 if (value == null) { 43 /* 44 * TO DO: Centralize JNI signature knowledge 45 */ 46 if (destination.signature().length() == 1) { 47 throw new InvalidTypeException("Can't set a primitive type to null"); 48 } 49 if (destination.signature().charAt(0) == 'Q') { 50 throw new InvalidTypeException("Can't set an inline type to null"); 51 } 52 return null; // no further checking or conversion necessary 53 } else { 54 return ((ValueImpl)value).prepareForAssignmentTo(destination); 55 } 56 } 57 58 static byte typeValueKey(Value val) { 59 if (val == null) { 60 return JDWP.Tag.OBJECT; 61 } else { 62 return ((ValueImpl)val).typeValueKey(); 63 } 64 } 65 66 abstract ValueImpl prepareForAssignmentTo(ValueContainer destination) 67 throws InvalidTypeException, ClassNotLoadedException; 68 69 abstract byte typeValueKey(); 70 } |