Allow to convert Java value to literal of certain type.

Change-Id: I99c5ee75737b3a7aeec4e001f47ef7b5b2178f68