java: Clean up constant pool API

Signed-off-by: Pekka Enberg <penberg@kernel.org>