I think the compiler treats "
new myClass().myMethod;" as "
new( myClass() ).myMethod();".
Compilers encounter tokens from left to right and, on encountering the
new operator, expect to see an identifier followed by a left paren, possibly a parameter list, and a right paren (I omit several other cases here). This does not follow the precedence rules, but see the following quote from the
Java Language Specification:
15.7.5 Evaluation Order for Other Expressions
The order of evaluation for some expressions is not completely covered by these general rules, because these expressions may raise exceptional conditions at times that must be specified. See, specifically, the detailed explanations of evaluation order for the following kinds of expressions:
class instance creation expressions (�15.9.4)
array creation expressions (�15.10.1)
method invocation expressions (�15.12.4)
array access expressions (�15.13.1)
assignments involving array components (�15.26)
The final authority on Java syntax as implemented by Java compilers is not the precedence table but the context-free grammars in the Java Language Specification which are, in turn, the input to the JavaCC parser generator and similar programs. You could go through chapter 15 and verify the parsing of "new MyClass().myMethod();".