Qualified class name inside qualified instance creation expression
Tagir Valeev
amaembo at gmail.com
Fri Feb 1 04:54:08 UTC 2019
Hello, Alex! Thank you for your answer.
> Correct. There has been shimmer in this part of the language. In Java SE
> 7, `this.new Test.Inner()` was illegal; only `this.new SIMPLENAME()` was
> allowed. (See
> https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.9)
> In Java SE 8, the grammar of `ClassInstanceCreationExpression` was
> modified to support type annotations, and `this.new QUALIFIEDNAME()` was
> allowed. In principle, there is no reason to disallow a qualified name
> in a qualified CICE. The phrase `new Test.Inner()` is meaningful as an
> unqualified CICE, and enriching the phrase to be a qualified CICE, with
> an explicit immediately enclosing instance, doesn't make it
> unmeaningful. I suspect javac is still expecting (modulo type arguments)
> a simple name after `new`.
Thank you for Java 7 pointer, I wasn't aware that this part was changed.
In our IDE we don't highlight such code as erroneous, and people complain
that it's our problem, because javac rejects it. Seems we have to mimic javac
behavior even if it violates the spec.
With best regards,
Tagir Valeev.
More information about the compiler-dev
mailing list