FinalThisReference.java revision 553:9d9f26857129
1306196Sjkim/* 296593Smarkm * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. 396593Smarkm * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4142429Snectar * 596593Smarkm * This code is free software; you can redistribute it and/or modify it 696593Smarkm * under the terms of the GNU General Public License version 2 only, as 796593Smarkm * published by the Free Software Foundation. 896593Smarkm * 996593Smarkm * This code is distributed in the hope that it will be useful, but WITHOUT 1096593Smarkm * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1196593Smarkm * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1296593Smarkm * version 2 for more details (a copy is included in the LICENSE file that 1396593Smarkm * accompanied this code). 1496593Smarkm * 1596593Smarkm * You should have received a copy of the GNU General Public License version 1696593Smarkm * 2 along with this work; if not, write to the Free Software Foundation, 1796593Smarkm * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1896593Smarkm * 1996593Smarkm * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20215698Ssimon * or visit www.oracle.com if you need additional information or have any 21215698Ssimon * questions. 22215698Ssimon */ 23215698Ssimon 24215698Ssimon/* 2596593Smarkm * @test 2696593Smarkm * @bug 4285004 2796593Smarkm * @summary Verify that final field can have 'this' as initializer. 2896593Smarkm * @author maddox 2996593Smarkm * 3096593Smarkm * @run compile FinalThisReference.java 3196593Smarkm */ 3296593Smarkm 3396593Smarkmclass A { 3496593Smarkm B b = new B(); 3596593Smarkm { 3696593Smarkm System.out.println(b.value); 3796593Smarkm } 3896593Smarkm} 3996593Smarkm 4096593Smarkmclass B { 41276864Sjkim final B value = this; 42276864Sjkim} 4396593Smarkm