--- old/test/hotspot/jtreg/runtime/LoaderConstraints/differentLE/Test.java 2018-06-14 15:10:47.823202210 -0400 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/differentLE/Test.java 2018-06-14 15:10:46.347656460 -0400 @@ -75,11 +75,13 @@ // 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 \"\" (instance of PreemptingClassLoader, " + - "child of \"app\" jdk.internal.loader.ClassLoaders$AppClassLoader) wants to load " + + // 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)."; + "by 'app' (instance of jdk.internal.loader.ClassLoaders$AppClassLoader)."; public static void test_access() throws Exception { try { @@ -101,8 +103,9 @@ 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" + + if (!errorMsg.contains(expectedErrorMessage_part1) || + !errorMsg.contains(expectedErrorMessage_part2)) { + System.out.println("Expected: " + expectedErrorMessage_part1 + "" + expectedErrorMessage_part2 + "\n" + "but got: " + errorMsg); throw new RuntimeException("Wrong error message of LinkageError."); } else {