Improved error handling of broken databases.

Previously we Java was throwing IllegalArgumentExceptions when we
tried to use an invalid pointer. Also added size checks for booleans,
floats, and doubles.