changeset 13573:f2e4f1de7ace nestmates

8186763: Nestmate update for lazy validation and virtual invocation
author dholmes
date Wed, 30 Aug 2017 02:37:37 -0400
parents 002f847a0202
children e583bb68cacb
files src/share/vm/classfile/stackMapFrame.hpp src/share/vm/classfile/verifier.cpp src/share/vm/interpreter/linkResolver.cpp src/share/vm/oops/instanceKlass.cpp src/share/vm/oops/instanceKlass.hpp test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java test/compiler/jvmci/events/JvmciShutdownEventTest.java test/runtime/Nestmates/membership/ArrayNestTop.jcod test/runtime/Nestmates/membership/MissingNestTop.jcod test/runtime/Nestmates/membership/NestTop.jcod test/runtime/Nestmates/membership/NestTop_NestMember.jcod test/runtime/Nestmates/membership/NotAMember.jcod test/runtime/Nestmates/membership/NotAMember2.java test/runtime/Nestmates/membership/NotAMember2.jcod test/runtime/Nestmates/membership/PackagedNestTop.java test/runtime/Nestmates/membership/PackagedNestTop.jcod test/runtime/Nestmates/membership/PackagedNestTop2.java test/runtime/Nestmates/membership/PackagedNestTop2Member.jcod test/runtime/Nestmates/membership/TestNestmateMembership.java test/runtime/Nestmates/privateConstructors/ExternalSub.jcod test/runtime/Nestmates/privateConstructors/ExternalSuper.jcod test/runtime/Nestmates/privateConstructors/TestConstructorHierarchy.java test/runtime/Nestmates/privateMethods/ExternalSub.jcod test/runtime/Nestmates/privateMethods/ExternalSuper.jcod test/runtime/Nestmates/privateMethods/MissingMethod.jcod test/runtime/Nestmates/privateMethods/MissingMethodWithSuper.jcod test/runtime/Nestmates/privateMethods/MissingNestTop.jcod test/runtime/Nestmates/privateMethods/TestInvoke.java test/runtime/Nestmates/privateMethods/TestInvokeErrors.java test/runtime/Nestmates/privateMethods/TestInvokeHierarchy.java test/runtime/Nestmates/privateMethods/TestInvokeSpecial.java test/runtime/Nestmates/privateMethods/TestInvokeSpecialErrors.java test/runtime/Nestmates/privateMethods/TestInvokeSpecialHierarchy.java
diffstat 34 files changed, 1732 insertions(+), 1058 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/stackMapFrame.hpp	Fri Aug 11 11:32:17 2017 +0100
+++ b/src/share/vm/classfile/stackMapFrame.hpp	Wed Aug 30 02:37:37 2017 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -215,17 +215,6 @@
     _stack[_stack_size++] = type2;
   }
 
-  // Return the top type on stack without popping.
-  inline VerificationType peek_stack(TRAPS) {
-    if (_stack_size <= 0) {
-      verifier()->verify_error(
-          ErrorContext::stack_underflow(_offset, this),
-          "Operand stack underflow");
-      return VerificationType::bogus_type();
-    }
-    return _stack[_stack_size - 1];
-  }
-
   // Pop and return the top type on stack without verifying.
   inline VerificationType pop_stack(TRAPS) {
     if (_stack_size <= 0) {
--- a/src/share/vm/classfile/verifier.cpp	Fri Aug 11 11:32:17 2017 +0100
+++ b/src/share/vm/classfile/verifier.cpp	Wed Aug 30 02:37:37 2017 -0400
@@ -2826,7 +2826,7 @@
                              !is_same_or_direct_interface(current_class()->host_klass(),
                                                           host_klass_type, ref_class_type));
       }
-      
+
       if ((!subtype  || have_imr_indirect) && !nestmates_checked) {
         // invokespecial may still be legitimate if current class and reference class
         // are nestmates. But in that case we also have to check that the method being
--- a/src/share/vm/interpreter/linkResolver.cpp	Fri Aug 11 11:32:17 2017 +0100
+++ b/src/share/vm/interpreter/linkResolver.cpp	Wed Aug 30 02:37:37 2017 -0400
@@ -730,33 +730,9 @@
     }
   }
 
-#if 0
-  // Experiment: disallow invokevirtual of private methods
-  if (code == Bytecodes::_invokevirtual && !resolved_method.is_null() && resolved_method->is_private()) {
-    ResourceMark rm(THREAD);
-    char buf[200];
-
-    KlassHandle current_klass = link_info.current_klass();
-    jio_snprintf(buf, sizeof(buf), "private method requires invokespecial, not invokevirtual: method %s, caller-class:%s",
-                 Method::name_and_sig_as_C_string(resolved_klass,
-                                                  resolved_method->name(),
-                                                  resolved_method->signature()),
-                                                  (current_klass == NULL ? "<NULL>" : current_klass->internal_name()));
-     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
-  }
-#endif
-
   // 5. method lookup failed
   if (resolved_method.is_null()) {
     ResourceMark rm(THREAD);
-    if (UseNewCode) {
-      static int count = 0;
-      tty->print_cr("Missing method: %s", Method::name_and_sig_as_C_string(resolved_klass,
-                                                                           link_info.name(),
-                                                                           link_info.signature()));
-      if (count++ > 0)
-        guarantee(false, "Boom");
-    }
     THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(),
                     Method::name_and_sig_as_C_string(resolved_klass,
                                                      link_info.name(),
@@ -764,7 +740,7 @@
                     nested_exception, NULL);
   }
 
-  // 5. access checks, access checking may be turned off when calling from within the VM.
+  // 6. access checks, access checking may be turned off when calling from within the VM.
   Klass* current_klass = link_info.current_klass();
   if (link_info.check_access()) {
     assert(current_klass != NULL , "current_klass should not be null");
@@ -780,6 +756,26 @@
     check_method_loader_constraints(link_info, resolved_method, "method", CHECK_NULL);
   }
 
+  // For private method invocation we should only find the method in the resolved class.
+  // If that is not the case then we have a found a supertype method that we have nestmate
+  // access to.
+  // FIXME: the "ignoring xxx" part is for debugging only
+  if (resolved_method->is_private() && resolved_method->method_holder() != resolved_klass) {
+    ResourceMark rm(THREAD);
+   DEBUG_ONLY(bool is_nestmate = InstanceKlass::cast(link_info.current_klass())->has_nestmate_access_to(InstanceKlass::cast(resolved_klass), THREAD);)
+    assert(is_nestmate, "was only expecting nestmates to get here!");
+    Exceptions::fthrow(
+      THREAD_AND_LOCATION,
+      vmSymbols::java_lang_NoSuchMethodError(),
+      "%s: method %s%s not found (ignoring %s)",
+      resolved_klass->external_name(),
+      resolved_method->name()->as_C_string(),
+      resolved_method->signature()->as_C_string(),
+      resolved_method->method_holder()->external_name()
+    );
+    return NULL;
+  }
+
   return resolved_method;
 }
 
@@ -1111,7 +1107,7 @@
 
   // Invokespecial is called for multiple special reasons:
   // <init>
-  // local, or nestmate, private method invocation, for classes and interfaces
+  // local private method invocation, for classes and interfaces
   // superclass.method, which can also resolve to a default method
   // and the selected method is recalculated relative to the direct superclass
   // superinterface.method, which explicitly does not check shadowing
@@ -1139,26 +1135,6 @@
     return NULL;
   }
 
-  // For private method invocation we should only find the method in the resolved class.
-  // If that is not the case then we have a found a supertype method that we have nestmate
-  // access to.
-  // FIXME: the "ignoring xxx" part is for debugging only
-  if (resolved_method->is_private() &&
-      resolved_method->method_holder() != resolved_klass) {
-    ResourceMark rm(THREAD);
-    assert(InstanceKlass::cast(link_info.current_klass())->has_nestmate_access_to(InstanceKlass::cast(resolved_klass), THREAD), "was only expecting nestmates here!");
-    Exceptions::fthrow(
-      THREAD_AND_LOCATION,
-      vmSymbols::java_lang_NoSuchMethodError(),
-      "%s: method %s%s not found (ignoring %s)",
-      resolved_klass->external_name(),
-      resolved_method->name()->as_C_string(),
-      resolved_method->signature()->as_C_string(),
-      resolved_method->method_holder()->external_name()
-    );
-    return NULL;
-  }
-
   // check that invokespecial's interface method reference is in a direct superinterface,
   // unless we are dealing with nestmates.
   Klass* current_klass = link_info.current_klass();
@@ -1199,6 +1175,26 @@
     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
+  // For private method invocation we should only find the method in the resolved class.
+  // If that is not the case then we have a found a supertype method that we have nestmate
+  // access to.
+  // FIXME: the "ignoring xxx" part is for debugging only
+  if (resolved_method->is_private() && resolved_method->method_holder() != resolved_klass) {
+    ResourceMark rm(THREAD);
+    DEBUG_ONLY(bool is_nestmate = InstanceKlass::cast(link_info.current_klass())->has_nestmate_access_to(InstanceKlass::cast(resolved_klass), THREAD);)
+    assert(is_nestmate, "was only expecting nestmates here!");
+    Exceptions::fthrow(
+      THREAD_AND_LOCATION,
+      vmSymbols::java_lang_NoSuchMethodError(),
+      "%s: method %s%s not found (ignoring %s)",
+      resolved_klass->external_name(),
+      resolved_method->name()->as_C_string(),
+      resolved_method->signature()->as_C_string(),
+      resolved_method->method_holder()->external_name()
+    );
+    return NULL;
+  }
+
   if (log_develop_is_enabled(Trace, itables)) {
     trace_method_resolution("invokespecial resolved method: caller-class:",
                             current_klass, resolved_klass, resolved_method, true);
@@ -1253,7 +1249,7 @@
     }
 
     // Check that the class of objectref (the receiver) is the current class or interface,
-    // or a subtype of the current class or interface (the sender), or else they are 
+    // or a subtype of the current class or interface (the sender), or else they are
     // nestmates, otherwise invokespecial throws IllegalAccessError.
     // The verifier checks that the sender is a subtype of the class in the I/MR operand.
     // The verifier also checks that the receiver is a subtype of the sender, if the sender is
--- a/src/share/vm/oops/instanceKlass.cpp	Fri Aug 11 11:32:17 2017 +0100
+++ b/src/share/vm/oops/instanceKlass.cpp	Wed Aug 30 02:37:37 2017 -0400
@@ -186,10 +186,10 @@
   return false;
 }
 
-// Return nest top class, resolving and saving it if needed
+// Return nest top class, resolving, validating and saving it if needed
 InstanceKlass* InstanceKlass::nest_top(TRAPS) {
-  InstanceKlass* ret_nest_top = _nest_top;
-  if (ret_nest_top == NULL) {
+  InstanceKlass* nest_top_k = _nest_top;
+  if (nest_top_k == NULL) {
     // need to resolve and save our nest top class. This could be attempted
     // concurrently but as the result is idempotent and we don't use the class
     // then we do not need any synchronization beyond what is implicitly used
@@ -201,14 +201,15 @@
                                     this->name()->as_C_string(),
                                     _constants->klass_name_at(_nest_top_index)->as_C_string());
       }
-      
+
       Klass* k = _constants->klass_at(_nest_top_index, CHECK_NULL);
-      
+
       if (log_is_enabled(Trace, class, nestmates)) {
         ResourceMark rm(THREAD);
         log_trace(class, nestmates)("Resolved nest top of %s to %s",
                                     this->name()->as_C_string(), k->name()->as_C_string());
       }
+
       if (!k->is_instance_klass()) {
         ResourceMark rm(THREAD);
         Exceptions::fthrow(
@@ -220,7 +221,34 @@
                            );
         return NULL;
       }
-      ret_nest_top = InstanceKlass::cast(k);
+
+      nest_top_k = InstanceKlass::cast(k);
+
+      bool is_member = nest_top_k->has_nest_member(this, CHECK_NULL);
+      if (!is_member) {
+        // this_k and nest_top disagree about nest membership
+        ResourceMark rm(THREAD);
+        Exceptions::fthrow(
+                           THREAD_AND_LOCATION,
+                           vmSymbols::java_lang_IncompatibleClassChangeError(),
+                           "Type %s is not a nest member of %s",
+                           this->external_name(),
+                           nest_top_k->external_name()
+                           );
+        return NULL;
+      }
+
+      if (!is_same_class_package(nest_top_k)) {
+        ResourceMark rm(THREAD);
+        Exceptions::fthrow(
+                           THREAD_AND_LOCATION,
+                           vmSymbols::java_lang_IncompatibleClassChangeError(),
+                           "Class %s is in a different package to its nest top class %s",
+                           this->external_name(),
+                           nest_top_k->external_name()
+                           );
+        return NULL;
+      }
     }
     else {
       if (log_is_enabled(Trace, class, nestmates)) {
@@ -228,32 +256,23 @@
         log_trace(class, nestmates)("Class %s is not part of a nest: setting nest top to self",
                                     this->name()->as_C_string());
       }
-      
-      ret_nest_top = const_cast<InstanceKlass*>(this);
+      nest_top_k = const_cast<InstanceKlass*>(this);
     }
   }
-  return ret_nest_top;
+  // save resolved nest-top value
+  _nest_top = nest_top_k;
+
+  return nest_top_k;
 }
- 
+
 // check if 'this' and k are nestmates (same nest_top), or k is our nest_top,
 // or we are k's nest_top - all of which is covered by comparing the two
 // resolved_nest_tops
 bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {
 
-  // nest-top should have been resolved and validated before any access checks occur
-
-  if (_nest_top == NULL) {
-    ResourceMark rm(THREAD);
-    log_trace(class, nestmates)("Nest-top of %s not resolved when checking access to %s",
-                                this->name()->as_C_string(), 
-                                k->name()->as_C_string());
-  }
-  assert(_nest_top != NULL, "_nest_top should be resolved before access checks occur!");
-
+  // If not actually nestmates, then both nest-top classes may have to loaded
+  // and the nest membership of each class validated.
   InstanceKlass* cur_top = nest_top(CHECK_false);
-
-  // k may not be linked yet so it's nest-top may need to be loaded
-  // if it is not in our nest
   Klass* k_nest_top = k->nest_top(CHECK_false);
 
   bool access = (cur_top == k_nest_top);
@@ -261,7 +280,7 @@
   if (log_is_enabled(Trace, class, nestmates)) {
     ResourceMark rm(THREAD);
     log_trace(class, nestmates)("Class %s does %shave nestmate accesss to %s",
-                                this->name()->as_C_string(), 
+                                this->name()->as_C_string(),
                                 access ? "" : "NOT ",
                                 k->name()->as_C_string());
   }
@@ -269,41 +288,6 @@
   return access;
 }
 
-// Resolves nest-top, if needed, and verifies we are actually a member of its nest
-void InstanceKlass::validate_nest_top(TRAPS) {
-  InstanceKlass* nest_top_k = nest_top(CHECK);
-  if (nest_top_k != this) { // real nest-top to check
-    bool is_member = nest_top_k->has_nest_member(this, CHECK);
-    if (!is_member) {
-      // this_k and nest_top disagree about nest membership
-      ResourceMark rm(THREAD);
-      Exceptions::fthrow(
-        THREAD_AND_LOCATION,
-        vmSymbols::java_lang_IncompatibleClassChangeError(),
-        "Type %s is not a nest member of %s",
-        this->external_name(),
-        nest_top_k->external_name()
-      );
-      return;
-    }
-
-    if (!is_same_class_package(nest_top_k)) {
-      ResourceMark rm(THREAD);
-      Exceptions::fthrow(
-        THREAD_AND_LOCATION,
-        vmSymbols::java_lang_IncompatibleClassChangeError(),
-        "Class %s is in a different package to its nest top class %s",
-        this->external_name(),
-        nest_top_k->external_name()
-      );
-      return;
-    }
-  }
-  // save resolved nest-top value
-  _nest_top = nest_top_k;
-}
-
-
 InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) {
   const int size = InstanceKlass::size(parser.vtable_size(),
                                        parser.itable_size(),
@@ -383,7 +367,7 @@
   _static_field_size(parser.static_field_size()),
   _nonstatic_oop_map_size(nonstatic_oop_map_size(parser.total_oop_map_count())),
   _itable_len(parser.itable_size()),
-  _reference_type(parser.reference_type()), 
+  _reference_type(parser.reference_type()),
   _nest_members(NULL),
   _nest_top_index(0),
   _nest_top(NULL) {
@@ -742,8 +726,6 @@
     return true;
   }
 
-  validate_nest_top(CHECK_false);
-
   // trace only the link time for this klass that includes
   // the verification time
   PerfClassTraceTime vmtimer(ClassLoader::perf_class_link_time(),
--- a/src/share/vm/oops/instanceKlass.hpp	Fri Aug 11 11:32:17 2017 +0100
+++ b/src/share/vm/oops/instanceKlass.hpp	Wed Aug 30 02:37:37 2017 -0400
@@ -450,14 +450,11 @@
   jushort nest_top_index() const { return _nest_top_index; }
   void set_nest_top_index(u2 i)  { _nest_top_index = i; }
 
-  // Returns nest-top class, resolving it if needed
-  // Returns NULL if an exception occurs during loading.
+  // Returns nest-top class, resolving and validating it if needed
+  // Returns NULL if an exception occurs during loading, or validation fails
   InstanceKlass* nest_top(TRAPS);
   InstanceKlass* raw_nest_top() { return _nest_top; } // debugging
 
-  // Resolves nest-top, if needed, and verifies we are actually a member of its nest
-  void validate_nest_top(TRAPS);
-
   // Called to verify that k is a member of this nest - does not look at k's nest-top
   bool has_nest_member(InstanceKlass* k, TRAPS) const;
   // Check if this klass is a nestmate of k
--- a/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java	Wed Aug 30 02:37:37 2017 -0400
@@ -41,7 +41,6 @@
  * @run driver jdk.test.lib.FileInstaller ./JvmciNotifyBootstrapFinishedEventTest.config
  *     ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
  * @run driver ClassFileInstaller
- *      compiler.jvmci.common.JVMCIHelpers
  *      compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult
--- a/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java	Wed Aug 30 02:37:37 2017 -0400
@@ -42,7 +42,6 @@
  * @run driver jdk.test.lib.FileInstaller ./JvmciNotifyInstallEventTest.config
  *     ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
  * @run driver ClassFileInstaller
- *      compiler.jvmci.common.JVMCIHelpers
  *      compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult
--- a/test/compiler/jvmci/events/JvmciShutdownEventTest.java	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/compiler/jvmci/events/JvmciShutdownEventTest.java	Wed Aug 30 02:37:37 2017 -0400
@@ -38,7 +38,6 @@
  * @run driver jdk.test.lib.FileInstaller ./JvmciShutdownEventTest.config
  *     ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator
  * @run driver ClassFileInstaller
- *      compiler.jvmci.common.JVMCIHelpers
  *      compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
  *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult
--- a/test/runtime/Nestmates/membership/ArrayNestTop.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/membership/ArrayNestTop.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,46 +21,58 @@
  * questions.
  */
 
-/* Generated from:
+/* Generated from: TestNestmateMembership.java
 
-public class TestNestMaterMembership {
-  public static class Nested {}
-}
+   MemberOfNest attribute is modified to refer to non-instance class Object[]
 */
 
-// Class ArrayNestTop claims to be in the nest of Object[] (not an instance class)
-
-class ArrayNestTop {
+class TestNestmateMembership$ArrayNestTop {
   0xCAFEBABE;
   0; // minor version
   53; // version
   [] { // Constant Pool
     ; // first element is empty
-    Method #3 #14; // #1    
-    class #15; // #2    
-    class #18; // #3    
-    Utf8 "obj"; // #4    
-    Utf8 "[Ljava/lang/Object;"; // #5    
-    Utf8 "<init>"; // #6    
-    Utf8 "()V"; // #7    
-    Utf8 "Code"; // #8    
-    Utf8 "LineNumberTable"; // #9    
-    Utf8 "SourceFile"; // #10    
-    Utf8 "TestNestmateMembership.java"; // #11    
-    Utf8 "MemberOfNest"; // #12    
-    class #19; // #13    
-    NameAndType #6 #7; // #14    
-    Utf8 "ArrayNestTop"; // #15    
-    Utf8 "Nested"; // #16    
-    Utf8 "InnerClasses"; // #17    
-    Utf8 "java/lang/Object"; // #18    
-    Utf8 "TestNestmateMembership"; // #19    
-    class #5; // #20 Object[] class
+    Method #6 #18; // #1    
+    Field #19 #20; // #2    
+    String #21; // #3    
+    Method #22 #23; // #4    
+    class #24; // #5    
+    class #27; // #6    
+    Utf8 "oa"; // #7    
+    Utf8 "[Ljava/lang/Object;"; // #8    
+    Utf8 "<init>"; // #9    
+    Utf8 "()V"; // #10    
+    Utf8 "Code"; // #11    
+    Utf8 "LineNumberTable"; // #12    
+    Utf8 "m"; // #13    
+    Utf8 "SourceFile"; // #14    
+    Utf8 "TestNestmateMembership.java"; // #15    
+    Utf8 "MemberOfNest"; // #16    
+    class #28; // #17    
+    NameAndType #9 #10; // #18    
+    class #29; // #19    
+    NameAndType #30 #31; // #20    
+    Utf8 "ArrayTop.m() - jcod version"; // #21  - modified
+    class #32; // #22    
+    NameAndType #33 #34; // #23    
+    Utf8 "TestNestmateMembership$ArrayNestTop"; // #24    
+    Utf8 "ArrayNestTop"; // #25    
+    Utf8 "InnerClasses"; // #26    
+    Utf8 "java/lang/Object"; // #27    
+    Utf8 "TestNestmateMembership"; // #28    
+    Utf8 "java/lang/System"; // #29    
+    Utf8 "out"; // #30    
+    Utf8 "Ljava/io/PrintStream;"; // #31    
+    Utf8 "java/io/PrintStream"; // #32    
+    Utf8 "println"; // #33    
+    Utf8 "(Ljava/lang/String;)V"; // #34    
+    // Added
+    class #8; // #35
   } // Constant Pool
 
   0x0020; // access
-  #2;// this_cpx
-  #3;// super_cpx
+  #5;// this_cpx
+  #6;// super_cpx
 
   [] { // Interfaces
   } // Interfaces
@@ -68,8 +80,8 @@
   [] { // fields
     { // Member
       0x0000; // access
-      #4; // name_cpx
-      #5; // sig_cpx
+      #7; // name_cpx
+      #8; // sig_cpx
       [] { // Attributes
       } // Attributes
     } // Member
@@ -78,10 +90,10 @@
   [] { // methods
     { // Member
       0x0000; // access
-      #6; // name_cpx
-      #7; // sig_cpx
+      #9; // name_cpx
+      #10; // sig_cpx
       [] { // Attributes
-        Attr(#8) { // Code
+        Attr(#11) { // Code
           1; // max_stack
           1; // max_locals
           Bytes[]{
@@ -90,9 +102,35 @@
           [] { // Traps
           } // end Traps
           [] { // Attributes
-            Attr(#9) { // LineNumberTable
+            Attr(#12) { // LineNumberTable
               [] { // LineNumberTable
-                0  37;
+                0  60;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member
+      0x000A; // access
+      #13; // name_cpx
+      #10; // sig_cpx
+      [] { // Attributes
+        Attr(#11) { // Code
+          2; // max_stack
+          0; // max_locals
+          Bytes[]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#12) { // LineNumberTable
+              [] { // LineNumberTable
+                0  63;
+                8  64;
               }
             } // end LineNumberTable
           } // Attributes
@@ -102,18 +140,18 @@
   } // methods
 
   [] { // Attributes
-    Attr(#10) { // SourceFile
-      #11;
+    Attr(#14) { // SourceFile
+      #15;
     } // end SourceFile
     ;
-    Attr(#12) { // MemberOfNest
-      0x0014;  // refers to Object[] class
+    Attr(#16) { // MemberOfNest - modified
+      0x0023;
     } // end MemberOfNest
     ;
-    Attr(#17) { // InnerClasses
+    Attr(#26) { // InnerClasses
       [] { // InnerClasses
-        #2 #13 #16 8;
+        #5 #17 #25 8;
       }
     } // end InnerClasses
   } // Attributes
-} // end class ArrayNestTop
+} // end class TestNestmateMembership$ArrayNestTop
--- a/test/runtime/Nestmates/membership/MissingNestTop.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/membership/MissingNestTop.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,66 +21,71 @@
  * questions.
  */
 
-/* Generated from:
+/* Generated from: TestNestmateMembership.java
 
-public class TestNestMaterMembership {
-  public static class Nested {}
-}
+   MemberOfNest attribute is modified to refer to NoSuchClass
 */
 
-// Class MissingNestTop claims to be in the nest of the non-existent NoSuchClass
-
-class MissingNestTop {
+class TestNestmateMembership$MissingNestTop {
   0xCAFEBABE;
   0; // minor version
   53; // version
   [] { // Constant Pool
     ; // first element is empty
-    Method #3 #14; // #1    
-    class #15; // #2    
-    class #18; // #3    
-    Utf8 "obj"; // #4    
-    Utf8 "[Ljava/lang/Object;"; // #5    
-    Utf8 "<init>"; // #6    
-    Utf8 "()V"; // #7    
-    Utf8 "Code"; // #8    
-    Utf8 "LineNumberTable"; // #9    
-    Utf8 "SourceFile"; // #10    
-    Utf8 "TestNestmateMembership.java"; // #11    
-    Utf8 "MemberOfNest"; // #12    
-    class #19; // #13    
-    NameAndType #6 #7; // #14    
-    Utf8 "MissingNestTop"; // #15    
-    Utf8 "Nested"; // #16    
-    Utf8 "InnerClasses"; // #17    
-    Utf8 "java/lang/Object"; // #18    
-    Utf8 "NoSuchClass"; // #19    
+    Method #6 #16; // #1    
+    Field #17 #18; // #2    
+    String #19; // #3    
+    Method #20 #21; // #4    
+    class #22; // #5    
+    class #25; // #6    
+    Utf8 "<init>"; // #7    
+    Utf8 "()V"; // #8    
+    Utf8 "Code"; // #9    
+    Utf8 "LineNumberTable"; // #10    
+    Utf8 "m"; // #11    
+    Utf8 "SourceFile"; // #12    
+    Utf8 "TestNestmateMembership.java"; // #13    
+    Utf8 "MemberOfNest"; // #14    
+    class #26; // #15    
+    NameAndType #7 #8; // #16    
+    class #27; // #17    
+    NameAndType #28 #29; // #18    
+    Utf8 "MissingNestTop.m() - jcod version"; // #19   - modified
+    class #30; // #20    
+    NameAndType #31 #32; // #21    
+    Utf8 "TestNestmateMembership$MissingNestTop"; // #22    
+    Utf8 "MissingNestTop"; // #23    
+    Utf8 "InnerClasses"; // #24    
+    Utf8 "java/lang/Object"; // #25    
+    Utf8 "TestNestmateMembership"; // #26    
+    Utf8 "java/lang/System"; // #27    
+    Utf8 "out"; // #28    
+    Utf8 "Ljava/io/PrintStream;"; // #29    
+    Utf8 "java/io/PrintStream"; // #30    
+    Utf8 "println"; // #31    
+    Utf8 "(Ljava/lang/String;)V"; // #32    
+    // added
+    Utf8 "NoSuchClass"; // 33
+    class #33; // #34
   } // Constant Pool
 
   0x0020; // access
-  #2;// this_cpx
-  #3;// super_cpx
+  #5;// this_cpx
+  #6;// super_cpx
 
   [] { // Interfaces
   } // Interfaces
 
   [] { // fields
-    { // Member
-      0x0000; // access
-      #4; // name_cpx
-      #5; // sig_cpx
-      [] { // Attributes
-      } // Attributes
-    } // Member
   } // fields
 
   [] { // methods
     { // Member
       0x0000; // access
-      #6; // name_cpx
-      #7; // sig_cpx
+      #7; // name_cpx
+      #8; // sig_cpx
       [] { // Attributes
-        Attr(#8) { // Code
+        Attr(#9) { // Code
           1; // max_stack
           1; // max_locals
           Bytes[]{
@@ -89,9 +94,35 @@
           [] { // Traps
           } // end Traps
           [] { // Attributes
-            Attr(#9) { // LineNumberTable
+            Attr(#10) { // LineNumberTable
               [] { // LineNumberTable
-                0  37;
+                0  52;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member
+      0x000A; // access
+      #11; // name_cpx
+      #8; // sig_cpx
+      [] { // Attributes
+        Attr(#9) { // Code
+          2; // max_stack
+          0; // max_locals
+          Bytes[]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#10) { // LineNumberTable
+              [] { // LineNumberTable
+                0  54;
+                8  55;
               }
             } // end LineNumberTable
           } // Attributes
@@ -101,18 +132,18 @@
   } // methods
 
   [] { // Attributes
-    Attr(#10) { // SourceFile
-      #11;
+    Attr(#12) { // SourceFile
+      #13;
     } // end SourceFile
     ;
-    Attr(#12) { // MemberOfNest
-      0x000D;
+    Attr(#14) { // MemberOfNest - modified
+      0x0022;
     } // end MemberOfNest
     ;
-    Attr(#17) { // InnerClasses
+    Attr(#24) { // InnerClasses
       [] { // InnerClasses
-        #2 #13 #16 8;
+        #5 #15 #23 8;
       }
     } // end InnerClasses
   } // Attributes
-} // end class MissingNestTop
+} // end class TestNestmateMembership$MissingNestTop
--- a/test/runtime/Nestmates/membership/NestTop.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * 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.
- */
-
-/* Generated from:
-
-public class NestTop {
-  public static class NestMember {}
-}
-*/
-
-// Class P1.NestTop claims to have a nest member NestTop$NestMember (different package)
-
-class P1/NestTop {
-  0xCAFEBABE;
-  0; // minor version
-  53; // version
-  [] { // Constant Pool
-    ; // first element is empty
-    Method #3 #14; // #1    
-    class #15; // #2    
-    class #16; // #3    
-    class #17; // #4    
-    Utf8 "NestMember"; // #5    
-    Utf8 "InnerClasses"; // #6    
-    Utf8 "<init>"; // #7    
-    Utf8 "()V"; // #8    
-    Utf8 "Code"; // #9    
-    Utf8 "LineNumberTable"; // #10    
-    Utf8 "SourceFile"; // #11    
-    Utf8 "NestTop.java"; // #12    
-    Utf8 "NestMembers"; // #13    
-    NameAndType #7 #8; // #14    
-    Utf8 "P1/NestTop"; // #15    
-    Utf8 "java/lang/Object"; // #16    
-    Utf8 "NestTop$NestMember"; // #17    
-  } // Constant Pool
-
-  0x0021; // access
-  #2;// this_cpx
-  #3;// super_cpx
-
-  [] { // Interfaces
-  } // Interfaces
-
-  [] { // fields
-  } // fields
-
-  [] { // methods
-    { // Member
-      0x0001; // access
-      #7; // name_cpx
-      #8; // sig_cpx
-      [] { // Attributes
-        Attr(#9) { // Code
-          1; // max_stack
-          1; // max_locals
-          Bytes[]{
-            0x2AB70001B1;
-          };
-          [] { // Traps
-          } // end Traps
-          [] { // Attributes
-            Attr(#10) { // LineNumberTable
-              [] { // LineNumberTable
-                0  3;
-              }
-            } // end LineNumberTable
-          } // Attributes
-        } // end Code
-      } // Attributes
-    } // Member
-  } // methods
-
-  [] { // Attributes
-    Attr(#11) { // SourceFile
-      #12;
-    } // end SourceFile
-    ;
-    Attr(#13) { // NestMembers
-      0x00010004;
-    } // end NestMembers
-    ;
-    Attr(#6) { // InnerClasses
-      [] { // InnerClasses
-        #4 #2 #5 9;
-      }
-    } // end InnerClasses
-  } // Attributes
-} // end class P1/NestTop
--- a/test/runtime/Nestmates/membership/NestTop_NestMember.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * 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.
- */
-
-/* Generated from:
-
-public class NestTop {
-  public static class NestMember {}
-}
-*/
-
-// Class NestTop$NestMember claims to be in the nest of P1.NestTop (different package)
-
-class NestTop$NestMember {
-  0xCAFEBABE;
-  0; // minor version
-  53; // version
-  [] { // Constant Pool
-    ; // first element is empty
-    Method #3 #12; // #1    
-    class #13; // #2    
-    class #16; // #3    
-    Utf8 "<init>"; // #4    
-    Utf8 "()V"; // #5    
-    Utf8 "Code"; // #6    
-    Utf8 "LineNumberTable"; // #7    
-    Utf8 "SourceFile"; // #8    
-    Utf8 "NestTop.java"; // #9    
-    Utf8 "MemberOfNest"; // #10    
-    class #17; // #11    
-    NameAndType #4 #5; // #12    
-    Utf8 "NestTop$NestMember"; // #13    
-    Utf8 "NestMember"; // #14    
-    Utf8 "InnerClasses"; // #15    
-    Utf8 "java/lang/Object"; // #16    
-    Utf8 "P1/NestTop"; // #17    
-  } // Constant Pool
-
-  0x0021; // access
-  #2;// this_cpx
-  #3;// super_cpx
-
-  [] { // Interfaces
-  } // Interfaces
-
-  [] { // fields
-  } // fields
-
-  [] { // methods
-    { // Member
-      0x0001; // access
-      #4; // name_cpx
-      #5; // sig_cpx
-      [] { // Attributes
-        Attr(#6) { // Code
-          1; // max_stack
-          1; // max_locals
-          Bytes[]{
-            0x2AB70001B1;
-          };
-          [] { // Traps
-          } // end Traps
-          [] { // Attributes
-            Attr(#7) { // LineNumberTable
-              [] { // LineNumberTable
-                0  4;
-              }
-            } // end LineNumberTable
-          } // Attributes
-        } // end Code
-      } // Attributes
-    } // Member
-  } // methods
-
-  [] { // Attributes
-    Attr(#8) { // SourceFile
-      #9;
-    } // end SourceFile
-    ;
-    Attr(#10) { // MemberOfNest
-      0x000B;
-    } // end MemberOfNest
-    ;
-    Attr(#15) { // InnerClasses
-      [] { // InnerClasses
-        #2 #11 #14 9;
-      }
-    } // end InnerClasses
-  } // Attributes
-} // end class NestTop$NestMember
--- a/test/runtime/Nestmates/membership/NotAMember.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/membership/NotAMember.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,66 +21,68 @@
  * questions.
  */
 
-/* Generated from:
+/* Generated from: TestNestmateMembership.java
 
-public class TestNestMaterMembership {
-  public static class Nested {}
-}
+   MemberOfNest attribute is modified to refer to Object
 */
 
-// Class NotAMember claims to be in the nest of Object (which has no nest)
-
-class NotAMember {
+class TestNestmateMembership$NotAMember {
   0xCAFEBABE;
   0; // minor version
   53; // version
   [] { // Constant Pool
     ; // first element is empty
-    Method #3 #14; // #1    
-    class #15; // #2    
-    class #18; // #3    
-    Utf8 "obj"; // #4    
-    Utf8 "[Ljava/lang/Object;"; // #5    
-    Utf8 "<init>"; // #6    
-    Utf8 "()V"; // #7    
-    Utf8 "Code"; // #8    
-    Utf8 "LineNumberTable"; // #9    
-    Utf8 "SourceFile"; // #10    
-    Utf8 "TestNestmateMembership.java"; // #11    
-    Utf8 "MemberOfNest"; // #12    
-    class #19; // #13    
-    NameAndType #6 #7; // #14    
-    Utf8 "NotAMember"; // #15    
-    Utf8 "Nested"; // #16    
-    Utf8 "InnerClasses"; // #17    
-    Utf8 "java/lang/Object"; // #18    
-    Utf8 "TestNestmateMembership"; // #19    
+    Method #6 #16; // #1    
+    Field #17 #18; // #2    
+    String #19; // #3    
+    Method #20 #21; // #4    
+    class #22; // #5    
+    class #25; // #6    
+    Utf8 "<init>"; // #7    
+    Utf8 "()V"; // #8    
+    Utf8 "Code"; // #9    
+    Utf8 "LineNumberTable"; // #10    
+    Utf8 "m"; // #11    
+    Utf8 "SourceFile"; // #12    
+    Utf8 "TestNestmateMembership.java"; // #13    
+    Utf8 "MemberOfNest"; // #14    
+    class #26; // #15    
+    NameAndType #7 #8; // #16    
+    class #27; // #17    
+    NameAndType #28 #29; // #18    
+    Utf8 "NotAMember.m() - jcod version"; // #19  - modified
+    class #30; // #20    
+    NameAndType #31 #32; // #21    
+    Utf8 "TestNestmateMembership$NotAMember"; // #22    
+    Utf8 "NotAMember"; // #23    
+    Utf8 "InnerClasses"; // #24    
+    Utf8 "java/lang/Object"; // #25    
+    Utf8 "TestNestmateMembership"; // #26    
+    Utf8 "java/lang/System"; // #27    
+    Utf8 "out"; // #28    
+    Utf8 "Ljava/io/PrintStream;"; // #29    
+    Utf8 "java/io/PrintStream"; // #30    
+    Utf8 "println"; // #31    
+    Utf8 "(Ljava/lang/String;)V"; // #32    
   } // Constant Pool
 
   0x0020; // access
-  #2;// this_cpx
-  #3;// super_cpx
+  #5;// this_cpx
+  #6;// super_cpx
 
   [] { // Interfaces
   } // Interfaces
 
   [] { // fields
-    { // Member
-      0x0000; // access
-      #4; // name_cpx
-      #5; // sig_cpx
-      [] { // Attributes
-      } // Attributes
-    } // Member
   } // fields
 
   [] { // methods
     { // Member
       0x0000; // access
-      #6; // name_cpx
-      #7; // sig_cpx
+      #7; // name_cpx
+      #8; // sig_cpx
       [] { // Attributes
-        Attr(#8) { // Code
+        Attr(#9) { // Code
           1; // max_stack
           1; // max_locals
           Bytes[]{
@@ -89,9 +91,35 @@
           [] { // Traps
           } // end Traps
           [] { // Attributes
-            Attr(#9) { // LineNumberTable
+            Attr(#10) { // LineNumberTable
               [] { // LineNumberTable
-                0  37;
+                0  65;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member
+      0x000A; // access
+      #11; // name_cpx
+      #8; // sig_cpx
+      [] { // Attributes
+        Attr(#9) { // Code
+          2; // max_stack
+          0; // max_locals
+          Bytes[]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#10) { // LineNumberTable
+              [] { // LineNumberTable
+                0  67;
+                8  68;
               }
             } // end LineNumberTable
           } // Attributes
@@ -101,18 +129,18 @@
   } // methods
 
   [] { // Attributes
-    Attr(#10) { // SourceFile
-      #11;
+    Attr(#12) { // SourceFile
+      #13;
     } // end SourceFile
     ;
-    Attr(#12) { // MemberOfNest
-      0x0003;  // refers to Object class
+    Attr(#14) { // MemberOfNest - modified
+      0x0006;
     } // end MemberOfNest
     ;
-    Attr(#17) { // InnerClasses
+    Attr(#24) { // InnerClasses
       [] { // InnerClasses
-        #2 #13 #16 8;
+        #5 #15 #23 8;
       }
     } // end InnerClasses
   } // Attributes
-} // end class NotAMember
+} // end class TestNestmateMembership$NotAMember
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/membership/NotAMember2.java	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+public class NotAMember2 {
+    // jcod modified to have a nest-top which does not include this class
+    public static class Member {
+        // this generates a CP entry we can use for the nest-top
+        static Class tc = TestNestmateMembership.class;
+
+        // jcod modified to be private
+        public static void m() {
+            System.out.println("NotAMember2.Member.m() - java version");
+        }
+    }
+}
\ No newline at end of file
--- a/test/runtime/Nestmates/membership/NotAMember2.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/membership/NotAMember2.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,54 +21,71 @@
  * questions.
  */
 
-/* Generated from:
+/* Generated from: NotAMember2.java
 
-public class TestNestMaterMembership {
-  public static class Nested {}
-}
+   MemberOfNest attribute is modified to refer to TestNestmateMembership.
+   m() is declared private
 */
 
-// Class NotAMember2 claims to be in the nest of TestNestmateMembership but isn't
-
-class NotAMember2 {
+class NotAMember2$Member {
   0xCAFEBABE;
   0; // minor version
   53; // version
   [] { // Constant Pool
     ; // first element is empty
-    Method #3 #14; // #1    
-    class #15; // #2    
-    class #18; // #3    
-    Utf8 "obj"; // #4    
-    Utf8 "[Ljava/lang/Object;"; // #5    
-    Utf8 "<init>"; // #6    
-    Utf8 "()V"; // #7    
-    Utf8 "Code"; // #8    
-    Utf8 "LineNumberTable"; // #9    
-    Utf8 "SourceFile"; // #10    
-    Utf8 "TestNestmateMembership.java"; // #11    
-    Utf8 "MemberOfNest"; // #12    
-    class #19; // #13    
-    NameAndType #6 #7; // #14    
-    Utf8 "NotAMember2"; // #15    
-    Utf8 "Nested"; // #16    
-    Utf8 "InnerClasses"; // #17    
-    Utf8 "java/lang/Object"; // #18    
-    Utf8 "TestNestmateMembership"; // #19    
+    Method #8 #21; // #1    
+    Field #22 #23; // #2    
+    String #24; // #3    
+    Method #25 #26; // #4    
+    class #27; // #5    
+    Field #7 #28; // #6    
+    class #29; // #7    
+    class #32; // #8    
+    Utf8 "tc"; // #9    
+    Utf8 "Ljava/lang/Class;"; // #10    
+    Utf8 "<init>"; // #11    
+    Utf8 "()V"; // #12    
+    Utf8 "Code"; // #13    
+    Utf8 "LineNumberTable"; // #14    
+    Utf8 "m"; // #15    
+    Utf8 "<clinit>"; // #16    
+    Utf8 "SourceFile"; // #17    
+    Utf8 "NotAMember2.java"; // #18    
+    Utf8 "MemberOfNest"; // #19    
+    class #33; // #20    
+    NameAndType #11 #12; // #21    
+    class #34; // #22    
+    NameAndType #35 #36; // #23    
+    Utf8 "NotAMember2.Member.m() - jcod version"; // #24    - modified
+    class #37; // #25    
+    NameAndType #38 #39; // #26    
+    Utf8 "TestNestmateMembership"; // #27    
+    NameAndType #9 #10; // #28    
+    Utf8 "NotAMember2$Member"; // #29    
+    Utf8 "Member"; // #30    
+    Utf8 "InnerClasses"; // #31    
+    Utf8 "java/lang/Object"; // #32    
+    Utf8 "NotAMember2"; // #33    
+    Utf8 "java/lang/System"; // #34    
+    Utf8 "out"; // #35    
+    Utf8 "Ljava/io/PrintStream;"; // #36    
+    Utf8 "java/io/PrintStream"; // #37    
+    Utf8 "println"; // #38    
+    Utf8 "(Ljava/lang/String;)V"; // #39    
   } // Constant Pool
 
-  0x0020; // access
-  #2;// this_cpx
-  #3;// super_cpx
+  0x0021; // access
+  #7;// this_cpx
+  #8;// super_cpx
 
   [] { // Interfaces
   } // Interfaces
 
   [] { // fields
     { // Member
-      0x0000; // access
-      #4; // name_cpx
-      #5; // sig_cpx
+      0x0008; // access
+      #9; // name_cpx
+      #10; // sig_cpx
       [] { // Attributes
       } // Attributes
     } // Member
@@ -76,11 +93,11 @@
 
   [] { // methods
     { // Member
-      0x0000; // access
-      #6; // name_cpx
-      #7; // sig_cpx
+      0x0001; // access
+      #11; // name_cpx
+      #12; // sig_cpx
       [] { // Attributes
-        Attr(#8) { // Code
+        Attr(#13) { // Code
           1; // max_stack
           1; // max_locals
           Bytes[]{
@@ -89,9 +106,59 @@
           [] { // Traps
           } // end Traps
           [] { // Attributes
-            Attr(#9) { // LineNumberTable
+            Attr(#14) { // LineNumberTable
               [] { // LineNumberTable
-                0  37;
+                0  4;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member
+      0x000A; // access - modified
+      #15; // name_cpx
+      #12; // sig_cpx
+      [] { // Attributes
+        Attr(#13) { // Code
+          2; // max_stack
+          0; // max_locals
+          Bytes[]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#14) { // LineNumberTable
+              [] { // LineNumberTable
+                0  9;
+                8  10;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member
+      0x0008; // access
+      #16; // name_cpx
+      #12; // sig_cpx
+      [] { // Attributes
+        Attr(#13) { // Code
+          1; // max_stack
+          0; // max_locals
+          Bytes[]{
+            0x1205B30006B1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#14) { // LineNumberTable
+              [] { // LineNumberTable
+                0  5;
               }
             } // end LineNumberTable
           } // Attributes
@@ -101,18 +168,18 @@
   } // methods
 
   [] { // Attributes
-    Attr(#10) { // SourceFile
-      #11;
+    Attr(#17) { // SourceFile
+      #18;
     } // end SourceFile
     ;
-    Attr(#12) { // MemberOfNest
-      0x000D;  // refers to TestNestmateMembership
+    Attr(#19) { // MemberOfNest - modified
+      0x0005;
     } // end MemberOfNest
     ;
-    Attr(#17) { // InnerClasses
+    Attr(#31) { // InnerClasses
       [] { // InnerClasses
-        #2 #13 #16 8;
+        #7 #20 #30 9;
       }
     } // end InnerClasses
   } // Attributes
-} // end class NotAMember2
+} // end class NotAMember2$Member
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/membership/PackagedNestTop.java	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,46 @@
+/*
+ * 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 P1;
+
+/*
+ * This is used to produce a jcod file in which we modify the
+ * NestMembers attribute to claim that P2.PackagedNestTop.Member
+ * is a member of our nest.
+ */
+public class PackagedNestTop {
+    // Use this to get our own NestMembers attribute
+    public static class Member {
+        private static void m() {
+            System.out.println("You should never see this!");
+        }
+    }
+
+    // Entry point for main test
+    public static void doAccess() {
+        // this should fail at runtime as m() will now be private
+        // and the nestmate access check should fail due to m() being in
+        // a different package.
+        P2.PackagedNestTop2.Member.m();
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/membership/PackagedNestTop.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ */
+
+/* Generated from: PackagedNestTop.java
+
+   NestMembers attribute is modified to contain P2.PackagedNestTop2.Member
+*/
+
+class P1/PackagedNestTop {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [] { // Constant Pool
+    ; // first element is empty
+    Method #4 #16; // #1    
+    Method #17 #18; // #2    
+    class #19; // #3    
+    class #20; // #4    
+    class #21; // #5    
+    Utf8 "Member"; // #6    
+    Utf8 "InnerClasses"; // #7    
+    Utf8 "<init>"; // #8    
+    Utf8 "()V"; // #9    
+    Utf8 "Code"; // #10    
+    Utf8 "LineNumberTable"; // #11    
+    Utf8 "doAccess"; // #12    
+    Utf8 "SourceFile"; // #13    
+    Utf8 "PackagedNestTop.java"; // #14    
+    Utf8 "NestMembers"; // #15    
+    NameAndType #8 #9; // #16    
+    class #23; // #17    
+    NameAndType #24 #9; // #18    
+    Utf8 "P1/PackagedNestTop"; // #19    
+    Utf8 "java/lang/Object"; // #20    
+    Utf8 "P1/PackagedNestTop$Member"; // #21    
+    class #25; // #22    
+    Utf8 "P2/PackagedNestTop2$Member"; // #23    
+    Utf8 "m"; // #24    
+    Utf8 "P2/PackagedNestTop2"; // #25    
+  } // Constant Pool
+
+  0x0021; // access
+  #3;// this_cpx
+  #4;// super_cpx
+
+  [] { // Interfaces
+  } // Interfaces
+
+  [] { // fields
+  } // fields
+
+  [] { // methods
+    { // Member
+      0x0001; // access
+      #8; // name_cpx
+      #9; // sig_cpx
+      [] { // Attributes
+        Attr(#10) { // Code
+          1; // max_stack
+          1; // max_locals
+          Bytes[]{
+            0x2AB70001B1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#11) { // LineNumberTable
+              [] { // LineNumberTable
+                0  31;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member
+      0x0009; // access
+      #12; // name_cpx
+      #9; // sig_cpx
+      [] { // Attributes
+        Attr(#10) { // Code
+          0; // max_stack
+          0; // max_locals
+          Bytes[]{
+            0xB80002B1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#11) { // LineNumberTable
+              [] { // LineNumberTable
+                0  44;
+                3  45;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [] { // Attributes
+    Attr(#13) { // SourceFile
+      #14;
+    } // end SourceFile
+    ;
+    Attr(#15) { // NestMembers - modified
+      0x00010011;
+    } // end NestMembers
+    ;
+    Attr(#7) { // InnerClasses
+      [] { // InnerClasses
+        #5 #3 #6 9;
+        #17 #22 #6 9;
+      }
+    } // end InnerClasses
+  } // Attributes
+} // end class P1/PackagedNestTop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/membership/PackagedNestTop2.java	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,38 @@
+/*
+ * 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 P2;
+
+/*
+ * This is used to produce a jcod file in which we modify the
+ * MemberOfNest attribute to claim that P2.PackagedNestTop.Member
+ * is a member of the nest of P1.PackagedNestTop.
+ */
+public class PackagedNestTop2 {
+    public static class Member {
+        // jcod file changes this to private
+        public static void m() {
+            System.out.println("You should never see this!");
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/membership/PackagedNestTop2Member.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ */
+
+/* Generated from: PackagedNestTop2.java
+
+   MemberOfNest attribute is modified to contain P1.PackagedNestTop
+   m() is declared to be private
+*/
+
+class P2/PackagedNestTop2$Member {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [] { // Constant Pool
+    ; // first element is empty
+    Method #6 #16; // #1    
+    Field #17 #18; // #2    
+    String #19; // #3    
+    Method #20 #21; // #4    
+    class #22; // #5    
+    class #25; // #6    
+    Utf8 "<init>"; // #7    
+    Utf8 "()V"; // #8    
+    Utf8 "Code"; // #9    
+    Utf8 "LineNumberTable"; // #10    
+    Utf8 "m"; // #11    
+    Utf8 "SourceFile"; // #12    
+    Utf8 "PackagedNestTop2.java"; // #13    
+    Utf8 "MemberOfNest"; // #14    
+    class #26; // #15    
+    NameAndType #7 #8; // #16    
+    class #27; // #17    
+    NameAndType #28 #29; // #18    
+    Utf8 "You should never see this!"; // #19    
+    class #30; // #20    
+    NameAndType #31 #32; // #21    
+    Utf8 "P2/PackagedNestTop2$Member"; // #22    
+    Utf8 "Member"; // #23    
+    Utf8 "InnerClasses"; // #24    
+    Utf8 "java/lang/Object"; // #25    
+    Utf8 "P2/PackagedNestTop2"; // #26    
+    Utf8 "java/lang/System"; // #27    
+    Utf8 "out"; // #28    
+    Utf8 "Ljava/io/PrintStream;"; // #29    
+    Utf8 "java/io/PrintStream"; // #30    
+    Utf8 "println"; // #31    
+    Utf8 "(Ljava/lang/String;)V"; // #32  
+    // added entries
+    Utf8 "P1/PackagedNestTop"; // #33    
+    class #33; // #34
+  } // Constant Pool
+
+  0x0021; // access
+  #5;// this_cpx
+  #6;// super_cpx
+
+  [] { // Interfaces
+  } // Interfaces
+
+  [] { // fields
+  } // fields
+
+  [] { // methods
+    { // Member
+      0x0001; // access
+      #7; // name_cpx
+      #8; // sig_cpx
+      [] { // Attributes
+        Attr(#9) { // Code
+          1; // max_stack
+          1; // max_locals
+          Bytes[]{
+            0x2AB70001B1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#10) { // LineNumberTable
+              [] { // LineNumberTable
+                0  32;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member
+      0x000A; // access- modified
+      #11; // name_cpx
+      #8; // sig_cpx
+      [] { // Attributes
+        Attr(#9) { // Code
+          2; // max_stack
+          0; // max_locals
+          Bytes[]{
+            0xB200021203B60004;
+            0xB1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#10) { // LineNumberTable
+              [] { // LineNumberTable
+                0  35;
+                8  36;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [] { // Attributes
+    Attr(#12) { // SourceFile
+      #13;
+    } // end SourceFile
+    ;
+    Attr(#14) { // MemberOfNest - modified
+      0x0022;
+    } // end MemberOfNest
+    ;
+    Attr(#24) { // InnerClasses
+      [] { // InnerClasses
+        #5 #15 #23 9;
+      }
+    } // end InnerClasses
+  } // Attributes
+} // end class P2/PackagedNestTop2$Member
--- a/test/runtime/Nestmates/membership/TestNestmateMembership.java	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/membership/TestNestmateMembership.java	Wed Aug 30 02:37:37 2017 -0400
@@ -25,69 +25,140 @@
  * @test
  * @bug 8046171
  * @summary Test the various rules for nest members and nest-tops
- * @compile TestNestmateMembership.java
- *          MissingNestTop.jcod
+ * @compile -XDdisablePrivateAccessors
+ *          TestNestmateMembership.java
+ *          PackagedNestTop.java
+ *          PackagedNestTop2.java
+ *          NotAMember2.java
+ * @compile MissingNestTop.jcod
  *          ArrayNestTop.jcod
  *          NotAMember.jcod
  *          NotAMember2.jcod
- *          NestTop.jcod
- *          NestTop_NestMember.jcod
- * @run main/othervm -Xlog:class+nestmates=off TestNestmateMembership
+ *          PackagedNestTop.jcod
+ *          PackagedNestTop2Member.jcod
+ * @run main/othervm TestNestmateMembership
  */
 
 // We test all the "illegal" relationships between a nest member and its nest-top
 // except for the case where the name of the nest-member matches the name listed
-// in the nest-top, but resolves to a different class. There doesn't seem to 
+// in the nest-top, but resolves to a different class. There doesn't seem to
 // be a way to construct that scenario.
+// For each nested class below there is a corresponding .jcod file which breaks one
+// of the rules regarding nest membership. For the package related tests we have
+// additional PackageNestTop*.java sources. We also have NotAMember2.java.
+// Note that all the .java files must be compiled in the same step, while all
+// .jcod files must be compiled in a later step.
 
 public class TestNestmateMembership {
 
-  static class Nested { // basic template for the jcod files
-    Object[] obj;
-  }
-
-  public static void main(String[] args) throws Throwable {
-    // Class's nest top does not exist
-    String msg = "NoSuchClass";
-    try {
-      Class<?> c = Class.forName("MissingNestTop");
-      throw new Error("Missing NoClassDefFoundError: " + msg);
-    }
-    catch (NoClassDefFoundError expected) {
-      if (!expected.getMessage().contains(msg))
-        throw new Error("Wrong NoClassDefFoundError: \"" +
-                        expected.getMessage() + "\" does not contain \"" +
-                        msg + "\"");
-      System.out.println("OK - got expected exception: " + expected);
+    // jcod modified to have non-existent nest-top
+    static class MissingNestTop {
+        private static void m() {
+            System.out.println("MissingNestTop.m() - java version");
+        }
     }
 
-    String[] badClasses = new String[] {
-      "ArrayNestTop",  // Listed  nest-top is not an instance class
-      "NotAMember",    // Listed nest-top has no nest
-      "NotAMember2",   // Listed nest-top doesn't list this class as member
-      "NestTop$NestMember", // nest-top and nest member are in different packages
-                            // - note both classes have to list the incorrect package
-    };
-    
-    String[] messages = new String[] {
-      "ArrayNestTop has non-instance class [Ljava.lang.Object; as nest-top",
-      "NotAMember is not a nest member of java.lang.Object",
-      "NotAMember2 is not a nest member of TestNestmateMembership",
-      "NestTop$NestMember is in a different package to its nest top class",
-    };
+    // jcod modified to have non-instance class Object[] as nest-top
+    static class ArrayNestTop {
+        Object[] oa; // create CP entry
+        private static void m() {
+            System.out.println("ArrayTop.m() - java version");
+        }
+    }
 
-    for (int i = 0; i < badClasses.length; i++ ) {
-      try {
-        Class<?> c = Class.forName(badClasses[i]);
-        throw new Error("Missing IncompatibleClassChangeError:" + messages[i]);
-      }
-      catch (IncompatibleClassChangeError expected) {
-        if (!expected.getMessage().contains(messages[i]))
-          throw new Error("Wrong IncompatibleClassChangeError: \"" +
-                          expected.getMessage() + "\" does not contain \"" +
-                          messages[i] + "\"");
-        System.out.println("OK - got expected exception: " + expected);
-      }
+    // jcod modified to have Object as nest-top, which has no nest-members
+    static class NotAMember {
+        private static void m() {
+            System.out.println("NotAMember.m() - java version");
+        }
     }
-  }
+
+    public static void main(String[] args) throws Throwable {
+        test_MissingNestTop();
+        test_ArrayNestTop();
+        test_WrongPackageForNestMember();
+        test_NotAMember();
+        test_NotAMember2();
+    }
+
+    static void test_WrongPackageForNestMember() {
+        System.out.println("Testing for nest-top and nest-member in different packages");
+        String msg = "Class P2.PackagedNestTop2$Member is in a different" +
+                     " package to its nest top class P1.PackagedNestTop";
+        try {
+            P1.PackagedNestTop.doAccess();
+            throw new Error("Missing IncompatibleClassChangeError: " + msg);
+        }
+        catch (IncompatibleClassChangeError expected) {
+            if (!expected.getMessage().contains(msg))
+                throw new Error("Wrong IncompatibleClassChangeError: \"" +
+                                expected.getMessage() + "\" does not contain \"" +
+                                msg + "\"");
+            System.out.println("OK - got expected exception: " + expected);
+        }
+    }
+
+    static void test_MissingNestTop() throws Throwable {
+        System.out.println("Testing for nest-top class that does not exist");
+        String msg = "NoSuchClass";
+        try {
+            MissingNestTop.m();
+            throw new Error("Missing NoClassDefFoundError: " + msg);
+        }
+        catch (NoClassDefFoundError expected) {
+            if (!expected.getMessage().contains(msg))
+                throw new Error("Wrong NoClassDefFoundError: \"" +
+                                expected.getMessage() + "\" does not contain \"" +
+                                msg + "\"");
+            System.out.println("OK - got expected exception: " + expected);
+        }
+    }
+
+    static void test_ArrayNestTop() throws Throwable {
+        System.out.println("Testing for nest-top class that is not an instance class");
+        String msg = "ArrayNestTop has non-instance class [Ljava.lang.Object; as nest-top";
+        try {
+            ArrayNestTop.m();
+            throw new Error("Missing IncompatibleClassChangeError: " + msg);
+        }
+        catch (IncompatibleClassChangeError expected) {
+            if (!expected.getMessage().contains(msg))
+                throw new Error("Wrong IncompatibleClassChangeError: \"" +
+                                expected.getMessage() + "\" does not contain \"" +
+                                msg + "\"");
+            System.out.println("OK - got expected exception: " + expected);
+        }
+    }
+
+    static void test_NotAMember() throws Throwable {
+        System.out.println("Testing for nest-top class that has no nest");
+        String msg = "NotAMember is not a nest member of java.lang.Object";
+        try {
+            NotAMember.m();
+            throw new Error("Missing IncompatibleClassChangeError: " + msg);
+        }
+        catch (IncompatibleClassChangeError expected) {
+            if (!expected.getMessage().contains(msg))
+                throw new Error("Wrong IncompatibleClassChangeError: \"" +
+                                expected.getMessage() + "\" does not contain \"" +
+                                msg + "\"");
+            System.out.println("OK - got expected exception: " + expected);
+        }
+    }
+
+    static void test_NotAMember2() throws Throwable {
+        System.out.println("Testing for nest-top class that doesn't list this class as a member");
+        String msg = "NotAMember2$Member is not a nest member of TestNestmateMembership";
+        try {
+            NotAMember2.Member.m();
+            throw new Error("Missing IncompatibleClassChangeError: " + msg);
+        }
+        catch (IncompatibleClassChangeError expected) {
+            if (!expected.getMessage().contains(msg))
+                throw new Error("Wrong IncompatibleClassChangeError: \"" +
+                                expected.getMessage() + "\" does not contain \"" +
+                                msg + "\"");
+            System.out.println("OK - got expected exception: " + expected);
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/privateConstructors/ExternalSub.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+/* Generated from: ExternalSub.java
+
+   Super constructor call is changed from the public NestedA(int)
+   constructor to the private NestedA() constructor.
+*/
+
+class ExternalSub {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [] { // Constant Pool
+    ; // first element is empty
+    Method #3 #10; // #1    
+    class #11; // #2    
+    class #13; // #3    
+    Utf8 "<init>"; // #4    
+    Utf8 "()V"; // #5    
+    Utf8 "Code"; // #6    
+    Utf8 "LineNumberTable"; // #7    
+    Utf8 "SourceFile"; // #8    
+    Utf8 "TestConstructorHierarchy.java"; // #9    
+    NameAndType #4 #5; // #10    - modified #16 to #5
+    Utf8 "ExternalSub"; // #11    
+    class #17; // #12    
+    Utf8 "TestConstructorHierarchy$NestedA"; // #13    
+    Utf8 "NestedA"; // #14    
+    Utf8 "InnerClasses"; // #15    
+    Utf8 "(I)V"; // #16    
+    Utf8 "TestConstructorHierarchy"; // #17    
+  } // Constant Pool
+
+  0x0020; // access
+  #2;// this_cpx
+  #3;// super_cpx
+
+  [] { // Interfaces
+  } // Interfaces
+
+  [] { // fields
+  } // fields
+
+  [] { // methods
+    { // Member
+      0x0001 // access 
+      #4; // name_cpx
+      #5; // sig_cpx
+      [] { // Attributes
+        Attr(#6) { // Code
+          1; // max_stack - modified from 2
+          1; // max_locals
+          Bytes[]{
+            0x2AB70001B1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#7) { // LineNumberTable
+              [] { // LineNumberTable
+                0  84;
+//                5  85;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [] { // Attributes
+    Attr(#8) { // SourceFile
+      #9;
+    } // end SourceFile
+    ;
+    Attr(#15) { // InnerClasses
+      [] { // InnerClasses
+        #3 #12 #14 8;
+      }
+    } // end InnerClasses
+  } // Attributes
+} // end class ExternalSub
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/privateConstructors/ExternalSuper.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+/* Generated from: ExternalSuper.java
+
+   Constructor access level is changed to private.
+*/
+
+class ExternalSuper {
+  0xCAFEBABE;
+  0; // minor version
+  53; // version
+  [] { // Constant Pool
+    ; // first element is empty
+    Method #3 #10; // #1    
+    class #11; // #2    
+    class #12; // #3    
+    Utf8 "<init>"; // #4    
+    Utf8 "()V"; // #5    
+    Utf8 "Code"; // #6    
+    Utf8 "LineNumberTable"; // #7    
+    Utf8 "SourceFile"; // #8    
+    Utf8 "TestConstructorHierarchy.java"; // #9    
+    NameAndType #4 #5; // #10    
+    Utf8 "ExternalSuper"; // #11    
+    Utf8 "java/lang/Object"; // #12    
+  } // Constant Pool
+
+  0x0020; // access
+  #2;// this_cpx
+  #3;// super_cpx
+
+  [] { // Interfaces
+  } // Interfaces
+
+  [] { // fields
+  } // fields
+
+  [] { // methods
+    { // Member
+      0x0002; // access - modified to private
+      #4; // name_cpx
+      #5; // sig_cpx
+      [] { // Attributes
+        Attr(#6) { // Code
+          1; // max_stack
+          1; // max_locals
+          Bytes[]{
+            0x2AB70001B1;
+          };
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#7) { // LineNumberTable
+              [] { // LineNumberTable
+                0  78;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [] { // Attributes
+    Attr(#8) { // SourceFile
+      #9;
+    } // end SourceFile
+  } // Attributes
+} // end class ExternalSuper
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/privateConstructors/TestConstructorHierarchy.java	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,96 @@
+/*
+ * 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 8046171
+ * @summary Test access to private constructors in the hierarchy that are
+ * outside the nest
+ * @compile -XDdisablePrivateAccessors TestConstructorHierarchy.java
+ * @compile ExternalSuper.jcod
+ *          ExternalSub.jcod
+ * @run main TestConstructorHierarchy
+ */
+
+public class TestConstructorHierarchy {
+
+    static class NestedA extends ExternalSuper {
+        private NestedA() {}
+        protected NestedA(int i) {} // for compile-time only
+    }
+
+    // Access to private members of classes outside the nest is
+    // not permitted. These tests should throw IllegalAccessError
+    // at runtime. To allow them to compile the classes below are
+    // defined with public members. We then replace those class files
+    // with jcod variants that make the member private again.
+
+    public static void main(String[] args) throws Throwable {
+        try {
+            new ExternalSuper();
+            throw new Error("Unexpected construction of ExternalSuper");
+        }
+        catch (IllegalAccessError iae) {
+            if (iae.getMessage().contains("tried to access method ExternalSuper.<init>()V from class TestConstructorHierarchy")) {
+                System.out.println("Got expected exception constructing ExternalSuper: " + iae);
+            }
+            else throw new Error("Unexpected IllegalAccessError: " + iae);
+        }
+        try {
+            new NestedA();
+            throw new Error("Unexpected construction of NestedA and supers");
+        }
+        catch (IllegalAccessError iae) {
+            if (iae.getMessage().contains("tried to access method ExternalSuper.<init>()V from class TestConstructorHierarchy$NestedA")) {
+                System.out.println("Got expected exception constructing NestedA: " + iae);
+            }
+            else throw new Error("Unexpected IllegalAccessError: " + iae);
+        }
+        try {
+            new ExternalSub();
+            throw new Error("Unexpected construction of ExternalSub");
+        }
+        catch (IllegalAccessError iae) {
+            if (iae.getMessage().contains("tried to access method TestConstructorHierarchy$NestedA.<init>()V from class ExternalSub")) {
+                System.out.println("Got expected exception constructing ExternalSub: " + iae);
+            }
+            else throw new Error("Unexpected IllegalAccessError: " + iae);
+        }
+    }
+}
+
+// Classes that are not part of the nest.
+// Being non-public allows us to declare them in this file.
+// The constructor is public to allow this file to compile, but
+// the jcod files change it back to private.
+
+class ExternalSuper {
+    public ExternalSuper() { }
+}
+
+
+class ExternalSub extends TestConstructorHierarchy.NestedA {
+    public ExternalSub() {
+        super(0); // this is changed to super() in jcod file
+    }
+}
--- a/test/runtime/Nestmates/privateMethods/ExternalSub.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/privateMethods/ExternalSub.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// Generated from the source in TestInvokeSpecialHierarchy.java
+// Generated from the source in TestInvokeHierarchy.java
 // with priv_invoke access modifier changed to private
 
 class ExternalSub {
@@ -44,15 +44,15 @@
     Utf8 "priv_invoke"; // #12    
     Utf8 "()Ljava/lang/String;"; // #13    
     Utf8 "SourceFile"; // #14    
-    Utf8 "TestInvokeSpecialHierarchy.java"; // #15    
+    Utf8 "TestInvokeHierarchy.java"; // #15    
     NameAndType #8 #9; // #16    
     Utf8 "ExternalSub"; // #17    
     Utf8 "ExternalSub::priv_invoke"; // #18    
     class #23; // #19    
-    Utf8 "TestInvokeSpecialHierarchy$NestedC"; // #20    
+    Utf8 "TestInvokeHierarchy$NestedC"; // #20    
     Utf8 "NestedC"; // #21    
     Utf8 "InnerClasses"; // #22    
-    Utf8 "TestInvokeSpecialHierarchy"; // #23    
+    Utf8 "TestInvokeHierarchy"; // #23    
   } // Constant Pool
 
   0x0020; // access
--- a/test/runtime/Nestmates/privateMethods/ExternalSuper.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/privateMethods/ExternalSuper.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// Generated from the source in TestInvokeSpecialHierarchy.java
+// Generated from the source in TestInvokeHierarchy.java
 // with priv_invoke access modifier changed to private
 
 class ExternalSuper {
@@ -44,7 +44,7 @@
     Utf8 "priv_invoke_s"; // #12    
     Utf8 "()Ljava/lang/String;"; // #13    
     Utf8 "SourceFile"; // #14    
-    Utf8 "TestInvokeSpecialHierarchy.java"; // #15    
+    Utf8 "TestInvokeHierarchy.java"; // #15    
     NameAndType #8 #9; // #16    
     Utf8 "ExternalSuper"; // #17    
     Utf8 "ExternalSuper::priv_invoke_s"; // #18    
--- a/test/runtime/Nestmates/privateMethods/MissingMethod.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/privateMethods/MissingMethod.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,10 +21,10 @@
  * questions.
  */
 
-// Generated from the source in TestInvokeSpecialErrors.java
+// Generated from the source in TestInvokeErrors.java
 // with priv_invoke renamed to not_priv_invoke so it isn't found
 
-class TestInvokeSpecialErrors$MissingMethod {
+class TestInvokeErrors$MissingMethod {
   0xCAFEBABE;
   0; // minor version
   53; // version
@@ -42,7 +42,7 @@
     Utf8 "LineNumberTable"; // #10    
     Utf8 "not_priv_invoke"; // #11 - renamed    
     Utf8 "SourceFile"; // #12    
-    Utf8 "TestInvokeSpecialErrors.java"; // #13    
+    Utf8 "TestInvokeErrors.java"; // #13    
     Utf8 "MemberOfNest"; // #14    
     class #26; // #15    
     NameAndType #7 #8; // #16    
@@ -51,11 +51,11 @@
     Utf8 "MissingMethod::priv_invoke"; // #19    
     class #30; // #20    
     NameAndType #31 #32; // #21    
-    Utf8 "TestInvokeSpecialErrors$MissingMethod"; // #22    
+    Utf8 "TestInvokeErrors$MissingMethod"; // #22    
     Utf8 "MissingMethod"; // #23    
     Utf8 "InnerClasses"; // #24    
     Utf8 "java/lang/Object"; // #25    
-    Utf8 "TestInvokeSpecialErrors"; // #26    
+    Utf8 "TestInvokeErrors"; // #26    
     Utf8 "java/lang/System"; // #27    
     Utf8 "out"; // #28    
     Utf8 "Ljava/io/PrintStream;"; // #29    
@@ -141,4 +141,4 @@
       }
     } // end InnerClasses
   } // Attributes
-} // end class TestInvokeSpecialErrors$MissingMethod
+} // end class TestInvokeErrors$MissingMethod
--- a/test/runtime/Nestmates/privateMethods/MissingMethodWithSuper.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/privateMethods/MissingMethodWithSuper.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,10 +21,10 @@
  * questions.
  */
 
-// Generated from the source in TestInvokeSpecialErrors.java
+// Generated from the source in TestInvokeErrors.java
 // with priv_invoke renamed to not_priv_invoke so it isn't found
 
-class TestInvokeSpecialErrors$MissingMethodWithSuper {
+class TestInvokeErrors$MissingMethodWithSuper {
   0xCAFEBABE;
   0; // minor version
   53; // version
@@ -42,7 +42,7 @@
     Utf8 "LineNumberTable"; // #10    
     Utf8 "not_priv_invoke"; // #11 - rename    
     Utf8 "SourceFile"; // #12    
-    Utf8 "TestInvokeSpecialErrors.java"; // #13    
+    Utf8 "TestInvokeErrors.java"; // #13    
     Utf8 "MemberOfNest"; // #14    
     class #27; // #15    
     NameAndType #7 #8; // #16    
@@ -51,12 +51,12 @@
     Utf8 "MissingMethodWithSuper::priv_invoke"; // #19    
     class #31; // #20    
     NameAndType #32 #33; // #21    
-    Utf8 "TestInvokeSpecialErrors$MissingMethodWithSuper"; // #22    
+    Utf8 "TestInvokeErrors$MissingMethodWithSuper"; // #22    
     Utf8 "MissingMethodWithSuper"; // #23    
     Utf8 "InnerClasses"; // #24    
-    Utf8 "TestInvokeSpecialErrors$Nested"; // #25    
+    Utf8 "TestInvokeErrors$Nested"; // #25    
     Utf8 "Nested"; // #26    
-    Utf8 "TestInvokeSpecialErrors"; // #27    
+    Utf8 "TestInvokeErrors"; // #27    
     Utf8 "java/lang/System"; // #28    
     Utf8 "out"; // #29    
     Utf8 "Ljava/io/PrintStream;"; // #30    
@@ -143,4 +143,4 @@
       }
     } // end InnerClasses
   } // Attributes
-} // end class TestInvokeSpecialErrors$MissingMethodWithSuper
+} // end class TestInvokeErrors$MissingMethodWithSuper
--- a/test/runtime/Nestmates/privateMethods/MissingNestTop.jcod	Fri Aug 11 11:32:17 2017 +0100
+++ b/test/runtime/Nestmates/privateMethods/MissingNestTop.jcod	Wed Aug 30 02:37:37 2017 -0400
@@ -21,10 +21,10 @@
  * questions.
  */
 
-// Generated from the source in TestInvokeSpecialErrors.java
+// Generated from the source in TestInvokeErrors.java
 // with MemberOfNest referring to non-existent class: NoSuchClass
 
-class TestInvokeSpecialErrors$MissingNestTop {
+class TestInvokeErrors$MissingNestTop {
   0xCAFEBABE;
   0; // minor version
   53; // version
@@ -42,7 +42,7 @@
     Utf8 "LineNumberTable"; // #10    
     Utf8 "priv_invoke"; // #11    
     Utf8 "SourceFile"; // #12    
-    Utf8 "TestInvokeSpecialErrors.java"; // #13    
+    Utf8 "TestInvokeErrors.java"; // #13    
     Utf8 "MemberOfNest"; // #14    
     class #26; // #15    
     NameAndType #7 #8; // #16    
@@ -51,11 +51,11 @@
     Utf8 "MissingNestTop::priv_invoke"; // #19    
     class #30; // #20    
     NameAndType #31 #32; // #21    
-    Utf8 "TestInvokeSpecialErrors$MissingNestTop"; // #22    
+    Utf8 "TestInvokeErrors$MissingNestTop"; // #22    
     Utf8 "MissingNestTop"; // #23    
     Utf8 "InnerClasses"; // #24    
     Utf8 "java/lang/Object"; // #25    
-    Utf8 "TestInvokeSpecialErrors"; // #26    
+    Utf8 "TestInvokeErrors"; // #26    
     Utf8 "java/lang/System"; // #27    
     Utf8 "out"; // #28    
     Utf8 "Ljava/io/PrintStream;"; // #29    
@@ -143,4 +143,4 @@
       }
     } // end InnerClasses
   } // Attributes
-} // end class TestInvokeSpecialErrors$MissingNestTop
+} // end class TestInvokeErrors$MissingNestTop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/privateMethods/TestInvoke.java	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,156 @@
+/*
+ * 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 8046171
+ * @summary Test access to private methods between nestmates and nest-top
+ *          using different flavours of named nested types
+ * @compile -XDdisablePrivateAccessors TestInvoke.java
+ * @run main TestInvoke
+ */
+
+public class TestInvoke {
+
+    // Private method of nest-top for nestmates to access
+    private void priv_invoke() {
+        System.out.println("TestInvoke::priv_invoke");
+    }
+
+    // public constructor so we aren't relying on private access
+    public TestInvoke() {}
+
+    // Methods that will access private methods of nestmates
+
+    void access_priv(TestInvoke o) {
+        o.priv_invoke();
+    }
+    void access_priv(InnerNested o) {
+        o.priv_invoke();
+    }
+    void access_priv(StaticNested o) {
+        o.priv_invoke();
+    }
+    void access_priv(StaticIface o) {
+        o.priv_invoke();
+    }
+
+    // The various nestmates
+
+    static interface StaticIface {
+
+        private void priv_invoke() {
+            System.out.println("StaticIface::priv_invoke");
+        }
+
+        // Methods that will access private methods of nestmates
+
+        default void access_priv(TestInvoke o) {
+            o.priv_invoke();
+        }
+        default void access_priv(InnerNested o) {
+            o.priv_invoke();
+        }
+        default void access_priv(StaticNested o) {
+            o.priv_invoke();
+        }
+        default void access_priv(StaticIface o) {
+            o.priv_invoke();
+        }
+    }
+
+    static class StaticNested {
+
+        private void priv_invoke() {
+            System.out.println("StaticNested::priv_invoke");
+        }
+
+        // public constructor so we aren't relying on private access
+        public StaticNested() {}
+
+        // Methods that will access private methods of nestmates
+
+        void access_priv(TestInvoke o) {
+            o.priv_invoke();
+        }
+        void access_priv(InnerNested o) {
+            o.priv_invoke();
+        }
+        void access_priv(StaticNested o) {
+            o.priv_invoke();
+        }
+        void access_priv(StaticIface o) {
+            o.priv_invoke();
+        }
+    }
+
+    class InnerNested {
+
+        private void priv_invoke() {
+            System.out.println("InnerNested::priv_invoke");
+        }
+
+        // public constructor so we aren't relying on private access
+        public InnerNested() {}
+
+        void access_priv(TestInvoke o) {
+            o.priv_invoke();
+        }
+        void access_priv(InnerNested o) {
+            o.priv_invoke();
+        }
+        void access_priv(StaticNested o) {
+            o.priv_invoke();
+        }
+        void access_priv(StaticIface o) {
+            o.priv_invoke();
+        }
+    }
+
+    public static void main(String[] args) {
+        TestInvoke o = new TestInvoke();
+        StaticNested s = new StaticNested();
+        InnerNested i = o.new InnerNested();
+        StaticIface intf = new StaticIface() {};
+
+        o.access_priv(new TestInvoke());
+        o.access_priv(i);
+        o.access_priv(s);
+        o.access_priv(intf);
+
+        s.access_priv(o);
+        s.access_priv(i);
+        s.access_priv(new StaticNested());
+        s.access_priv(intf);
+
+        i.access_priv(o);
+        i.access_priv(o.new InnerNested());
+        i.access_priv(s);
+        i.access_priv(intf);
+
+        intf.access_priv(o);
+        intf.access_priv(i);
+        intf.access_priv(s);
+        intf.access_priv(new StaticIface(){});
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/privateMethods/TestInvokeErrors.java	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,119 @@
+/*
+ * 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 8046171
+ * @summary Setup nestmate calls to private methods then use
+ *          modified jcod classes to introduce errors. Test with
+ *          and without verification enabled
+ * @compile -XDdisablePrivateAccessors TestInvokeErrors.java
+ * @compile MissingMethod.jcod
+ *          MissingMethodWithSuper.jcod
+ *          MissingNestTop.jcod
+ * @run main TestInvokeErrors true
+ * @run main/othervm -Xverify:none TestInvokeErrors false
+ */
+
+public class TestInvokeErrors {
+
+    static class Nested {
+        private void priv_invoke() {
+            System.out.println("Nested::priv_invoke");
+        }
+    }
+
+    static class MissingMethod {
+        // jcod version will rename this method to not_priv_invoke
+        private void priv_invoke() {
+            System.out.println("MissingMethod::priv_invoke");
+        }
+    }
+
+    static class MissingMethodWithSuper extends Nested {
+        // jcod version will rename this method to not_priv_invoke
+        private void priv_invoke() {
+            System.out.println("MissingMethodWithSuper::priv_invoke");
+        }
+    }
+
+    static class MissingNestTop {
+        // jcod version will change MemberOfNest to a non-existent class
+        private void priv_invoke() {
+            System.out.println("MissingNestTop::priv_invoke");
+        }
+    }
+
+    // Helper class adds a level of indirection to avoid the main class
+    // failing verification if these tests are written directly in main.
+    // That can only happen if using invokespecial for nestmate invocation.
+    static class Helper {
+        static void doTest() {
+            try {
+                MissingNestTop m = new MissingNestTop();
+                m.priv_invoke();
+                throw new Error("Unexpected success invoking MissingNestTop.priv_invoke");
+            }
+            catch (NoClassDefFoundError ncdfe) {
+                System.out.println("Got expected exception:" + ncdfe);
+            }
+        }
+    }
+
+    public static void main(String[] args) throws Throwable {
+        // some errors change depending on whether they are caught by the
+        // verifier first
+        boolean verifying = Boolean.parseBoolean(args[0]);
+        System.out.println("Verification is " +
+                           (verifying ? "enabled" : "disabled"));
+
+        try {
+            MissingMethod m = new MissingMethod();
+            m.priv_invoke();
+            throw new Error("Unexpected success invoking MissingMethod.priv_invoke");
+        }
+        catch (NoSuchMethodError nsme) {
+            System.out.println("Got expected exception:" + nsme);
+        }
+
+        try {
+            MissingMethodWithSuper m = new MissingMethodWithSuper();
+            m.priv_invoke();
+            throw new Error("Unexpected success invoking MissingMethodWithSuper.priv_invoke");
+        }
+        catch (NoSuchMethodError nsme) {
+            System.out.println("Got expected exception:" + nsme);
+        }
+
+        // Verification of Helper will trigger the nestmate access check failure
+        try {
+            Helper.doTest();
+        }
+        catch (NoClassDefFoundError ncdfe) {
+            if (verifying)
+                System.out.println("Got expected exception:" + ncdfe);
+            else
+                throw new Error("Unexpected error loading Helper class with verification disabled");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/Nestmates/privateMethods/TestInvokeHierarchy.java	Wed Aug 30 02:37:37 2017 -0400
@@ -0,0 +1,177 @@
+/*
+ * 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 8046171
+ * @summary Test access to private methods between nestmates where there
+ *          is an inheritance hierarchy and we invoke private methods that
+ *          exist in specific classes in the hierarchy.
+ * @compile -XDdisablePrivateAccessors TestInvokeHierarchy.java
+ * @compile ExternalSuper.jcod ExternalSub.jcod
+ * @run main TestInvokeHierarchy
+ */
+
+public class TestInvokeHierarchy {
+
+    static class NestedA extends ExternalSuper {
+        static final String ID =  "NestedA::priv_invoke";
+        private String priv_invoke() {
+            return ID;
+        }
+        static void checkA(NestedA a) throws Throwable {
+            verifyEquals(a.priv_invoke(), NestedA.ID);
+        }
+    }
+
+    static class NestedB extends NestedA {
+        static final String ID =  "NestedB::priv_invoke";
+        private String priv_invoke() {
+            return ID;
+        }
+        static void checkA(NestedA a) throws Throwable {
+            verifyEquals(a.priv_invoke(), NestedA.ID);
+        }
+    }
+
+    static class NestedC extends NestedB {
+        static final String ID =  "NestedC::priv_invoke";
+        private String priv_invoke() {
+            return ID;
+        }
+        static void checkA(NestedA a) throws Throwable {
+            verifyEquals(a.priv_invoke(), NestedA.ID);
+        }
+    }
+
+    static void checkA(NestedA a) throws Throwable {
+        verifyEquals(a.priv_invoke(), NestedA.ID);
+    }
+
+    static void checkB(NestedB b) throws Throwable {
+        verifyEquals(b.priv_invoke(), NestedB.ID);
+    }
+
+    static void checkC(NestedC c) throws Throwable {
+        verifyEquals(c.priv_invoke(), NestedC.ID);
+    }
+
+
+    // Access to private members of classes outside the nest is
+    // not permitted. These tests should throw IllegalAccessError
+    // at runtime. To allow them to compile the classes below are
+    // defined with public members. We then replace those class files
+    // with jcod variants that make the member private again.
+
+    static void checkExternalSuper(ExternalSuper s) throws Throwable {
+        try {
+            String str = s.priv_invoke_s();
+            throw new Error("Unexpected access to ExternalSuper.priv_invoke_s");
+        }
+        catch (IllegalAccessError iae) {
+            System.out.println("Got expected exception accessing ExternalSuper.priv_invoke_s:" + iae);
+        }
+    }
+
+    static void checkExternalSub(ExternalSub s) throws Throwable {
+        try {
+            String str = s.priv_invoke();
+            throw new Error("Unexpected access to ExternalSub.priv_invoke");
+        }
+        catch (IllegalAccessError iae) {
+            System.out.println("Got expected exception accessing ExternalSub.priv_invoke:" + iae);
+        }
+    }
+
+    static void verifyEquals(String actual, String expected) {
+        if (!actual.equals(expected)) {
+            throw new Error("Expected " + expected + " but got " + actual);
+        }
+        System.out.println("Check passed for " + expected);
+    }
+
+    public static void main(String[] args) throws Throwable {
+        NestedA a = new NestedA();
+        NestedB b = new NestedB();
+        NestedC c = new NestedC();
+        ExternalSub sub = new ExternalSub();
+        ExternalSuper sup = new ExternalSuper();
+
+        checkExternalSuper(sup);
+        checkExternalSuper(a);
+        checkExternalSuper(b);
+        checkExternalSuper(c);
+        checkExternalSuper(sub);
+
+        checkA(a);
+        checkA(b);
+        checkA(c);
+        checkA(sub);
+
+        NestedA.checkA(a);
+        NestedA.checkA(b);
+        NestedA.checkA(c);
+        NestedA.checkA(sub);
+
+        NestedB.checkA(a);
+        NestedB.checkA(b);
+        NestedB.checkA(c);
+        NestedB.checkA(sub);
+
+        NestedC.checkA(a);
+        NestedC.checkA(b);
+        NestedC.checkA(c);
+        NestedC.checkA(sub);
+
+        checkB(b);
+        checkB(c);
+        checkB(sub);
+
+        checkC(c);
+        checkC(sub);
+
+        checkExternalSub(sub);
+    }
+}
+
+// Classes that are not part of the nest.
+// Being non-public allows us to declare them in this file.
+// The priv_invoke* member is public to allow this file to compile, but
+// the jcod files change it back to private.
+
+class ExternalSuper {
+    static final String ID =  "ExternalSuper::priv_invoke_s";
+    // Can't call this priv_invoke as subclasses make it less accessible
+    // which is not allowed.
+    public String priv_invoke_s() {
+        return ID;
+    }
+}
+
+
+class ExternalSub extends TestInvokeHierarchy.NestedC {
+    static final String ID =  "ExternalSub::priv_invoke";
+    public String priv_invoke() {
+        return ID;
+    }
+}
--- a/test/runtime/Nestmates/privateMethods/TestInvokeSpecial.java	Fri Aug 11 11:32:17 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
- * 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 8046171
- * @summary Test access to private methods between nestmates and nest-top
- *          using different flavours of named nested types that will
- *          generate invokespecial for the calls
- * @compile -XDdisablePrivateAccessors TestInvokeSpecial.java
- * @run main TestInvokeSpecial
- */
-
-public class TestInvokeSpecial {
-
-    // Private method of nest-top for nestmates to access
-    private void priv_invoke() {
-        System.out.println("TestInvokeSpecial::priv_invoke");
-    }
-
-    // public constructor so we aren't relying on private access
-    public TestInvokeSpecial() {}
-
-    // Methods that will access private methods of nestmates
-
-    void access_priv(TestInvokeSpecial o) {
-        o.priv_invoke();
-    }
-    void access_priv(InnerNested o) {
-        o.priv_invoke();
-    }
-    void access_priv(StaticNested o) {
-        o.priv_invoke();
-    }
-    void access_priv(StaticIface o) {
-        o.priv_invoke();
-    }
-
-    // The various nestmates
-
-    static interface StaticIface {
-
-        private void priv_invoke() {
-            System.out.println("StaticIface::priv_invoke");
-        }
-
-        // Methods that will access private methods of nestmates
-
-        default void access_priv(TestInvokeSpecial o) {
-            o.priv_invoke();
-        }
-        default void access_priv(InnerNested o) {
-            o.priv_invoke();
-        }
-        default void access_priv(StaticNested o) {
-            o.priv_invoke();
-        }
-        default void access_priv(StaticIface o) {
-            o.priv_invoke();
-        }
-    }
-
-    static class StaticNested {
-
-        private void priv_invoke() {
-            System.out.println("StaticNested::priv_invoke");
-        }
-
-        // public constructor so we aren't relying on private access
-        public StaticNested() {}
-
-        // Methods that will access private methods of nestmates
-
-        void access_priv(TestInvokeSpecial o) {
-            o.priv_invoke();
-        }
-        void access_priv(InnerNested o) {
-            o.priv_invoke();
-        }
-        void access_priv(StaticNested o) {
-            o.priv_invoke();
-        }
-        void access_priv(StaticIface o) {
-            o.priv_invoke();
-        }
-    }
-
-    class InnerNested {
-
-        private void priv_invoke() {
-            System.out.println("InnerNested::priv_invoke");
-        }
-
-        // public constructor so we aren't relying on private access
-        public InnerNested() {}
-
-        void access_priv(TestInvokeSpecial o) {
-            o.priv_invoke();
-        }
-        void access_priv(InnerNested o) {
-            o.priv_invoke();
-        }
-        void access_priv(StaticNested o) {
-            o.priv_invoke();
-        }
-        void access_priv(StaticIface o) {
-            o.priv_invoke();
-        }
-    }
-
-    public static void main(String[] args) {
-        TestInvokeSpecial o = new TestInvokeSpecial();
-        StaticNested s = new StaticNested();
-        InnerNested i = o.new InnerNested();
-        StaticIface intf = new StaticIface() {};
-
-        o.access_priv(new TestInvokeSpecial());
-        o.access_priv(i);
-        o.access_priv(s);
-        o.access_priv(intf);
-
-        s.access_priv(o);
-        s.access_priv(i);
-        s.access_priv(new StaticNested());
-        s.access_priv(intf);
-
-        i.access_priv(o);
-        i.access_priv(o.new InnerNested());
-        i.access_priv(s);
-        i.access_priv(intf);
-
-        intf.access_priv(o);
-        intf.access_priv(i);
-        intf.access_priv(s);
-        intf.access_priv(new StaticIface(){});
-    }
-}
--- a/test/runtime/Nestmates/privateMethods/TestInvokeSpecialErrors.java	Fri Aug 11 11:32:17 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/*
- * 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 8046171
- * @summary Setup invokespecial-based nestmate call to private methods
- *          then use modified jcod classes to introduce errors. Test with
- *          and without verification enabled 
- * @compile -XDdisablePrivateAccessors TestInvokeSpecialErrors.java
- * @compile MissingMethod.jcod
- *          MissingMethodWithSuper.jcod
- *          MissingNestTop.jcod
- * @run main TestInvokeSpecialErrors true
- * @run main/othervm -Xverify:none TestInvokeSpecialErrors false
- */
-
-public class TestInvokeSpecialErrors {
-
-    static class Nested {
-        private void priv_invoke() {
-            System.out.println("Nested::priv_invoke");
-        }
-    }
-
-    static class MissingMethod {
-        // jcod version will rename this method to not_priv_invoke
-        private void priv_invoke() {
-            System.out.println("MissingMethod::priv_invoke");
-        }
-    }
-
-    static class MissingMethodWithSuper extends Nested {
-        // jcod version will rename this method to not_priv_invoke
-        private void priv_invoke() {
-            System.out.println("MissingMethodWithSuper::priv_invoke");
-        }
-    }
-
-    static class MissingNestTop {
-        // jcod version will change MemberOfNest to a non-existent class
-        private void priv_invoke() {
-            System.out.println("MissingNestTop::priv_invoke");
-        }
-    }
-    static class Helper {
-        // If these tests are directly in main() they trigger failures
-        // loading the main class much earlier than runtime.
-        static void doTest(boolean verifying) {
-            if (verifying)
-                throw new Error("Unexpected load of Helper class with verification enabled");
-            try {
-                MissingNestTop m = new MissingNestTop();
-                m.priv_invoke();
-                throw new Error("Unexpected success invoking MissingNestTop.priv_invoke");
-            }
-            catch (NoClassDefFoundError ncdfe) {
-                System.out.println("Got expected exception:" + ncdfe);
-            }
-        }
-    }
-
-    public static void main(String[] args) throws Throwable {
-        // some errors change depending on whether they are caught by the
-        // verifier first
-        boolean verifying = Boolean.parseBoolean(args[0]);
-        System.out.println("Verification is " + 
-                           (verifying ? "enabled" : "disabled"));
-
-        try {
-            MissingMethod m = new MissingMethod();
-            m.priv_invoke();
-            throw new Error("Unexpected success invoking MissingMethod.priv_invoke");
-        }
-        catch (NoSuchMethodError nsme) {
-            System.out.println("Got expected exception:" + nsme);
-        }
-
-        try {
-            MissingMethodWithSuper m = new MissingMethodWithSuper();
-            m.priv_invoke();
-            throw new Error("Unexpected success invoking MissingMethodWithSuper.priv_invoke");
-        }
-        catch (NoSuchMethodError nsme) {
-            System.out.println("Got expected exception:" + nsme);
-        }
-
-        // with verification enabled we can't even reference Helper
-        try {
-            Helper.doTest(verifying);
-        } 
-        catch (NoClassDefFoundError ncdfe) {
-            if (verifying)
-                System.out.println("Got expected exception:" + ncdfe);
-            else
-                throw new Error("Unexpected error loading Helper class with verification disabled");
-        }
-    }
-}
--- a/test/runtime/Nestmates/privateMethods/TestInvokeSpecialHierarchy.java	Fri Aug 11 11:32:17 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/*
- * 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 8046171
- * @summary Test access to private methods between nestmates where there
- *          is an inheritance hierarchy and we use invokespecial to invoke
- *          private methods that exist in specific classes in the hierarchy.
- * @compile -XDdisablePrivateAccessors TestInvokeSpecialHierarchy.java
- * @compile ExternalSuper.jcod ExternalSub.jcod
- * @run main TestInvokeSpecialHierarchy
- */
-
-public class TestInvokeSpecialHierarchy {
-
-    static class NestedA extends ExternalSuper {
-        static final String ID =  "NestedA::priv_invoke";
-        private String priv_invoke() {
-            return ID;
-        }
-        static void checkA(NestedA a) throws Throwable {
-            verifyEquals(a.priv_invoke(), NestedA.ID);
-        }
-    }
-
-    static class NestedB extends NestedA {
-        static final String ID =  "NestedB::priv_invoke";
-        private String priv_invoke() {
-            return ID;
-        }
-        static void checkA(NestedA a) throws Throwable {
-            verifyEquals(a.priv_invoke(), NestedA.ID);
-        }
-    }
-
-    static class NestedC extends NestedB {
-        static final String ID =  "NestedC::priv_invoke";
-        private String priv_invoke() {
-            return ID;
-        }
-        static void checkA(NestedA a) throws Throwable {
-            verifyEquals(a.priv_invoke(), NestedA.ID);
-        }
-    }
-
-    static void checkA(NestedA a) throws Throwable {
-        verifyEquals(a.priv_invoke(), NestedA.ID);
-    }
-
-    static void checkB(NestedB b) throws Throwable {
-        verifyEquals(b.priv_invoke(), NestedB.ID);
-    }
-
-    static void checkC(NestedC c) throws Throwable {
-        verifyEquals(c.priv_invoke(), NestedC.ID);
-    }
-
-
-    // Access to private members of classes outside the nest is
-    // not permitted. These tests should throw IllegalAccessError
-    // at runtime. To allow them to compile the classes below are
-    // defined with public members. We then replace those class files
-    // with jcod variants that make the member private again.
-
-    static void checkExternalSuper(ExternalSuper s) throws Throwable {
-        try {
-            String str = s.priv_invoke_s();
-            throw new Error("Unexpected access to ExternalSuper.priv_invoke_s");
-        }
-        catch (IllegalAccessError iae) {
-            System.out.println("Got expected exception accessing ExternalSuper.priv_invoke_s:" + iae);
-        }
-    }
-
-    static void checkExternalSub(ExternalSub s) throws Throwable {
-        try {
-            String str = s.priv_invoke();
-            throw new Error("Unexpected access to ExternalSub.priv_invoke");
-        }
-        catch (IllegalAccessError iae) {
-            System.out.println("Got expected exception accessing ExternalSub.priv_invoke:" + iae);
-        }
-    }
-
-    static void verifyEquals(String actual, String expected) {
-        if (!actual.equals(expected)) {
-            throw new Error("Expected " + expected + " but got " + actual);
-        }
-        System.out.println("Check passed for " + expected);
-    }
-
-    public static void main(String[] args) throws Throwable {
-        NestedA a = new NestedA();
-        NestedB b = new NestedB();
-        NestedC c = new NestedC();
-        ExternalSub sub = new ExternalSub();
-        ExternalSuper sup = new ExternalSuper();
-
-        checkExternalSuper(sup);
-        checkExternalSuper(a);
-        checkExternalSuper(b);
-        checkExternalSuper(c);
-        checkExternalSuper(sub);
-
-        checkA(a);
-        checkA(b);
-        checkA(c);
-        checkA(sub);
-
-        NestedA.checkA(a);
-        NestedA.checkA(b);
-        NestedA.checkA(c);
-        NestedA.checkA(sub);
-
-        NestedB.checkA(a);
-        NestedB.checkA(b);
-        NestedB.checkA(c);
-        NestedB.checkA(sub);
-
-        NestedC.checkA(a);
-        NestedC.checkA(b);
-        NestedC.checkA(c);
-        NestedC.checkA(sub);
-
-        checkB(b);
-        checkB(c);
-        checkB(sub);
-
-        checkC(c);
-        checkC(sub);
-
-        checkExternalSub(sub);
-    }
-}
-
-// Classes that are not part of the nest
-// Being non-public allows us to declare them in this file.
-// The priv_invoke* member is public to allow this file to compile, but
-// the jcod files change it back to private.
-
-class ExternalSuper {
-    static final String ID =  "ExternalSuper::priv_invoke_s";
-    // Can't call this priv_invoke as subclasses make it less accessible
-    // which is not allowed.
-    public String priv_invoke_s() {
-        return ID;
-    }
-}
-
-
-class ExternalSub extends TestInvokeSpecialHierarchy.NestedC {
-    static final String ID =  "ExternalSub::priv_invoke";
-    public String priv_invoke() {
-        return ID;
-    }
-}