Java generics test. Fixes #458.