< prev index next >

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

Print this page

        

*** 73,87 **** // it tries to load interface A. As it does not find it (there is no A.impl2), // it asks the super classloader for A. // Then it loads the D2 variant of D from the current working directory and it's // superclass C. This fails as D1 is already loaded with the same superclass. ! static String expectedErrorMessage = ! "loader constraint violation: loader \"<unnamed>\" (instance of PreemptingClassLoader, " + ! "child of \"app\" jdk.internal.loader.ClassLoaders$AppClassLoader) wants to load " + "class test.D_ambgs. A different class with the same name was previously loaded " + ! "by \"app\" (instance of jdk.internal.loader.ClassLoaders$AppClassLoader)."; public static void test_access() throws Exception { try { // Make a Class 'D_ambgs' under the default loader. // This uses the implementation from the .java file. --- 73,89 ---- // it tries to load interface A. As it does not find it (there is no A.impl2), // it asks the super classloader for A. // Then it loads the D2 variant of D from the current working directory and it's // superclass C. This fails as D1 is already loaded with the same superclass. ! // Break the expectedErrorMessage into 2 pieces since the loader name will include ! // its identity hash and can not be compared against. ! static String expectedErrorMessage_part1 = "loader constraint violation: loader PreemptingClassLoader @"; ! static String expectedErrorMessage_part2 = " (instance of PreemptingClassLoader, " + ! "child of 'app' jdk.internal.loader.ClassLoaders$AppClassLoader) wants to load " + "class test.D_ambgs. A different class with the same name was previously loaded " + ! "by 'app' (instance of jdk.internal.loader.ClassLoaders$AppClassLoader)."; public static void test_access() throws Exception { try { // Make a Class 'D_ambgs' under the default loader. // This uses the implementation from the .java file.
*** 99,110 **** D_ambgs[] x2 = c_1.make(iface); throw new RuntimeException("Expected LinkageError was not thrown."); } catch (LinkageError jle) { String errorMsg = jle.getMessage(); ! if (!errorMsg.equals(expectedErrorMessage)) { ! System.out.println("Expected: " + expectedErrorMessage + "\n" + "but got: " + errorMsg); throw new RuntimeException("Wrong error message of LinkageError."); } else { System.out.println("Passed with message: " + errorMsg); } --- 101,113 ---- D_ambgs[] x2 = c_1.make(iface); throw new RuntimeException("Expected LinkageError was not thrown."); } catch (LinkageError jle) { String errorMsg = jle.getMessage(); ! if (!errorMsg.contains(expectedErrorMessage_part1) || ! !errorMsg.contains(expectedErrorMessage_part2)) { ! System.out.println("Expected: " + expectedErrorMessage_part1 + "<id>" + expectedErrorMessage_part2 + "\n" + "but got: " + errorMsg); throw new RuntimeException("Wrong error message of LinkageError."); } else { System.out.println("Passed with message: " + errorMsg); }
< prev index next >