java: Move method and field resolvers to common code

Move field and method resolver functions to common code so that they can
be used by other backends.

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