jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java
changeset 44617 112ddd6c13b2
parent 44616 70f34b975a86
parent 44614 a34001e206f9
child 44620 f9082fe892ac
equal deleted inserted replaced
44616:70f34b975a86 44617:112ddd6c13b2
     1 /*
       
     2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package jdk.internal.misc;
       
    27 
       
    28 import java.lang.module.ModuleDescriptor;
       
    29 import java.lang.reflect.Layer;
       
    30 import java.lang.reflect.Module;
       
    31 import java.net.URI;
       
    32 import java.util.stream.Stream;
       
    33 
       
    34 import jdk.internal.module.ServicesCatalog;
       
    35 
       
    36 /**
       
    37  * Provides access to non-public methods in java.lang.reflect.Module
       
    38  */
       
    39 
       
    40 public interface JavaLangReflectModuleAccess {
       
    41 
       
    42     /**
       
    43      * Defines the unnamed module for the given class loader.
       
    44      */
       
    45     Module defineUnnamedModule(ClassLoader loader);
       
    46 
       
    47     /**
       
    48      * Defines a new module to the Java virtual machine. The module
       
    49      * is defined to the given class loader.
       
    50      *
       
    51      * The URI is for information purposes only, it can be {@code null}.
       
    52      */
       
    53     Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri);
       
    54 
       
    55     /**
       
    56      * Updates the readability so that module m1 reads m2. The new read edge
       
    57      * does not result in a strong reference to m2 (m2 can be GC'ed).
       
    58      *
       
    59      * This method is the same as m1.addReads(m2) but without a permission check.
       
    60      */
       
    61     void addReads(Module m1, Module m2);
       
    62 
       
    63     /**
       
    64      * Updates module m to read all unnamed modules.
       
    65      */
       
    66     void addReadsAllUnnamed(Module m);
       
    67 
       
    68     /**
       
    69      * Update module m to export a package to all modules.
       
    70      */
       
    71     void addExports(Module m, String pn);
       
    72 
       
    73     /**
       
    74      * Updates module m1 to export a package to module m2. The export does
       
    75      * not result in a strong reference to m2 (m2 can be GC'ed).
       
    76      */
       
    77     void addExports(Module m1, String pkg, Module m2);
       
    78 
       
    79     /**
       
    80      * Updates a module m to export a package to all unnamed modules.
       
    81      */
       
    82     void addExportsToAllUnnamed(Module m, String pkg);
       
    83 
       
    84     /**
       
    85      * Updates a module m to open a package to all modules.
       
    86      */
       
    87     void addOpens(Module m, String pkg);
       
    88 
       
    89     /**
       
    90      * Updates module m1 to open a package to module m2. Opening the
       
    91      * package does not result in a strong reference to m2 (m2 can be GC'ed).
       
    92      */
       
    93     void addOpens(Module m1, String pkg, Module m2);
       
    94 
       
    95     /**
       
    96      * Updates a module m to open a package to all unnamed modules.
       
    97      */
       
    98     void addOpensToAllUnnamed(Module m, String pkg);
       
    99 
       
   100     /**
       
   101      * Updates a module m to use a service.
       
   102      */
       
   103     void addUses(Module m, Class<?> service);
       
   104 
       
   105     /**
       
   106      * Returns the ServicesCatalog for the given Layer.
       
   107      */
       
   108     ServicesCatalog getServicesCatalog(Layer layer);
       
   109 
       
   110     /**
       
   111      * Returns an ordered stream of layers. The first element is is the
       
   112      * given layer, the remaining elements are its parents, in DFS order.
       
   113      */
       
   114     Stream<Layer> layers(Layer layer);
       
   115 
       
   116     /**
       
   117      * Returns a stream of the layers that have modules defined to the
       
   118      * given class loader.
       
   119      */
       
   120     Stream<Layer> layers(ClassLoader loader);
       
   121 }