1/* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/* 25 * @test 26 * @bug 8026394 27 * @summary clone() and finalize() interface resolution should not receive IAE 28 * @run main InterfaceObjectTest 29 */ 30interface IClone extends Cloneable { 31 void finalize() throws Throwable; 32 Object clone(); 33} 34 35interface ICloneExtend extends IClone { } 36 37public class InterfaceObjectTest implements ICloneExtend { 38 39 public Object clone() { 40 System.out.println("In InterfaceObjectTest's clone() method\n"); 41 return null; 42 } 43 44 public void finalize() throws Throwable { 45 try { 46 System.out.println("In InterfaceObjectTest's finalize() method\n"); 47 } catch (Throwable t) { 48 throw new AssertionError(t); 49 } 50 } 51 52 public static void tryIt(ICloneExtend o1) { 53 try { 54 Object o2 = o1.clone(); 55 o1.finalize(); 56 } catch (Throwable t) { 57 if (t instanceof IllegalAccessError) { 58 System.out.println("TEST FAILS - IAE resulted\n"); 59 System.exit(1); 60 } 61 } 62 } 63 64 public static void main(String[] args) { 65 InterfaceObjectTest o1 = new InterfaceObjectTest(); 66 tryIt(o1); 67 System.out.println("TEST PASSES - no IAE resulted\n"); 68 } 69} 70