Merge
authorlana
Fri, 12 Jan 2018 05:07:01 +0000
changeset 48518 e2c862ab9601
parent 48516 7d286141598c (diff)
parent 48517 94dd6cda265d (current diff)
child 48519 482ede6c4936
Merge
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Fri Jan 12 05:06:07 2018 +0000
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Fri Jan 12 05:07:01 2018 +0000
@@ -2734,43 +2734,58 @@
   return method_type;
 }
 
+Handle SystemDictionary::find_field_handle_type(Symbol* signature,
+                                                Klass* accessing_klass,
+                                                TRAPS) {
+  Handle empty;
+  ResourceMark rm(THREAD);
+  SignatureStream ss(signature, /*is_method=*/ false);
+  if (!ss.is_done()) {
+    Handle class_loader, protection_domain;
+    if (accessing_klass != NULL) {
+      class_loader      = Handle(THREAD, accessing_klass->class_loader());
+      protection_domain = Handle(THREAD, accessing_klass->protection_domain());
+    }
+    oop mirror = ss.as_java_mirror(class_loader, protection_domain, SignatureStream::NCDFError, CHECK_(empty));
+    ss.next();
+    if (ss.is_done()) {
+      return Handle(THREAD, mirror);
+    }
+  }
+  return empty;
+}
+
 // Ask Java code to find or construct a method handle constant.
 Handle SystemDictionary::link_method_handle_constant(Klass* caller,
                                                      int ref_kind, //e.g., JVM_REF_invokeVirtual
                                                      Klass* callee,
-                                                     Symbol* name_sym,
+                                                     Symbol* name,
                                                      Symbol* signature,
                                                      TRAPS) {
   Handle empty;
-  Handle name = java_lang_String::create_from_symbol(name_sym, CHECK_(empty));
-  Handle type;
-  if (signature->utf8_length() > 0 && signature->byte_at(0) == '(') {
-    type = find_method_handle_type(signature, caller, CHECK_(empty));
-  } else if (caller == NULL) {
-    // This should not happen.  JDK code should take care of that.
+  if (caller == NULL) {
     THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad MH constant", empty);
-  } else {
-    ResourceMark rm(THREAD);
-    SignatureStream ss(signature, false);
-    if (!ss.is_done()) {
-      oop mirror = ss.as_java_mirror(Handle(THREAD, caller->class_loader()),
-                                     Handle(THREAD, caller->protection_domain()),
-                                     SignatureStream::NCDFError, CHECK_(empty));
-      type = Handle(THREAD, mirror);
-      ss.next();
-      if (!ss.is_done())  type = Handle();  // error!
-    }
   }
-  if (type.is_null()) {
-    THROW_MSG_(vmSymbols::java_lang_LinkageError(), "bad signature", empty);
-  }
+  Handle name_str      = java_lang_String::create_from_symbol(name,      CHECK_(empty));
+  Handle signature_str = java_lang_String::create_from_symbol(signature, CHECK_(empty));
+
+  // Put symbolic info from the MH constant into freshly created MemberName and resolve it.
+  Handle mname = MemberName_klass()->allocate_instance_handle(CHECK_(empty));
+  java_lang_invoke_MemberName::set_clazz(mname(), callee->java_mirror());
+  java_lang_invoke_MemberName::set_name (mname(), name_str());
+  java_lang_invoke_MemberName::set_type (mname(), signature_str());
+  java_lang_invoke_MemberName::set_flags(mname(), MethodHandles::ref_kind_to_flags(ref_kind));
+  MethodHandles::resolve_MemberName(mname, caller, CHECK_(empty));
+
+  // After method/field resolution succeeded, it's safe to resolve MH signature as well.
+  Handle type = MethodHandles::resolve_MemberName_type(mname, caller, CHECK_(empty));
 
   // call java.lang.invoke.MethodHandleNatives::linkMethodHandleConstant(Class caller, int refKind, Class callee, String name, Object type) -> MethodHandle
   JavaCallArguments args;
   args.push_oop(Handle(THREAD, caller->java_mirror()));  // the referring class
   args.push_int(ref_kind);
   args.push_oop(Handle(THREAD, callee->java_mirror()));  // the target class
-  args.push_oop(name);
+  args.push_oop(name_str);
   args.push_oop(type);
   JavaValue result(T_OBJECT);
   JavaCalls::call_static(&result,
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Fri Jan 12 05:06:07 2018 +0000
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Fri Jan 12 05:07:01 2018 +0000
@@ -532,6 +532,11 @@
                                            Klass* accessing_klass,
                                            TRAPS);
 
+  // find a java.lang.Class object for a given signature
+  static Handle    find_field_handle_type(Symbol* signature,
+                                          Klass* accessing_klass,
+                                          TRAPS);
+
   // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry
   static Handle    link_method_handle_constant(Klass* caller,
                                                int ref_kind, //e.g., JVM_REF_invokeVirtual
--- a/src/hotspot/share/prims/methodHandles.cpp	Fri Jan 12 05:06:07 2018 +0000
+++ b/src/hotspot/share/prims/methodHandles.cpp	Fri Jan 12 05:07:01 2018 +0000
@@ -122,6 +122,48 @@
   ALL_KINDS      = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE
 };
 
+int MethodHandles::ref_kind_to_flags(int ref_kind) {
+  assert(ref_kind_is_valid(ref_kind), "%d", ref_kind);
+  int flags = (ref_kind << REFERENCE_KIND_SHIFT);
+  if (ref_kind_is_field(ref_kind)) {
+    flags |= IS_FIELD;
+  } else if (ref_kind_is_method(ref_kind)) {
+    flags |= IS_METHOD;
+  } else if (ref_kind == JVM_REF_newInvokeSpecial) {
+    flags |= IS_CONSTRUCTOR;
+  }
+  return flags;
+}
+
+Handle MethodHandles::resolve_MemberName_type(Handle mname, Klass* caller, TRAPS) {
+  Handle empty;
+  Handle type(THREAD, java_lang_invoke_MemberName::type(mname()));
+  if (!java_lang_String::is_instance_inlined(type())) {
+    return type; // already resolved
+  }
+  Symbol* signature = java_lang_String::as_symbol_or_null(type());
+  if (signature == NULL) {
+    return empty;  // no such signature exists in the VM
+  }
+  Handle resolved;
+  int flags = java_lang_invoke_MemberName::flags(mname());
+  switch (flags & ALL_KINDS) {
+    case IS_METHOD:
+    case IS_CONSTRUCTOR:
+      resolved = SystemDictionary::find_method_handle_type(signature, caller, CHECK_(empty));
+      break;
+    case IS_FIELD:
+      resolved = SystemDictionary::find_field_handle_type(signature, caller, CHECK_(empty));
+      break;
+    default:
+      THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized MemberName format", empty);
+  }
+  if (resolved.is_null()) {
+    THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad MemberName type", empty);
+  }
+  return resolved;
+}
+
 oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) {
   // This method is used from java.lang.invoke.MemberName constructors.
   // It fills in the new MemberName from a java.lang.reflect.Member.
--- a/src/hotspot/share/prims/methodHandles.hpp	Fri Jan 12 05:06:07 2018 +0000
+++ b/src/hotspot/share/prims/methodHandles.hpp	Fri Jan 12 05:07:01 2018 +0000
@@ -70,6 +70,8 @@
   static int find_MemberNames(Klass* k, Symbol* name, Symbol* sig,
                               int mflags, Klass* caller,
                               int skip, objArrayHandle results, TRAPS);
+  static Handle resolve_MemberName_type(Handle mname, Klass* caller, TRAPS);
+
   // bit values for suppress argument to expand_MemberName:
   enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 };
 
@@ -191,6 +193,8 @@
             ref_kind == JVM_REF_invokeInterface);
   }
 
+  static int ref_kind_to_flags(int ref_kind);
+
 #include CPU_HEADER(methodHandles)
 
   // Tracing
--- a/src/java.base/share/classes/java/lang/invoke/MemberName.java	Fri Jan 12 05:06:07 2018 +0000
+++ b/src/java.base/share/classes/java/lang/invoke/MemberName.java	Fri Jan 12 05:07:01 2018 +0000
@@ -900,9 +900,9 @@
             buf.append(getName(clazz));
             buf.append('.');
         }
-        String name = getName();
+        String name = this.name; // avoid expanding from VM
         buf.append(name == null ? "*" : name);
-        Object type = getType();
+        Object type = this.type; // avoid expanding from VM
         if (!isInvocable()) {
             buf.append('/');
             buf.append(type == null ? "*" : getName(type));
--- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java	Fri Jan 12 05:06:07 2018 +0000
+++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java	Fri Jan 12 05:07:01 2018 +0000
@@ -212,6 +212,13 @@
         }
     },
 
+    ADD_OPENS("--add-opens", true) {
+        @Override
+        public void process(Helper helper, String arg) throws InvalidValueException {
+            Option.ADD_OPENS.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
     // ----- doclet options -----
 
     DOCLET("-doclet", true), // handled in setDocletInvoker
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Fri Jan 12 05:06:07 2018 +0000
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Fri Jan 12 05:07:01 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -189,6 +189,13 @@
         }
     },
 
+    ADD_OPENS("--add-opens", HIDDEN, true) {
+        @Override
+        public void process(Helper helper, String arg) throws InvalidValueException {
+            Option.ADD_OPENS.process(helper.getOptionHelper(), primaryName, arg);
+        }
+    },
+
     // ----- doclet options -----
 
     DOCLET("-doclet", STANDARD, true), // handled in setDocletInvoker
--- a/test/hotspot/jtreg/runtime/appcds/TestCommon.java	Fri Jan 12 05:06:07 2018 +0000
+++ b/test/hotspot/jtreg/runtime/appcds/TestCommon.java	Fri Jan 12 05:07:01 2018 +0000
@@ -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
@@ -23,6 +23,7 @@
  */
 
 import jdk.test.lib.Utils;
+import jdk.test.lib.BuildHelper;
 import jdk.test.lib.JDKToolFinder;
 import jdk.test.lib.Platform;
 import jdk.test.lib.cds.CDSOptions;
@@ -107,6 +108,19 @@
         return createArchive(opts);
     }
 
+    // If you use -XX:+UseAppCDS or -XX:-UseAppCDS in your JVM command-line, call this method
+    // to wrap the arguments. On commercial builds, -XX:+UnlockCommercialFeatures will be
+    // prepended to the command-line. See JDK-8193664.
+    public static String[] makeCommandLineForAppCDS(String... args) throws Exception {
+        if (BuildHelper.isCommercialBuild()) {
+            String[] newArgs = new String[args.length + 1];
+            newArgs[0] = "-XX:+UnlockCommercialFeatures";
+            System.arraycopy(args, 0, newArgs, 1, args.length);
+            return newArgs;
+        } else {
+            return args;
+        }
+    }
 
     // Create AppCDS archive using appcds options
     public static OutputAnalyzer createArchive(AppCDSOptions opts)
@@ -139,7 +153,7 @@
         for (String s : opts.suffix) cmd.add(s);
 
         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
         return executeAndLog(pb, "dump");
     }
 
@@ -166,7 +180,7 @@
         for (String s : opts.suffix) cmd.add(s);
 
         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
         return executeAndLog(pb, "exec");
     }
 
--- a/test/hotspot/jtreg/runtime/appcds/UseAppCDS.java	Fri Jan 12 05:06:07 2018 +0000
+++ b/test/hotspot/jtreg/runtime/appcds/UseAppCDS.java	Fri Jan 12 05:07:01 2018 +0000
@@ -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
@@ -122,14 +122,14 @@
 
     static void dumpLoadedClasses(boolean useAppCDS, String[] expectedClasses,
                                   String[] unexpectedClasses) throws Exception {
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            true,
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+          TestCommon.makeCommandLineForAppCDS(
             "-XX:DumpLoadedClassList=" + CLASSLIST_FILE,
             "-cp",
             TESTJAR,
             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
             TESTNAME,
-            TEST_OUT);
+            TEST_OUT));
 
         OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes")
             .shouldHaveExitValue(0).shouldContain(TEST_OUT);
@@ -152,8 +152,8 @@
 
     static void dumpArchive(boolean useAppCDS, String[] expectedClasses,
                             String[] unexpectedClasses) throws Exception {
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            true,
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+          TestCommon.makeCommandLineForAppCDS(
             useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
                         "-XX:+UnlockDiagnosticVMOptions",
             "-cp",
@@ -162,7 +162,7 @@
             "-XX:SharedClassListFile=" + CLASSLIST_FILE,
             "-XX:SharedArchiveFile=" + ARCHIVE_FILE,
             "-Xlog:cds",
-            "-Xshare:dump");
+            "-Xshare:dump"));
 
         OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive")
             .shouldHaveExitValue(0);
@@ -179,8 +179,8 @@
 
     static void useArchive(boolean useAppCDS, String[] expectedClasses,
                            String[] unexpectedClasses) throws Exception {
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            true,
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+          TestCommon.makeCommandLineForAppCDS(
             useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
                         "-XX:+UnlockDiagnosticVMOptions",
             "-cp",
@@ -190,7 +190,7 @@
             "-verbose:class",
             "-Xshare:on",
             TESTNAME,
-            TEST_OUT );
+            TEST_OUT));
 
         OutputAnalyzer output = TestCommon.executeAndLog(pb, "use-archive");
         if (CDSTestUtils.isUnableToMap(output))
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsBasic.java	Fri Jan 12 05:06:07 2018 +0000
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsBasic.java	Fri Jan 12 05:07:01 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, 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
@@ -50,6 +50,7 @@
             TestCommon.getSourceFile("SharedStringsBasic.txt").toString();
 
         ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true,
+          TestCommon.makeCommandLineForAppCDS(
             "-XX:+UseAppCDS",
             "-XX:+UseCompressedOops",
             "-XX:+UseG1GC",
@@ -57,13 +58,14 @@
             "-XX:SharedArchiveConfigFile=" + sharedArchiveConfigFile,
             "-XX:SharedArchiveFile=./SharedStringsBasic.jsa",
             "-Xshare:dump",
-            "-Xlog:cds,cds+hashtables");
+            "-Xlog:cds,cds+hashtables"));
 
         TestCommon.executeAndLog(dumpPb, "dump")
             .shouldContain("Shared string table stats")
             .shouldHaveExitValue(0);
 
         ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true,
+          TestCommon.makeCommandLineForAppCDS(
             "-XX:+UseAppCDS",
             "-XX:+UseCompressedOops",
             "-XX:+UseG1GC",
@@ -71,7 +73,7 @@
             "-XX:SharedArchiveFile=./SharedStringsBasic.jsa",
             "-Xshare:auto",
             "-showversion",
-            "HelloString");
+            "HelloString"));
 
         TestCommon.executeAndLog(runPb, "run").shouldHaveExitValue(0);
     }
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/SysDictCrash.java	Fri Jan 12 05:06:07 2018 +0000
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/SysDictCrash.java	Fri Jan 12 05:07:01 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, 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
@@ -42,21 +42,23 @@
         // SharedBaseAddress=0 puts the archive at a very high address on solaris,
         // which provokes the crash.
         ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true,
+          TestCommon.makeCommandLineForAppCDS(
             "-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5",
             "-XX:+UseAppCDS",
             "-cp", ".",
             "-XX:SharedBaseAddress=0", "-XX:SharedArchiveFile=./SysDictCrash.jsa",
             "-Xshare:dump",
-            "-showversion", "-Xlog:cds,cds+hashtables");
+            "-showversion", "-Xlog:cds,cds+hashtables"));
 
         TestCommon.checkDump(TestCommon.executeAndLog(dumpPb, "dump"));
 
         ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true,
+          TestCommon.makeCommandLineForAppCDS(
             "-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5",
             "-XX:+UseAppCDS",
             "-XX:SharedArchiveFile=./SysDictCrash.jsa",
             "-Xshare:on",
-            "-version");
+            "-version"));
 
         TestCommon.checkExec(TestCommon.executeAndLog(runPb, "exec"));
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/invokedynamic/MethodHandleConstantHelper.jasm	Fri Jan 12 05:07:01 2018 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017, 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.
+ *
+ * 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 runtime/invokedynamic;
+
+super public class MethodHandleConstantHelper
+    version 51:0
+{
+
+static Field "testField":"I";
+
+static Method "testMethod":"()V"
+{
+    return;
+}
+
+public static Method "testMethodSignatureResolutionFailure":"()V"
+    stack 1 locals 1
+{
+          ldc MethodHandle REF_invokeStatic:
+                  MethodHandleConstantHelper.testMethod:
+                  "(LNotExist;)V";
+
+          return;
+}
+
+public static Method "testFieldSignatureResolutionFailure":"()V"
+    stack 1 locals 1
+{
+          ldc MethodHandle REF_getField:
+                  MethodHandleConstantHelper.testField:
+                  "LNotExist;";
+
+          return;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/invokedynamic/MethodHandleConstantTest.java	Fri Jan 12 05:07:01 2018 +0000
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, 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.
+ *
+ * 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.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8188145
+ * @compile MethodHandleConstantHelper.jasm
+ * @run main runtime.invokedynamic.MethodHandleConstantTest
+ */
+package runtime.invokedynamic;
+
+import java.lang.invoke.*;
+
+public class MethodHandleConstantTest {
+    static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
+    static final MethodType TEST_MT = MethodType.methodType(void.class);
+    static final Class<?> TEST_CLASS;
+
+    static {
+       try {
+          TEST_CLASS = Class.forName("runtime.invokedynamic.MethodHandleConstantHelper");
+       } catch (ClassNotFoundException e) {
+           throw new Error(e);
+       }
+    }
+
+    static void test(String testName, Class<? extends Throwable> expectedError) {
+        System.out.print(testName);
+        try {
+            LOOKUP.findStatic(TEST_CLASS, testName, TEST_MT).invokeExact();
+        } catch (Throwable e) {
+            if (expectedError.isInstance(e)) {
+                // expected
+            } else {
+                e.printStackTrace();
+                String msg = String.format("%s: wrong exception: %s, but %s expected",
+                                           testName, e.getClass().getName(), expectedError.getName());
+                throw new AssertionError(msg);
+            }
+        }
+        System.out.println(": PASSED");
+    }
+
+    public static void main(String[] args) throws Throwable {
+        test("testMethodSignatureResolutionFailure", NoSuchMethodError.class);
+        test("testFieldSignatureResolutionFailure",  NoSuchFieldError.class);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/tool/AddOpensTest.java	Fri Jan 12 05:07:01 2018 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8181878
+ * @summary javadoc should support/ignore --add-opens
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ * @modules jdk.javadoc/jdk.javadoc.internal.api
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @library /tools/lib
+ * @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox
+ * @run main AddOpensTest
+ */
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.JavadocTask;
+import toolbox.Task;
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class AddOpensTest extends TestRunner {
+    public static void main(String... args) throws Exception {
+        AddOpensTest t = new AddOpensTest();
+        t.runTests();
+    }
+
+    private final ToolBox tb = new ToolBox();
+    private final Path src = Paths.get("src");
+    private final Path api = Paths.get("api");
+
+    AddOpensTest() throws Exception {
+        super(System.err);
+        init();
+    }
+
+    void init() throws IOException {
+        tb.writeJavaFiles(src, "public class C { }");
+    }
+
+    @Test
+    public void testEncoding() {
+        Task.Result result = new JavadocTask(tb, Task.Mode.EXEC)
+                .options("-d", api.toString(),
+                        "--add-opens", "some.module")
+                .files(src.resolve("C.java"))
+                .run(Task.Expect.SUCCESS)
+                .writeAll();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javadoc/AddOpensTest.java	Fri Jan 12 05:07:01 2018 +0000
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8181878
+ * @summary javadoc should support/ignore --add-opens
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ * @modules jdk.javadoc/jdk.javadoc.internal.api
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @library /tools/lib /tools/javadoc/lib
+ * @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox ToyDoclet
+ * @run main AddOpensTest
+ */
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.JavadocTask;
+import toolbox.Task;
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class AddOpensTest extends TestRunner {
+    public static void main(String... args) throws Exception {
+        AddOpensTest t = new AddOpensTest();
+        t.runTests();
+    }
+
+    private final ToolBox tb = new ToolBox();
+    private final Path src = Paths.get("src");
+    private final Path api = Paths.get("api");
+
+    AddOpensTest() throws Exception {
+        super(System.err);
+        init();
+    }
+
+    void init() throws IOException {
+        tb.writeJavaFiles(src, "public class C { }");
+    }
+
+    @Test
+    public void testEncoding() {
+        Task.Result result = new JavadocTask(tb, Task.Mode.EXEC)
+                .options("-docletpath", System.getProperty("test.class.path"),
+                        "-doclet", "ToyDoclet",
+                        "--add-opens", "some.module")
+                .files(src.resolve("C.java"))
+                .run(Task.Expect.SUCCESS)
+                .writeAll();
+    }
+}
+