--- old/test/hotspot/jtreg/runtime/LoaderConstraints/common/C.jasm 2018-04-12 12:05:06.915363000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/common/C.jasm 2018-04-12 12:05:06.445327000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/common/Foo.java 2018-04-12 12:05:08.136464000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/common/Foo.java 2018-04-12 12:05:07.659424000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/common/J.java 2018-04-12 12:05:09.350590000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/common/J.java 2018-04-12 12:05:08.884527000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/common/PreemptingClassLoader.java 2018-04-12 12:05:10.638672000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/common/PreemptingClassLoader.java 2018-04-12 12:05:10.104625000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/differentLE/Test.java 2018-04-12 12:05:11.876770000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/differentLE/Test.java 2018-04-12 12:05:11.397739000 +0200 @@ -60,7 +60,7 @@ // C // An abstract class. // | // D // Class with two different implementations D1 and D2. D2 is - // // compiled to the current working directory so that it is found by our + // // compiled to the current working directory so that it is found by our // // special class loader. // // First, the bootstrap loader will load D1. It already has loaded interface A. @@ -86,7 +86,7 @@ // Some classes under a new Loader, loader2, including, indirectly, // another version of 'D_ambgs' String[] classNames = {"B", "D_ambgs"}; - + ClassLoader loader2 = new PreemptingClassLoader(null, classNames, false); Class class2 = loader2.loadClass("B"); A iface = (A)class2.newInstance(); --- old/test/hotspot/jtreg/runtime/LoaderConstraints/duplicateLE/Test.java 2018-04-12 12:05:13.108872000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/duplicateLE/Test.java 2018-04-12 12:05:12.610830000 +0200 @@ -40,6 +40,12 @@ "loader instance of PreemptingClassLoader (parent: \"app\" " + "jdk.internal.loader.ClassLoaders$AppClassLoader) attempted duplicate class definition for test.Foo."; + // Check that all names have external formatting ('.' and not '/' in package names). + // Check for name and parent of class loader. + static String expectedErrorMessage2 = + "loader \"DuplicateLE_Test_Loader\" (instance of PreemptingClassLoader, parent: \"app\" " + + "jdk.internal.loader.ClassLoaders$AppClassLoader) attempted duplicate class definition for test.Foo."; + // Test that the error message is correct when a loader constraint error is // detected during vtable creation. // @@ -47,17 +53,17 @@ // overrides "J.m()LFoo;". But, Task's class Foo and super type J's class Foo // are different. So, a LinkageError exception should be thrown because the // loader constraint check will fail. - public static void test1() throws Exception { + public static void test(String loaderName, String expectedErrorMessage) throws Exception { String[] classNames = {"test.Foo"}; - ClassLoader l = new PreemptingClassLoader(null, classNames, false); + ClassLoader l = new PreemptingClassLoader(loaderName, classNames, false); l.loadClass("test.Foo"); try { l.loadClass("test.Foo").newInstance(); throw new RuntimeException("Expected LinkageError exception not thrown"); } catch (LinkageError e) { String errorMsg = e.getMessage(); - if (!errorMsg.equals(expectedErrorMessage1)) { - System.out.println("Expected: " + expectedErrorMessage1 + "\n" + + if (!errorMsg.equals(expectedErrorMessage)) { + System.out.println("Expected: " + expectedErrorMessage + "\n" + "but got: " + errorMsg); throw new RuntimeException("Wrong LinkageError exception thrown: " + errorMsg); } @@ -65,34 +71,9 @@ } } - // Check that all names have external formatting ('.' and not '/' in package names). - // Check for name and parent of class loader. - static String expectedErrorMessage2 = - "loader \"DuplicateLE_Test_Loader\" (instance of PreemptingClassLoader, parent: \"app\" " + - "jdk.internal.loader.ClassLoaders$AppClassLoader) attempted duplicate class definition for test.Foo."; - - // Same as test1, but ClassLoader has a name. - public static void test2() throws Exception { - String[] classNames = {"test.Foo"}; - ClassLoader l = new PreemptingClassLoader("DuplicateLE_Test_Loader", classNames, false); - l.loadClass("test.Foo"); - try { - l.loadClass("test.Foo"); - throw new RuntimeException("Expected LinkageError exception not thrown"); - } catch (LinkageError e) { - String errorMsg = e.getMessage(); - if (!errorMsg.equals(expectedErrorMessage2)) { - System.out.println("Expected: " + expectedErrorMessage2 + "\n" + - "but got: " + errorMsg); - throw new RuntimeException("Wrong LinkageError exception thrown: " + errorMsg); - } - System.out.println("Passed with message: " + errorMsg); - } - } - public static void main(String args[]) throws Exception { - test1(); - test2(); + test(null, expectedErrorMessage1); + test("DuplicateLE_Test_Loader", expectedErrorMessage2); } } --- old/test/hotspot/jtreg/runtime/LoaderConstraints/itableICCE/I.java 2018-04-12 12:05:14.355974000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/itableICCE/I.java 2018-04-12 12:05:13.881936000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/itableICCE/Task.java 2018-04-12 12:05:15.559073000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/itableICCE/Task.java 2018-04-12 12:05:15.073033000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/itableICCE/Test.java 2018-04-12 12:05:16.797173000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/itableICCE/Test.java 2018-04-12 12:05:16.308134000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/itableLdrConstraint/I.java 2018-04-12 12:05:18.025274000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/itableLdrConstraint/I.java 2018-04-12 12:05:17.552236000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/itableLdrConstraint/Task.java 2018-04-12 12:05:19.285377000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/itableLdrConstraint/Task.java 2018-04-12 12:05:18.805430000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/itableLdrConstraint/Test.java 2018-04-12 12:05:20.513478000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/itableLdrConstraint/Test.java 2018-04-12 12:05:20.036438000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -44,32 +44,6 @@ "parent: \"platform\" jdk.internal.loader.ClassLoaders$PlatformClassLoader) " + "of the selected method's type, test.J have different Class objects for the type test.Foo used in the signature"; - // Test that the error message is correct when a loader constraint error is - // detected during itable creation. - // - // In this test, during itable creation for class C, method "m()LFoo;" for - // C's super interface I has a different class Foo than the selected method's - // type super interface J. The selected method is not an overpass method nor - // otherwise excluded from loader constraint checking. So, a LinkageError - // exception should be thrown because the loader constraint check will fail. - public static void test1() 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(); - throw new RuntimeException("Expected LinkageError exception not thrown"); - } catch (LinkageError e) { - String errorMsg = e.getMessage(); - if (!errorMsg.equals(expectedErrorMessage1)) { - System.out.println("Expected: " + expectedErrorMessage1 + "\n" + - "but got: " + errorMsg); - throw new RuntimeException("Wrong LinkageError exception thrown: " + errorMsg); - } - System.out.println("Passed with message: " + errorMsg); - } - } - static String expectedErrorMessage2 = "loader constraint violation in interface itable initialization for class test.C: " + "when selecting method test.I.m()Ltest/Foo; the class loader \"ItableLdrCnstrnt_Test_Loader\" " + @@ -79,19 +53,26 @@ "parent: \"platform\" jdk.internal.loader.ClassLoaders$PlatformClassLoader) " + "of the selected method's type, test.J have different Class objects for the type test.Foo used in the signature"; - // Same as test1, but ClassLoader has a name. - public static void test2() throws Exception { + // Test that the error message is correct when a loader constraint error is + // detected during itable creation. + // + // In this test, during itable creation for class C, method "m()LFoo;" for + // C's super interface I has a different class Foo than the selected method's + // type super interface J. The selected method is not an overpass method nor + // otherwise excluded from loader constraint checking. So, a LinkageError + // exception should be thrown because the loader constraint check will fail. + public static void test(String loaderName, String expectedErrorMessage) throws Exception { Class c = test.Foo.class; // Forces standard class loader to load Foo. - String[] classNames = {"test.Task", "test.Foo", "test.C", "test.I"}; - ClassLoader l = new PreemptingClassLoader("ItableLdrCnstrnt_Test_Loader", classNames); + String[] classNames = {"test.Task", "test.Foo", "test.C", "test.I"}; + ClassLoader l = new PreemptingClassLoader(loaderName, classNames); Runnable r = (Runnable) l.loadClass("test.Task").newInstance(); try { r.run(); throw new RuntimeException("Expected LinkageError exception not thrown"); } catch (LinkageError e) { String errorMsg = e.getMessage(); - if (!errorMsg.equals(expectedErrorMessage2)) { - System.out.println("Expected: " + expectedErrorMessage2 + "\n" + + if (!errorMsg.equals(expectedErrorMessage)) { + System.out.println("Expected: " + expectedErrorMessage + "\n" + "but got: " + errorMsg); throw new RuntimeException("Wrong LinkageError exception thrown: " + errorMsg); } @@ -100,8 +81,7 @@ } public static void main(String... args) throws Exception { - test1(); - test2(); + test(null, expectedErrorMessage1); + test("ItableLdrCnstrnt_Test_Loader", expectedErrorMessage2); } - } --- old/test/hotspot/jtreg/runtime/LoaderConstraints/vtableAME/I.java 2018-04-12 12:05:21.748579000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/vtableAME/I.java 2018-04-12 12:05:21.262541000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/vtableAME/Task.java 2018-04-12 12:05:22.952685000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/vtableAME/Task.java 2018-04-12 12:05:22.485640000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/vtableAME/Test.java 2018-04-12 12:05:24.181778000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/vtableAME/Test.java 2018-04-12 12:05:23.700743000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/vtableLdrConstraint/I.java 2018-04-12 12:05:25.378877000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/vtableLdrConstraint/I.java 2018-04-12 12:05:24.902837000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/vtableLdrConstraint/Task.java 2018-04-12 12:05:26.621981000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/vtableLdrConstraint/Task.java 2018-04-12 12:05:26.146951000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 --- old/test/hotspot/jtreg/runtime/LoaderConstraints/vtableLdrConstraint/Test.java 2018-04-12 12:05:27.804074000 +0200 +++ new/test/hotspot/jtreg/runtime/LoaderConstraints/vtableLdrConstraint/Test.java 2018-04-12 12:05:27.331038000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -43,31 +43,6 @@ "parent: \"platform\" jdk.internal.loader.ClassLoaders$PlatformClassLoader) for its super type test.J " + "have different Class objects for the type test.Foo used in the signature"; - // Test that the error message is correct when a loader constraint error is - // detected during vtable creation. - // - // In this test, during vtable creation for class Task, method "Task.m()LFoo;" - // overrides "J.m()LFoo;". But, Task's class Foo and super type J's class Foo - // are different. So, a LinkageError exception should be thrown because the - // loader constraint check will fail. - public static void test1() throws Exception { - Class c = test.Foo.class; // forces standard class loader to load Foo - ClassLoader l = new PreemptingClassLoader("test.Task", "test.Foo", "test.I"); - l.loadClass("test.Foo"); - try { - l.loadClass("test.Task").newInstance(); - throw new RuntimeException("Expected LinkageError exception not thrown"); - } catch (LinkageError e) { - String errorMsg = e.getMessage(); - if (!errorMsg.equals(expectedErrorMessage1)) { - System.out.println("Expected: " + expectedErrorMessage1 + "\n" + - "but got: " + errorMsg); - throw new RuntimeException("Wrong LinkageError exception thrown: " + errorMsg); - } - System.out.println("Passed with message: " + errorMsg); - } - } - static String expectedErrorMessage2 = "loader constraint violation for class test.Task: when selecting overriding method test.Task.m()Ltest/Foo; " + "the class loader \"VtableLdrCnstrnt_Test_Loader\" (instance of PreemptingClassLoader, " + @@ -76,29 +51,35 @@ "parent: \"platform\" jdk.internal.loader.ClassLoaders$PlatformClassLoader) for its super type test.J " + "have different Class objects for the type test.Foo used in the signature"; - // Same as test1, but ClassLoader has a name. - public static void test2() throws Exception { + // Test that the error message is correct when a loader constraint error is + // detected during vtable creation. + // + // In this test, during vtable creation for class Task, method "Task.m()LFoo;" + // overrides "J.m()LFoo;". But, Task's class Foo and super type J's class Foo + // are different. So, a LinkageError exception should be thrown because the + // loader constraint check will fail. + public static void test(String loaderName, String expectedErrorMessage) throws Exception { Class c = test.Foo.class; // Forces standard class loader to load Foo. String[] classNames = {"test.Task", "test.Foo", "test.I"}; - ClassLoader l = new PreemptingClassLoader("VtableLdrCnstrnt_Test_Loader", classNames); + ClassLoader l = new PreemptingClassLoader(loaderName, classNames); l.loadClass("test.Foo"); try { l.loadClass("test.Task").newInstance(); throw new RuntimeException("Expected LinkageError exception not thrown"); } catch (LinkageError e) { String errorMsg = e.getMessage(); - if (!errorMsg.equals(expectedErrorMessage2)) { - System.out.println("Expected: " + expectedErrorMessage2 + "\n" + + if (!errorMsg.equals(expectedErrorMessage)) { + System.out.println("Expected: " + expectedErrorMessage + "\n" + "but got: " + errorMsg); throw new RuntimeException("Wrong LinkageError exception thrown: " + errorMsg); } System.out.println("Passed with message: " + errorMsg); } } - + public static void main(String args[]) throws Exception { - test1(); - test2(); + test(null, expectedErrorMessage1); + test("VtableLdrCnstrnt_Test_Loader", expectedErrorMessage2); } }