JDK 1.7 vs JDK 1.6 inner classes inheritance difference

Viewed 700

I'm on solving some Java puzzles and stumbled on this one:

public class Outer {
    class Inner1 extends Outer {}
    class Inner2 extends Inner1 {}
}

While compiling this code with javac 1.6.0_45 I'm getting, as expected, this error:

Outer.java:8: cannot reference this before supertype constructor has been called
class Inner2 extends Inner1 {}                                                                                                
^

This is because of compiler generates default constructor for Inner2 class with similar code, which explains error above:

Inner2 () {
    this.super();
}

And it's obvious now, because you really can't do this in Java 1.6.0_45, JLS 8.8.7.1 (as I can guess):

An explicit constructor invocation statement in a constructor body may not refer to any instance variables or instance methods declared in this class or any superclass, or use this or super in any expression; otherwise, a compile-time error occurs.

See (accepted answer in Odd situation for "cannot reference this before supertype constructor has been called")

But if I try to compile it with javac 1.7.0_79 - it is OK!

And here goes the question - What has been changed in Java 1.7, that this code is now correct?

Thanks in advance!

2 Answers
Related