static {
    final Class<?> myClass = ModuleGraphManipulator.class;
    MY_MODULE = myClass.getModule();
    final String myName = myClass.getName();
    MY_PKG_NAME = myName.substring(0, myName.lastIndexOf('.'));

    // nashorn's module is the module of the class loader of current class
    final Module nashornModule = myClass.getClassLoader().getClass().getModule();

    // Make sure this class was not loaded by Nashorn's own loader!
    if (MY_MODULE == nashornModule) {
      throw new IllegalStateException(myClass + " loaded by wrong loader!");
    }

    // From this module add a qualified export to nashorn module
    MY_MODULE.addExports(MY_PKG_NAME, nashornModule);
  }
 private static void addExport(final Module otherMod) {
   MY_MODULE.addExports(MY_PKG_NAME, otherMod);
 }