1 package jdk.internal.access.code;
 2 
 3 /**
 4  * Intializes a module layer containing the incubating module jdk.incubator.code so that
 5  * it can be used by the jdk.compiler module for compiling reflectable code.
 6  * See use in com.sun.tools.javac.main.JavaCompiler of the jdk.compiler module.
 7  */
 8 public class CodeModuleLayerInit {
 9     public static void initCodeModuleLayer(ModuleLayer layer) {
10         Module codeReflectionModule = layer.findModule("jdk.incubator.code").get();
11         Module jdkCompilerModule = CodeModuleLayerInit.class.getModule();
12         // We need to add exports all java.base packages so that the jdk.incubator.code module can use them
13         for (String packageName : jdkCompilerModule.getPackages()) {
14             jdkCompilerModule.addExports(packageName, codeReflectionModule);
15         }
16     }
17 }