This bug is somehow related to CR 6665356. When the parser see an open parenthesis it continue parsing the rest of the expression disabling type-arguments parsing. This is because otherwise there would be ambiguity between the this expression
( e < 5 && e > 0) //combination of binary operators < and >
and this one:
(Foo<String>) //generic cast expression
For this reason javac disables parsing of type-arguments when parsing the content of a parenthesized expression. When a generic cast is ecnountered however, javac has to reconstruct the type-arguments information that has not been parsed yet.
In this example we have that this expression is parsed succesfully:
while this one is not
The reason is that the parser is seeing an open parenthesis and, in order to avoid ambiguities, it disables type-argument parsing, as described above. In such a mode, there's no way to parse ".<Object>cast..." so the parser thinks that the end of the parenthesized expression is just after the '.', while it's not.
Since generic method calls with explicit type-arguments are the only kind of expression such that the symbol '<' can follow an '.' , it is safe to temporary re-enable type-arguments parsing right after a '.' has been read (and re-disabling it after type-arguments --- if any --- have been parsed).