8194141: Remove JDK9Wrappers
authorjjg
Thu, 04 Jan 2018 10:14:50 -0800
changeset 48433 04d8d293e458
parent 48432 db09f53aba91
child 48434 2d250a0174a6
8194141: Remove JDK9Wrappers Reviewed-by: erikj, alanb
make/autoconf/spec.gmk.in
src/java.base/share/classes/module-info.java
src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java
src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties
src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java
src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java
test/langtools/tools/jdeps/listdeps/ListModuleDeps.java
--- a/make/autoconf/spec.gmk.in	Wed Jan 03 15:16:46 2018 -0800
+++ b/make/autoconf/spec.gmk.in	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -585,6 +585,8 @@
 INTERIM_LANGTOOLS_MODULES := $(addsuffix .interim, $(INTERIM_LANGTOOLS_BASE_MODULES))
 INTERIM_LANGTOOLS_ADD_EXPORTS := \
     --add-exports java.base/sun.reflect.annotation=jdk.compiler.interim \
+    --add-exports java.base/jdk.internal.jmod=jdk.compiler.interim \
+    --add-exports java.base/jdk.internal.misc=jdk.compiler.interim \
     #
 INTERIM_LANGTOOLS_MODULES_COMMA := $(strip $(subst $(SPACE),$(COMMA),$(strip \
     $(INTERIM_LANGTOOLS_MODULES))))
--- a/src/java.base/share/classes/module-info.java	Wed Jan 03 15:16:46 2018 -0800
+++ b/src/java.base/share/classes/module-info.java	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -142,7 +142,7 @@
         java.instrument,
         java.logging;
     exports jdk.internal.jmod to
-        jdk.compiler,   // reflective dependency
+        jdk.compiler,
         jdk.jlink;
     exports jdk.internal.logger to
         java.logging;
@@ -172,7 +172,7 @@
         java.xml,
         jdk.attach,
         jdk.charsets,
-        jdk.compiler,   // reflective dependency
+        jdk.compiler,
         jdk.incubator.httpclient,
         jdk.jdeps,
         jdk.jlink,
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Jan 03 15:16:46 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.module.Configuration;
+import java.lang.module.ModuleFinder;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -77,11 +79,6 @@
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.JDK9Wrappers.Configuration;
-import com.sun.tools.javac.util.JDK9Wrappers.Layer;
-import com.sun.tools.javac.util.JDK9Wrappers.ModuleFinder;
-import com.sun.tools.javac.util.JDK9Wrappers.Module;
-import com.sun.tools.javac.util.JDK9Wrappers.ServiceLoaderHelper;
 
 import static java.nio.file.FileVisitOption.FOLLOW_LINKS;
 
@@ -980,14 +977,14 @@
     public <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) throws IOException {
         nullCheck(location);
         nullCheck(service);
-        Module.getModule(getClass()).addUses(service);
+        getClass().getModule().addUses(service);
         if (location.isModuleOrientedLocation()) {
             Collection<Path> paths = locations.getLocation(location);
             ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[paths.size()]));
-            Layer bootLayer = Layer.boot();
+            ModuleLayer bootLayer = ModuleLayer.boot();
             Configuration cf = bootLayer.configuration().resolveAndBind(ModuleFinder.of(), finder, Collections.emptySet());
-            Layer layer = bootLayer.defineModulesWithOneLoader(cf, ClassLoader.getSystemClassLoader());
-            return ServiceLoaderHelper.load(layer, service);
+            ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, ClassLoader.getSystemClassLoader());
+            return ServiceLoader.load(layer, service);
         } else {
             return ServiceLoader.load(service, getClassLoader(location));
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Wed Jan 03 15:16:46 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,6 +77,8 @@
 import javax.tools.StandardJavaFileManager.PathFactory;
 import javax.tools.StandardLocation;
 
+import jdk.internal.jmod.JmodFile;
+
 import com.sun.tools.javac.code.Lint;
 import com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.main.Option;
@@ -84,7 +86,6 @@
 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.JDK9Wrappers;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.jvm.ModuleNameReader;
@@ -1451,7 +1452,7 @@
                 if (p.getFileName().toString().endsWith(".jmod")) {
                     try {
                         // check if the JMOD file is valid
-                        JDK9Wrappers.JmodFile.checkMagic(p);
+                        JmodFile.checkMagic(p);
 
                         // No JMOD file system.  Use JarFileSystem to
                         // workaround for now
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Wed Jan 03 15:16:46 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 
 import java.io.FileWriter;
 import java.io.PrintWriter;
+import java.lang.module.ModuleDescriptor;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -47,6 +48,8 @@
 
 import javax.lang.model.SourceVersion;
 
+import jdk.internal.misc.VM;
+
 import com.sun.tools.doclint.DocLint;
 import com.sun.tools.javac.code.Lint;
 import com.sun.tools.javac.code.Lint.LintCategory;
@@ -57,7 +60,6 @@
 import com.sun.tools.javac.platform.PlatformProvider;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.util.Assert;
-import com.sun.tools.javac.util.JDK9Wrappers;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Log.PrefixKind;
 import com.sun.tools.javac.util.Log.WriterKind;
@@ -650,21 +652,11 @@
             if (arg.isEmpty()) {
                 throw helper.newInvalidValueException("err.no.value.for.option", option);
             } else {
+                // use official parser if available
                 try {
-                    Class.forName(JDK9Wrappers.ModuleDescriptor.Version.CLASSNAME);
-                    // use official parser if available
-                    try {
-                        JDK9Wrappers.ModuleDescriptor.Version.parse(arg);
-                    } catch (IllegalArgumentException e) {
-                        throw helper.newInvalidValueException("err.bad.value.for.option", option, arg);
-                    }
-                } catch (ClassNotFoundException ex) {
-                    // fall-back to simplistic rules when running on older platform
-                    if (!(arg.charAt(0) >= '0' && arg.charAt(0) <= '9') ||
-                        arg.endsWith("-") ||
-                        arg.endsWith("+")) {
-                        throw helper.newInvalidValueException("err.bad.value.for.option", option, arg);
-                    }
+                    ModuleDescriptor.Version.parse(arg);
+                } catch (IllegalArgumentException e) {
+                    throw helper.newInvalidValueException("err.bad.value.for.option", option, arg);
                 }
             }
             super.process(helper, option, arg);
@@ -717,41 +709,36 @@
             HIDDEN, BASIC) {
         @Override
         public void process(OptionHelper helper, String option) throws InvalidValueException {
-            try {
-                Class.forName(JDK9Wrappers.VMHelper.CLASSNAME);
-                String[] runtimeArgs = JDK9Wrappers.VMHelper.getRuntimeArguments();
-                for (String arg : runtimeArgs) {
-                    // Handle any supported runtime options; ignore all others.
-                    // The runtime arguments always use the single token form, e.g. "--name=value".
-                    for (Option o : getSupportedRuntimeOptions()) {
-                        if (o.matches(arg)) {
-                            switch (o) {
-                                case ADD_MODULES:
-                                    int eq = arg.indexOf('=');
-                                    Assert.check(eq > 0, () -> ("invalid runtime option:" + arg));
-                                    // --add-modules=ALL-DEFAULT is not supported at compile-time
-                                    // so remove it from list, and only process the rest
-                                    // if the set is non-empty.
-                                    // Note that --add-modules=ALL-DEFAULT is automatically added
-                                    // by the standard javac launcher.
-                                    String mods = Arrays.stream(arg.substring(eq + 1).split(","))
-                                            .filter(s -> !s.isEmpty() && !s.equals("ALL-DEFAULT"))
-                                            .collect(Collectors.joining(","));
-                                    if (!mods.isEmpty()) {
-                                        String updatedArg = arg.substring(0, eq + 1) + mods;
-                                        o.handleOption(helper, updatedArg, Collections.emptyIterator());
-                                    }
-                                    break;
-                                default:
-                                    o.handleOption(helper, arg, Collections.emptyIterator());
-                                    break;
-                            }
-                            break;
+            String[] runtimeArgs = VM.getRuntimeArguments();
+            for (String arg : runtimeArgs) {
+                // Handle any supported runtime options; ignore all others.
+                // The runtime arguments always use the single token form, e.g. "--name=value".
+                for (Option o : getSupportedRuntimeOptions()) {
+                    if (o.matches(arg)) {
+                        switch (o) {
+                            case ADD_MODULES:
+                                int eq = arg.indexOf('=');
+                                Assert.check(eq > 0, () -> ("invalid runtime option:" + arg));
+                                // --add-modules=ALL-DEFAULT is not supported at compile-time
+                                // so remove it from list, and only process the rest
+                                // if the set is non-empty.
+                                // Note that --add-modules=ALL-DEFAULT is automatically added
+                                // by the standard javac launcher.
+                                String mods = Arrays.stream(arg.substring(eq + 1).split(","))
+                                        .filter(s -> !s.isEmpty() && !s.equals("ALL-DEFAULT"))
+                                        .collect(Collectors.joining(","));
+                                if (!mods.isEmpty()) {
+                                    String updatedArg = arg.substring(0, eq + 1) + mods;
+                                    o.handleOption(helper, updatedArg, Collections.emptyIterator());
+                                }
+                                break;
+                            default:
+                                o.handleOption(helper, arg, Collections.emptyIterator());
+                                break;
                         }
+                        break;
                     }
                 }
-            } catch (ClassNotFoundException | SecurityException e) {
-                throw helper.newInvalidValueException("err.cannot.access.runtime.env");
             }
         }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jan 03 15:16:46 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,6 @@
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.Iterators;
 import com.sun.tools.javac.util.JCDiagnostic;
-import com.sun.tools.javac.util.JDK9Wrappers.Module;
 import com.sun.tools.javac.util.JavacMessages;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Log;
@@ -267,7 +266,7 @@
                     : fileManager.getClassLoader(CLASS_PATH);
 
                 if (options.isSet("accessInternalAPI"))
-                    ModuleHelper.addExports(Module.getModule(getClass()), Module.getUnnamedModule(processorClassLoader));
+                    ModuleHelper.addExports(getClass().getModule(), processorClassLoader.getUnnamedModule());
 
                 if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
                     compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jan 03 15:16:46 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -374,8 +374,6 @@
     not a directory: {0}
 javac.err.file.not.file=\
     not a file: {0}
-javac.err.cannot.access.runtime.env=\
-    cannot access runtime environment
 javac.err.two.class.loaders.1=\
     javac is split between multiple class loaders: check your configuration
 javac.err.two.class.loaders.2=\
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Wed Jan 03 15:16:46 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,460 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.util;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.ServiceLoader;
-
-/**
- *  This class provides wrappers for classes and methods that are new in JDK 9, and which are not
- *  available on older versions of the platform on which javac may be compiled and run.
- *  In future releases, when javac is always compiled on JDK 9 or later, the use of these wrappers
- *  can be replaced by use of the real underlying classes.
- *
- *  <p>Wrapper classes provide a subset of the API of the wrapped classes, as needed for use
- *  in javac. Wrapper objects contain an {@code Object} reference to the underlying runtime object,
- *  and {@code Class} and {@code Method} objects for obtaining or using such instances via
- *  runtime reflection.  The {@code Class} and {@code Method} objects are set up on a per-class
- *  basis, by an {@code init} method, which is called from static methods on the wrapper class,
- *  or in the constructor, when instances are created.
- *  <p>
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- */
-public class JDK9Wrappers {
-
-    /**
-     * Helper class for new method in java.util.ServiceLoader.
-     */
-    public static final class ServiceLoaderHelper {
-        @SuppressWarnings("unchecked")
-        public static <S> ServiceLoader<S> load(Layer layer, Class<S> service) {
-            try {
-                init();
-                Object result = loadMethod.invoke(null, layer.theRealLayer, service);
-                return (ServiceLoader<S>)result;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        // -----------------------------------------------------------------------------------------
-
-        private static Method loadMethod = null;
-
-        private static void init() {
-            if (loadMethod == null) {
-                try {
-                    Class<?> layerClass = Layer.layerClass;
-                    loadMethod = ServiceLoader.class.getDeclaredMethod("load", layerClass, Class.class);
-                } catch (NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-        }
-    }
-
-    /**
-     * Wrapper class for java.lang.module.ModuleDescriptor and ModuleDescriptor.Version.
-     */
-    public static class ModuleDescriptor {
-        public static class Version {
-            public static final String CLASSNAME = "java.lang.module.ModuleDescriptor$Version";
-            private final Object theRealVersion;
-
-            private Version(Object version) {
-                this.theRealVersion = version;
-            }
-
-            public static Version parse(String v) {
-                try {
-                    init();
-                    Object result = parseMethod.invoke(null, v);
-                    Version version = new Version(result);
-                    return version;
-                } catch (InvocationTargetException ex) {
-                    if (ex.getCause() instanceof IllegalArgumentException) {
-                        throw (IllegalArgumentException) ex.getCause();
-                    } else {
-                        throw new Abort(ex);
-                    }
-                } catch (IllegalAccessException | IllegalArgumentException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-
-            @Override
-            public String toString() {
-                return theRealVersion.toString();
-            }
-
-            // -----------------------------------------------------------------------------------------
-
-            private static Class<?> versionClass = null;
-            private static Method parseMethod = null;
-
-            private static void init() {
-                if (versionClass == null) {
-                    try {
-                        versionClass = Class.forName(CLASSNAME, false, null);
-                        parseMethod = versionClass.getDeclaredMethod("parse", String.class);
-                    } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
-                        throw new Abort(ex);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Wrapper class for java.lang.module.ModuleFinder.
-     */
-    public static class ModuleFinder {
-        private final Object theRealModuleFinder;
-
-        private ModuleFinder(Object moduleFinder) {
-            this.theRealModuleFinder = moduleFinder;
-            init();
-        }
-
-        public static ModuleFinder of(Path... dirs) {
-            try {
-                init();
-                Object result = ofMethod.invoke(null, (Object)dirs);
-                ModuleFinder mFinder = new ModuleFinder(result);
-                return mFinder;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        // -----------------------------------------------------------------------------------------
-
-        private static Class<?> moduleFinderClass = null;
-        private static Method ofMethod;
-
-        static final Class<?> getModuleFinderClass() {
-            init();
-            return moduleFinderClass;
-        }
-
-        private static void init() {
-            if (moduleFinderClass == null) {
-                try {
-                    moduleFinderClass = Class.forName("java.lang.module.ModuleFinder", false, null);
-                    ofMethod = moduleFinderClass.getDeclaredMethod("of", Path[].class);
-                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-        }
-    }
-
-    /**
-     * Wrapper class for java.lang.Module. To materialize a handle use the static factory
-     * methods Module#getModule(Class<?>) or Module#getUnnamedModule(ClassLoader).
-     */
-    public static class Module {
-
-        private final Object theRealModule;
-
-        private Module(Object module) {
-            this.theRealModule = module;
-            init();
-        }
-
-        public static Module getModule(Class<?> clazz) {
-            try {
-                init();
-                Object result = getModuleMethod.invoke(clazz, new Object[0]);
-                return new Module(result);
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        public static Module getUnnamedModule(ClassLoader classLoader) {
-            try {
-                init();
-                Object result = getUnnamedModuleMethod.invoke(classLoader, new Object[0]);
-                return new Module(result);
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        public Module addExports(String pn, Module other) {
-            try {
-                addExportsMethod.invoke(theRealModule, new Object[] { pn, other.theRealModule});
-            } catch (IllegalAccessException | InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-            return this;
-        }
-
-        public Module addUses(Class<?> st) {
-            try {
-                addUsesMethod.invoke(theRealModule, new Object[] { st });
-            } catch (IllegalAccessException | InvocationTargetException ex) {
-                throw new Abort(ex);
-            }
-            return this;
-        }
-
-        // -----------------------------------------------------------------------------------------
-        // on java.lang.Module
-        private static Method addExportsMethod = null;
-        // on java.lang.Module
-        private static Method addUsesMethod = null;
-        // on java.lang.Class
-        private static Method getModuleMethod;
-        // on java.lang.ClassLoader
-        private static Method getUnnamedModuleMethod;
-
-        private static void init() {
-            if (addExportsMethod == null) {
-                try {
-                    Class<?> moduleClass = Class.forName("java.lang.Module", false, null);
-                    addUsesMethod = moduleClass.getDeclaredMethod("addUses", new Class<?>[] { Class.class });
-                    addExportsMethod = moduleClass.getDeclaredMethod("addExports",
-                                                        new Class<?>[] { String.class, moduleClass });
-                    getModuleMethod = Class.class.getDeclaredMethod("getModule", new Class<?>[0]);
-                    getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule", new Class<?>[0]);
-                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-        }
-    }
-
-    /**
-     * Wrapper class for java.lang.module.Configuration.
-     */
-    public static final class Configuration {
-        private final Object theRealConfiguration;
-
-        private Configuration(Object configuration) {
-            this.theRealConfiguration = configuration;
-            init();
-        }
-
-        public Configuration resolveAndBind(
-                ModuleFinder beforeFinder,
-                ModuleFinder afterFinder,
-                Collection<String> roots) {
-            try {
-                Object result = resolveAndBindMethod.invoke(theRealConfiguration,
-                                    beforeFinder.theRealModuleFinder,
-                                    afterFinder.theRealModuleFinder,
-                                    roots
-                                );
-                Configuration configuration = new Configuration(result);
-                return configuration;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        // -----------------------------------------------------------------------------------------
-
-        private static Class<?> configurationClass = null;
-        private static Method resolveAndBindMethod;
-
-        static final Class<?> getConfigurationClass() {
-            init();
-            return configurationClass;
-        }
-
-        private static void init() {
-            if (configurationClass == null) {
-                try {
-                    configurationClass = Class.forName("java.lang.module.Configuration", false, null);
-                    Class<?> moduleFinderInterface = ModuleFinder.getModuleFinderClass();
-                    resolveAndBindMethod = configurationClass.getDeclaredMethod("resolveAndBind",
-                                moduleFinderInterface,
-                                moduleFinderInterface,
-                                Collection.class
-                    );
-                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-        }
-    }
-
-    /**
-     * Wrapper class for java.lang.ModuleLayer.
-     */
-    public static final class Layer {
-        private final Object theRealLayer;
-
-        private Layer(Object layer) {
-            this.theRealLayer = layer;
-        }
-
-        public static Layer boot() {
-            try {
-                init();
-                Object result = bootMethod.invoke(null);
-                Layer layer = new Layer(result);
-                return layer;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        public Configuration configuration() {
-            try {
-                Object result = configurationMethod.invoke(theRealLayer);
-                Configuration configuration = new Configuration(result);
-                return configuration;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        public Layer defineModulesWithOneLoader(Configuration configuration, ClassLoader parentClassLoader) {
-            try {
-                Object result = defineModulesWithOneLoaderMethod.invoke(
-                        theRealLayer, configuration.theRealConfiguration, parentClassLoader);
-                Layer layer = new Layer(result);
-                return layer;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        // -----------------------------------------------------------------------------------------
-
-        private static Class<?> layerClass = null;
-        private static Method bootMethod;
-        private static Method defineModulesWithOneLoaderMethod;
-        private static Method configurationMethod;
-
-        private static void init() {
-            if (layerClass == null) {
-                try {
-                    layerClass = Class.forName("java.lang.ModuleLayer", false, null);
-                    bootMethod = layerClass.getDeclaredMethod("boot");
-                    defineModulesWithOneLoaderMethod = layerClass.getDeclaredMethod("defineModulesWithOneLoader",
-                                Configuration.getConfigurationClass(),
-                                ClassLoader.class);
-                    configurationMethod = layerClass.getDeclaredMethod("configuration");
-                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-        }
-    }
-
-
-    /**
-     * Helper class for new method in jdk.internal.misc.VM.
-     */
-    public static final class VMHelper {
-        public static final String CLASSNAME = "jdk.internal.misc.VM";
-
-        @SuppressWarnings("unchecked")
-        public static String[] getRuntimeArguments() {
-            try {
-                init();
-                Object result = getRuntimeArgumentsMethod.invoke(null);
-                return (String[])result;
-            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
-                    | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        // -----------------------------------------------------------------------------------------
-
-        private static Class<?> vmClass = null;
-        private static Method getRuntimeArgumentsMethod = null;
-
-        private static void init() {
-            if (vmClass == null) {
-                try {
-                    vmClass = Class.forName(CLASSNAME, false, null);
-                    getRuntimeArgumentsMethod = vmClass.getDeclaredMethod("getRuntimeArguments");
-                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-        }
-    }
-
-    /**
-     * Helper class for new method in jdk.internal.jmod.JmodFile
-     */
-    public static final class JmodFile {
-        public static final String JMOD_FILE_CLASSNAME = "jdk.internal.jmod.JmodFile";
-
-        public static void checkMagic(Path file) throws IOException {
-            try {
-                init();
-                checkMagicMethod.invoke(null, file);
-            } catch (InvocationTargetException ex) {
-                if (ex.getCause() instanceof IOException) {
-                    throw IOException.class.cast(ex.getCause());
-                }
-                throw new Abort(ex);
-            } catch (IllegalAccessException | IllegalArgumentException | SecurityException ex) {
-                throw new Abort(ex);
-            }
-        }
-
-        // -----------------------------------------------------------------------------------------
-
-        private static Class<?> jmodFileClass = null;
-        private static Method checkMagicMethod = null;
-
-        private static void init() {
-            if (jmodFileClass == null) {
-                try {
-                    jmodFileClass = Class.forName(JMOD_FILE_CLASSNAME, false, null);
-                    checkMagicMethod = jmodFileClass.getDeclaredMethod("checkMagic", Path.class);
-                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
-                    throw new Abort(ex);
-                }
-            }
-        }
-    }
-}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java	Wed Jan 03 15:16:46 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
 
 package com.sun.tools.javac.util;
 
-import com.sun.tools.javac.util.JDK9Wrappers.Module;
-
 public class ModuleHelper {
 
     private static final String[] javacInternalPackages = new String[] {
--- a/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java	Wed Jan 03 15:16:46 2018 -0800
+++ b/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java	Thu Jan 04 10:14:50 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,8 @@
     public Object[][] jdkModules() {
         return new Object[][]{
             {"jdk.compiler", new String[]{
+                                "java.base/jdk.internal.jmod",
+                                "java.base/jdk.internal.misc",
                                 "java.base/sun.reflect.annotation",
                                 "java.compiler",
                              }