src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/ExportingClassLoader.java
changeset 58299 6df94ce3ab2f
parent 55509 d58442b8abc1
child 58679 9c3209ff7550
equal deleted inserted replaced
58298:0152ad7b38b8 58299:6df94ce3ab2f
     1 /*
     1 /*
     2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2019, 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.
    22  */
    22  */
    23 
    23 
    24 
    24 
    25 package org.graalvm.compiler.test;
    25 package org.graalvm.compiler.test;
    26 
    26 
    27 import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
       
    28 
       
    29 /**
    27 /**
    30  * A class loader that exports all packages in the module defining the class loader to all classes
    28  * A class loader that exports all packages in the module defining the class loader to all classes
    31  * in the unnamed module associated with the loader.
    29  * in the unnamed module associated with the loader.
    32  */
    30  */
    33 public class ExportingClassLoader extends ClassLoader {
    31 public class ExportingClassLoader extends ClassLoader {
    34     public ExportingClassLoader() {
    32     public ExportingClassLoader() {
    35         if (JavaVersionUtil.JAVA_SPEC > 8) {
    33         ModuleSupport.exportAllPackagesTo(getClass(), this);
    36             JLModule.fromClass(getClass()).exportAllPackagesTo(JLModule.getUnnamedModuleFor(this));
       
    37         }
       
    38     }
    34     }
    39 
    35 
    40     public ExportingClassLoader(ClassLoader parent) {
    36     public ExportingClassLoader(ClassLoader parent) {
    41         super(parent);
    37         super(parent);
    42         if (JavaVersionUtil.JAVA_SPEC > 8) {
    38         ModuleSupport.exportAllPackagesTo(getClass(), this);
    43             JLModule.fromClass(getClass()).exportAllPackagesTo(JLModule.getUnnamedModuleFor(this));
       
    44         }
       
    45     }
    39     }
    46 }
    40 }