ValueImpl convertForAssignmentTo()

in src/main/java/com/jetbrains/jdi/PrimitiveValueImpl.java [118:147]


    ValueImpl convertForAssignmentTo(ValueContainer destination)
        throws InvalidTypeException
    {
        JNITypeParser destSig = new JNITypeParser(destination.signature());
        JNITypeParser sourceSig = new JNITypeParser(type().signature());

        if (destSig.isReference()) {
            throw new InvalidTypeException("Can't assign primitive value to object");
        }

        if (destSig.isBoolean() && !sourceSig.isBoolean()) {
            throw new InvalidTypeException("Can't assign non-boolean value to a boolean");
        }

        if (!destSig.isBoolean() && sourceSig.isBoolean()) {
            throw new InvalidTypeException("Can't assign boolean value to an non-boolean");
        }

        if (destSig.isVoid()) {
            throw new InvalidTypeException("Can't assign primitive value to a void");
        }

        try {
            PrimitiveTypeImpl primitiveType = (PrimitiveTypeImpl)destination.type();
            return (ValueImpl)(primitiveType.convert(this));
        } catch (ClassNotLoadedException e) {
            throw new InternalException("Signature and type inconsistent for: " +
                                        destination.typeName());
        }
    }