InstanceInitException_1.java revision 0:9a66ca7c79fa
155714Skris/* 255714Skris * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. 355714Skris * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 455714Skris * 555714Skris * This code is free software; you can redistribute it and/or modify it 655714Skris * under the terms of the GNU General Public License version 2 only, as 755714Skris * published by the Free Software Foundation. 868651Skris * 968651Skris * This code is distributed in the hope that it will be useful, but WITHOUT 1068651Skris * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1168651Skris * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1276866Skris * version 2 for more details (a copy is included in the LICENSE file that 1355714Skris * accompanied this code). 1455714Skris * 1568651Skris * You should have received a copy of the GNU General Public License version 1668651Skris * 2 along with this work; if not, write to the Free Software Foundation, 1768651Skris * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18109998Smarkm * 19109998Smarkm * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20109998Smarkm * CA 95054 USA or visit www.sun.com if you need additional information or 21109998Smarkm * have any questions. 22109998Smarkm */ 2355714Skris 2455714Skris/* 2555714Skris * @test 2655714Skris * @bug 4054256 2755714Skris * @summary Verify that instance initializers can throw checked exceptions. 2855714Skris * @author William Maddox 2955714Skris * 3055714Skris * @run compile InstanceInitException_1.java 3155714Skris */ 3255714Skris 3355714Skrispublic class InstanceInitException_1 { 3455714Skris 3555714Skris int i = 1; 3655714Skris 3755714Skris InstanceInitException_1() throws Throwable {} 3855714Skris 3955714Skris { 4055714Skris if (i > 0) throw new Throwable(); 4155714Skris } 4255714Skris 4355714Skris class Inner1 { 4455714Skris 4555714Skris Inner1() throws Throwable {} 4655714Skris 4755714Skris { 4855714Skris if (i > 0) throw new Throwable(); 4955714Skris } 5055714Skris 5155714Skris } 5255714Skris 5355714Skris class Exn1 extends Throwable {} 5455714Skris class Exn2 extends Exception {} 5555714Skris 5655714Skris class Inner2 { 5755714Skris 5855714Skris Inner2() throws Exn1, Exn2 {} 5955714Skris 60160814Ssimon { 61160814Ssimon if (i > 0) throw new Exn1(); 6255714Skris if (i > 0) throw new Exn2(); 6376866Skris } 6455714Skris 6576866Skris } 66243933Seadler 67243933Seadler void test() throws Throwable { 6855714Skris 69238405Sjkim new Object() { 7055714Skris { 7159191Skris if (i > 0) throw new Throwable(); 7268651Skris } 73109998Smarkm }; 74205128Ssimon 7555714Skris } 76111147Snectar 77111147Snectar} 78111147Snectar