< prev index next >

test/hotspot/jtreg/runtime/LoaderConstraints/itableICCE/Test.java

Print this page
rev 49800 : 8199852: Print more information about class loaders in LinkageErrors.
Reviewed-by: dholmes

*** 1,7 **** /* ! * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 42,59 **** // C's super interface I has a different class Foo than the selected method's // type J. But, the selected method is an overpass method (that throws an // ICCE). So, no LinkageError exception should be thrown because the loader // constraint check that would cause the LinkageError should not be done. public static void main(String... args) throws Exception { ! Class<?> c = Foo.class; // forces standard class loader to load Foo ! ClassLoader l = new PreemptingClassLoader("Task", "Foo", "C", "I"); ! Runnable r = (Runnable) l.loadClass("Task").newInstance(); try { r.run(); // Cause an ICCE because both I and J define m()LFoo; throw new RuntimeException("Expected ICCE exception not thrown"); } catch (IncompatibleClassChangeError e) { ! if (!e.getMessage().contains("Conflicting default methods: I.m J.m")) { throw new RuntimeException("Wrong ICCE exception thrown: " + e.getMessage()); } } } } --- 42,59 ---- // C's super interface I has a different class Foo than the selected method's // type J. But, the selected method is an overpass method (that throws an // ICCE). So, no LinkageError exception should be thrown because the loader // constraint check that would cause the LinkageError should not be done. public static void main(String... args) throws Exception { ! Class<?> c = test.Foo.class; // forces standard class loader to load Foo ! ClassLoader l = new PreemptingClassLoader("test.Task", "test.Foo", "test.C", "test.I"); ! Runnable r = (Runnable) l.loadClass("test.Task").newInstance(); try { r.run(); // Cause an ICCE because both I and J define m()LFoo; throw new RuntimeException("Expected ICCE exception not thrown"); } catch (IncompatibleClassChangeError e) { ! if (!e.getMessage().contains("Conflicting default methods: test/I.m test/J.m")) { throw new RuntimeException("Wrong ICCE exception thrown: " + e.getMessage()); } } } }
< prev index next >