Two problems with generics in Java