jdk
1/*
2* @test /nodynamiccopyright/
3* @bug 6521805
4* @summary Regression: JDK5/JDK6 javac allows write access to outer class reference
5* @author mcimadamore
6*
7* @compile/fail/ref=T6521805d.out T6521805d.java -XDrawDiagnostics
8*/
9
10import java.util.Objects;
11
12class T6521805 {
13
14static class Inner extends T6521805.Outer {
15
16Inner(T6521805 t) {
17t.super();
18}
19
20T6521805 this$0 = null;
21
22public void foo() {
23this$0 = new T6521805();
24}
25}
26
27class Outer {
28{
29// access enclosing instance so this$0 field is generated
30Objects.requireNonNull(T6521805.this);
31}
32}
33
34}
35