test/hotspot/jtreg/runtime/appcds/test-classes/ForNameTest.java
changeset 49335 3271310a6af7
parent 48138 78b2ecdd3c4b
equal deleted inserted replaced
49334:aefee96e2b90 49335:3271310a6af7
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    25 import sun.hotspot.WhiteBox;
    25 import sun.hotspot.WhiteBox;
    26 
    26 
    27 public class ForNameTest {
    27 public class ForNameTest {
    28     public static void main(String[] args) throws Throwable {
    28     public static void main(String[] args) throws Throwable {
    29         // Hello is on the bootclasspath. The defining classloader is
    29         // Hello is on the bootclasspath. The defining classloader is
    30         // the NULL classloader. See AppCDSClassLoaderTest.
    30         // the NULL classloader. See ../ClassLoaderTest.java
    31         Class c = Class.forName("Hello");
    31         Class c = Class.forName("Hello");
    32         ClassLoader cl = c.getClassLoader();
    32         ClassLoader cl = c.getClassLoader();
    33         if (cl != null) {
    33         if (cl != null) {
    34             throw new RuntimeException(
    34             throw new RuntimeException(
    35                 "Test Failed. Wrong classloader is used. Expect the NULL classloader.");
    35                 "Test Failed. Wrong classloader is used. Expect the NULL classloader.");
    36         }
    36         }
    37 
    37 
    38         WhiteBox wb = WhiteBox.getWhiteBox();
    38         WhiteBox wb = WhiteBox.getWhiteBox();
    39         if (!wb.isSharedClass(c)) {
    39         if (wb.isSharedClass(c)) {
    40             System.out.println("As expected, Hello.class is not in shared space.");
    40             System.out.println("As expected, Hello.class is in shared space.");
    41         } else {
    41         } else {
    42             throw new java.lang.RuntimeException("Hello.class shouldn't be in shared space.");
    42             throw new java.lang.RuntimeException("Hello.class must be in shared space.");
    43         }
    43         }
    44     }
    44     }
    45 }
    45 }