It doesn't compile because the type of the second argument in the Pair<,> of the statement is String and that type might not be the "unknown" type that was used in the declaration. I think it will compile if you replace the ? with Object. Of course, you will then lose compile-time type-checking.