Path: blob/master/test/hotspot/jtreg/runtime/LoaderConstraints/itableICCE/Test.java
40948 views
/*1* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 818609226* @compile ../common/Foo.java27* I.java28* ../common/J.java29* ../common/C.jasm30* Task.java31* ../common/PreemptingClassLoader.java32* @run main/othervm Test33*/3435public class Test {3637// Test that LinkageError exceptions are not thrown during itable creation,38// for loader constraint errors, if the target method is an overpass method.39//40// In this test, during itable creation for class C, method "m()LFoo;" for41// C's super interface I has a different class Foo than the selected method's42// type J. But, the selected method is an overpass method (that throws an43// ICCE). So, no LinkageError exception should be thrown because the loader44// constraint check that would cause the LinkageError should not be done.45public static void main(String... args) throws Exception {46Class<?> c = test.Foo.class; // forces standard class loader to load Foo47ClassLoader l = new PreemptingClassLoader("test.Task", "test.Foo", "test.C", "test.I");48Runnable r = (Runnable) l.loadClass("test.Task").newInstance();49try {50r.run(); // Cause an ICCE because both I and J define m()LFoo;51throw new RuntimeException("Expected ICCE exception not thrown");52} catch (IncompatibleClassChangeError e) {53if (!e.getMessage().contains("Conflicting default methods: test/I.m test/J.m")) {54throw new RuntimeException("Wrong ICCE exception thrown: " + e.getMessage());55}56}57}58}596061