Consider the following code:
class Test {
class Inner {}
void test() {
new Test.Inner(); // compiles successfully
this.new Test.Inner(); // error
}
}
javac reports:
Test.java:6: error: '(' expected
this.new Test.Inner();
^
1 error
However, per JLS 15.9, such code should be accepted. (Relative to JLS7, JLS8 expanded the grammar of class instance creation expressions. See http://mail.openjdk.java.net/pipermail/compiler-dev/2019-January/012923.html for details.)
class Test {
class Inner {}
void test() {
new Test.Inner(); // compiles successfully
this.new Test.Inner(); // error
}
}
javac reports:
Test.java:6: error: '(' expected
this.new Test.Inner();
^
1 error
However, per JLS 15.9, such code should be accepted. (Relative to JLS7, JLS8 expanded the grammar of class instance creation expressions. See http://mail.openjdk.java.net/pipermail/compiler-dev/2019-January/012923.html for details.)