@mengxr Doesn't work unfortunately. You won't be able to cast `Foo<Object>` to `Foo<String>` in Java in general and it doesn't compile for me. I feel like I'm missing something and would like to figure it out; there may be some tweak needed on the Scala side? But at least for here, the snippet proposed in this PR does compile and work and isn't too different.