8208999: Some use of Klass* should be replaced by InstanceKlass*
authoriklam
Tue, 07 Aug 2018 15:45:07 -0700
changeset 51329 9c68699bebe5
parent 51328 fad2334b2906
child 51330 edd33b9946ca
8208999: Some use of Klass* should be replaced by InstanceKlass* Summary: Klass::java_super() => InstanceKlass*; InstanceKlass::{local,transitive}_interfaces() => Array<InstanceKlass*>* Reviewed-by: coleenp, hseigel
src/hotspot/share/classfile/classFileParser.cpp
src/hotspot/share/classfile/classFileParser.hpp
src/hotspot/share/classfile/systemDictionary.cpp
src/hotspot/share/classfile/systemDictionary.hpp
src/hotspot/share/classfile/systemDictionaryShared.cpp
src/hotspot/share/classfile/systemDictionaryShared.hpp
src/hotspot/share/classfile/verifier.cpp
src/hotspot/share/code/dependencies.hpp
src/hotspot/share/memory/heapInspection.cpp
src/hotspot/share/memory/universe.cpp
src/hotspot/share/memory/universe.hpp
src/hotspot/share/oops/arrayKlass.cpp
src/hotspot/share/oops/arrayKlass.hpp
src/hotspot/share/oops/cpCache.cpp
src/hotspot/share/oops/instanceKlass.cpp
src/hotspot/share/oops/instanceKlass.hpp
src/hotspot/share/oops/klass.cpp
src/hotspot/share/oops/klass.hpp
src/hotspot/share/oops/klassVtable.cpp
src/hotspot/share/oops/klassVtable.hpp
src/hotspot/share/oops/objArrayKlass.cpp
src/hotspot/share/oops/objArrayKlass.hpp
src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp
src/hotspot/share/prims/jvmtiEnv.cpp
src/hotspot/share/prims/jvmtiImpl.cpp
src/hotspot/share/prims/jvmtiRedefineClasses.cpp
src/hotspot/share/prims/jvmtiTagMap.cpp
src/hotspot/share/prims/methodHandles.cpp
src/hotspot/share/runtime/reflectionUtils.cpp
src/hotspot/share/runtime/reflectionUtils.hpp
src/hotspot/share/runtime/vmStructs.cpp
src/hotspot/share/services/heapDumper.cpp
--- a/src/hotspot/share/classfile/classFileParser.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -922,10 +922,10 @@
   assert(has_nonstatic_concrete_methods != NULL, "invariant");
 
   if (itfs_len == 0) {
-    _local_interfaces = Universe::the_empty_klass_array();
+    _local_interfaces = Universe::the_empty_instance_klass_array();
   } else {
     assert(itfs_len > 0, "only called for len>0");
-    _local_interfaces = MetadataFactory::new_array<Klass*>(_loader_data, itfs_len, NULL, CHECK);
+    _local_interfaces = MetadataFactory::new_array<InstanceKlass*>(_loader_data, itfs_len, NULL, CHECK);
 
     int index;
     for (index = 0; index < itfs_len; index++) {
@@ -966,7 +966,7 @@
       if (InstanceKlass::cast(interf)->has_nonstatic_concrete_methods()) {
         *has_nonstatic_concrete_methods = true;
       }
-      _local_interfaces->at_put(index, interf);
+      _local_interfaces->at_put(index, InstanceKlass::cast(interf));
     }
 
     if (!_need_verify || itfs_len <= 1) {
@@ -984,8 +984,8 @@
     {
       debug_only(NoSafepointVerifier nsv;)
       for (index = 0; index < itfs_len; index++) {
-        const Klass* const k = _local_interfaces->at(index);
-        name = InstanceKlass::cast(k)->name();
+        const InstanceKlass* const k = _local_interfaces->at(index);
+        name = k->name();
         // If no duplicates, add (name, NULL) in hashtable interface_names.
         if (!put_after_lookup(name, NULL, interface_names)) {
           dup = true;
@@ -4496,7 +4496,7 @@
     }
 
     // add super interface dependencies
-    const Array<Klass*>* const local_interfaces = defined_klass->local_interfaces();
+    const Array<InstanceKlass*>* const local_interfaces = defined_klass->local_interfaces();
     if (local_interfaces != NULL) {
       const int length = local_interfaces->length();
       for (int i = 0; i < length; i++) {
@@ -4508,21 +4508,21 @@
 
 // utility methods for appending an array with check for duplicates
 
-static void append_interfaces(GrowableArray<Klass*>* result,
-                              const Array<Klass*>* const ifs) {
+static void append_interfaces(GrowableArray<InstanceKlass*>* result,
+                              const Array<InstanceKlass*>* const ifs) {
   // iterate over new interfaces
   for (int i = 0; i < ifs->length(); i++) {
-    Klass* const e = ifs->at(i);
-    assert(e->is_klass() && InstanceKlass::cast(e)->is_interface(), "just checking");
+    InstanceKlass* const e = ifs->at(i);
+    assert(e->is_klass() && e->is_interface(), "just checking");
     // add new interface
     result->append_if_missing(e);
   }
 }
 
-static Array<Klass*>* compute_transitive_interfaces(const InstanceKlass* super,
-                                                    Array<Klass*>* local_ifs,
-                                                    ClassLoaderData* loader_data,
-                                                    TRAPS) {
+static Array<InstanceKlass*>* compute_transitive_interfaces(const InstanceKlass* super,
+                                                            Array<InstanceKlass*>* local_ifs,
+                                                            ClassLoaderData* loader_data,
+                                                            TRAPS) {
   assert(local_ifs != NULL, "invariant");
   assert(loader_data != NULL, "invariant");
 
@@ -4537,15 +4537,15 @@
   // Add local interfaces' super interfaces
   const int local_size = local_ifs->length();
   for (int i = 0; i < local_size; i++) {
-    Klass* const l = local_ifs->at(i);
-    max_transitive_size += InstanceKlass::cast(l)->transitive_interfaces()->length();
+    InstanceKlass* const l = local_ifs->at(i);
+    max_transitive_size += l->transitive_interfaces()->length();
   }
   // Finally add local interfaces
   max_transitive_size += local_size;
   // Construct array
   if (max_transitive_size == 0) {
     // no interfaces, use canonicalized array
-    return Universe::the_empty_klass_array();
+    return Universe::the_empty_instance_klass_array();
   } else if (max_transitive_size == super_size) {
     // no new local interfaces added, share superklass' transitive interface array
     return super->transitive_interfaces();
@@ -4554,7 +4554,7 @@
     return local_ifs;
   } else {
     ResourceMark rm;
-    GrowableArray<Klass*>* const result = new GrowableArray<Klass*>(max_transitive_size);
+    GrowableArray<InstanceKlass*>* const result = new GrowableArray<InstanceKlass*>(max_transitive_size);
 
     // Copy down from superclass
     if (super != NULL) {
@@ -4563,8 +4563,8 @@
 
     // Copy down from local interfaces' superinterfaces
     for (int i = 0; i < local_size; i++) {
-      Klass* const l = local_ifs->at(i);
-      append_interfaces(result, InstanceKlass::cast(l)->transitive_interfaces());
+      InstanceKlass* const l = local_ifs->at(i);
+      append_interfaces(result, l->transitive_interfaces());
     }
     // Finally add local interfaces
     append_interfaces(result, local_ifs);
@@ -4572,10 +4572,10 @@
     // length will be less than the max_transitive_size if duplicates were removed
     const int length = result->length();
     assert(length <= max_transitive_size, "just checking");
-    Array<Klass*>* const new_result =
-      MetadataFactory::new_array<Klass*>(loader_data, length, CHECK_NULL);
+    Array<InstanceKlass*>* const new_result =
+      MetadataFactory::new_array<InstanceKlass*>(loader_data, length, CHECK_NULL);
     for (int i = 0; i < length; i++) {
-      Klass* const e = result->at(i);
+      InstanceKlass* const e = result->at(i);
       assert(e != NULL, "just checking");
       new_result->at_put(i, e);
     }
@@ -4643,17 +4643,17 @@
 
 static void check_super_interface_access(const InstanceKlass* this_klass, TRAPS) {
   assert(this_klass != NULL, "invariant");
-  const Array<Klass*>* const local_interfaces = this_klass->local_interfaces();
+  const Array<InstanceKlass*>* const local_interfaces = this_klass->local_interfaces();
   const int lng = local_interfaces->length();
   for (int i = lng - 1; i >= 0; i--) {
-    Klass* const k = local_interfaces->at(i);
+    InstanceKlass* const k = local_interfaces->at(i);
     assert (k != NULL && k->is_interface(), "invalid interface");
     Reflection::VerifyClassAccessResults vca_result =
-      Reflection::verify_class_access(this_klass, InstanceKlass::cast(k), false);
+      Reflection::verify_class_access(this_klass, k, false);
     if (vca_result != Reflection::ACCESS_OK) {
       ResourceMark rm(THREAD);
       char* msg = Reflection::verify_class_access_msg(this_klass,
-                                                      InstanceKlass::cast(k),
+                                                      k,
                                                       vca_result);
       if (msg == NULL) {
         bool same_module = (this_klass->module() == k->module());
@@ -5735,11 +5735,11 @@
                    ik->java_super()->external_name());
       }
       // print out each of the interface classes referred to by this class.
-      const Array<Klass*>* const local_interfaces = ik->local_interfaces();
+      const Array<InstanceKlass*>* const local_interfaces = ik->local_interfaces();
       if (local_interfaces != NULL) {
         const int length = local_interfaces->length();
         for (int i = 0; i < length; i++) {
-          const Klass* const k = local_interfaces->at(i);
+          const InstanceKlass* const k = local_interfaces->at(i);
           const char * to = k->external_name();
           log_debug(class, resolve)("%s %s (interface)", from, to);
         }
@@ -6272,7 +6272,7 @@
   assert(_loader_data != NULL, "invariant");
 
   if (_class_name == vmSymbols::java_lang_Object()) {
-    check_property(_local_interfaces == Universe::the_empty_klass_array(),
+    check_property(_local_interfaces == Universe::the_empty_instance_klass_array(),
                    "java.lang.Object cannot implement an interface in class file %s",
                    CHECK);
   }
--- a/src/hotspot/share/classfile/classFileParser.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/classfile/classFileParser.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -99,8 +99,8 @@
   Array<u2>* _inner_classes;
   Array<u2>* _nest_members;
   u2 _nest_host;
-  Array<Klass*>* _local_interfaces;
-  Array<Klass*>* _transitive_interfaces;
+  Array<InstanceKlass*>* _local_interfaces;
+  Array<InstanceKlass*>* _transitive_interfaces;
   Annotations* _combined_annotations;
   AnnotationArray* _annotations;
   AnnotationArray* _type_annotations;
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -242,12 +242,23 @@
 }
 
 
-// Forwards to resolve_instance_class_or_null
+// Forwards to resolve_array_class_or_null or resolve_instance_class_or_null
 
 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
   if (FieldType::is_array(class_name)) {
     return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
-  } else if (FieldType::is_obj(class_name)) {
+  } else {
+    return resolve_instance_class_or_null_helper(class_name, class_loader, protection_domain, THREAD);
+  }
+}
+
+// name may be in the form of "java/lang/Object" or "Ljava/lang/Object;"
+InstanceKlass* SystemDictionary::resolve_instance_class_or_null_helper(Symbol* class_name,
+                                                                       Handle class_loader,
+                                                                       Handle protection_domain,
+                                                                       TRAPS) {
+  assert(class_name != NULL && !FieldType::is_array(class_name), "must be");
+  if (FieldType::is_obj(class_name)) {
     ResourceMark rm(THREAD);
     // Ignore wrapping L and ;.
     TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
@@ -330,17 +341,18 @@
 // placeholders()->find_and_add(PlaceholderTable::LOAD_SUPER),
 // you need to find_and_remove it before returning.
 // So be careful to not exit with a CHECK_ macro betweeen these calls.
-Klass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
-                                                 Symbol* class_name,
-                                                 Handle class_loader,
-                                                 Handle protection_domain,
-                                                 bool is_superclass,
-                                                 TRAPS) {
+InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
+                                                       Symbol* super_name,
+                                                       Handle class_loader,
+                                                       Handle protection_domain,
+                                                       bool is_superclass,
+                                                       TRAPS) {
+  assert(!FieldType::is_array(super_name), "invalid super class name");
 #if INCLUDE_CDS
   if (DumpSharedSpaces) {
     // Special processing for CDS dump time.
-    Klass* k = SystemDictionaryShared::dump_time_resolve_super_or_fail(child_name,
-        class_name, class_loader, protection_domain, is_superclass, CHECK_NULL);
+    InstanceKlass* k = SystemDictionaryShared::dump_time_resolve_super_or_fail(child_name,
+        super_name, class_loader, protection_domain, is_superclass, CHECK_NULL);
     if (k) {
       return k;
     }
@@ -372,18 +384,17 @@
   bool throw_circularity_error = false;
   {
     MutexLocker mu(SystemDictionary_lock, THREAD);
-    Klass* childk = find_class(d_hash, child_name, dictionary);
-    Klass* quicksuperk;
+    InstanceKlass* childk = find_class(d_hash, child_name, dictionary);
+    InstanceKlass* quicksuperk;
     // to support // loading: if child done loading, just return superclass
-    // if class_name, & class_loader don't match:
+    // if super_name, & class_loader don't match:
     // if initial define, SD update will give LinkageError
     // if redefine: compare_class_versions will give HIERARCHY_CHANGED
     // so we don't throw an exception here.
     // see: nsk redefclass014 & java.lang.instrument Instrument032
     if ((childk != NULL ) && (is_superclass) &&
-       ((quicksuperk = childk->super()) != NULL) &&
-
-         ((quicksuperk->name() == class_name) &&
+        ((quicksuperk = childk->java_super()) != NULL) &&
+         ((quicksuperk->name() == super_name) &&
             (oopDesc::equals(quicksuperk->class_loader(), class_loader())))) {
            return quicksuperk;
     } else {
@@ -394,7 +405,7 @@
     }
     if (!throw_circularity_error) {
       // Be careful not to exit resolve_super
-      PlaceholderEntry* newprobe = placeholders()->find_and_add(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, class_name, THREAD);
+      PlaceholderEntry* newprobe = placeholders()->find_and_add(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, super_name, THREAD);
     }
   }
   if (throw_circularity_error) {
@@ -403,12 +414,13 @@
   }
 
 // java.lang.Object should have been found above
-  assert(class_name != NULL, "null super class for resolving");
+  assert(super_name != NULL, "null super class for resolving");
   // Resolve the super class or interface, check results on return
-  Klass* superk = SystemDictionary::resolve_or_null(class_name,
-                                                    class_loader,
-                                                    protection_domain,
-                                                    THREAD);
+  InstanceKlass* superk =
+    SystemDictionary::resolve_instance_class_or_null_helper(super_name,
+                                                            class_loader,
+                                                            protection_domain,
+                                                            THREAD);
 
   // Clean up of placeholders moved so that each classloadAction registrar self-cleans up
   // It is no longer necessary to keep the placeholder table alive until update_dictionary
@@ -423,7 +435,11 @@
   }
   if (HAS_PENDING_EXCEPTION || superk == NULL) {
     // can null superk
-    superk = handle_resolution_exception(class_name, true, superk, THREAD);
+    Klass* k = handle_resolution_exception(super_name, true, superk, THREAD);
+    assert(k == NULL || k == superk, "must be");
+    if (k == NULL) {
+      superk = NULL;
+    }
   }
 
   return superk;
@@ -639,10 +655,12 @@
 // placeholders()->find_and_add(PlaceholderTable::LOAD_INSTANCE),
 // you need to find_and_remove it before returning.
 // So be careful to not exit with a CHECK_ macro betweeen these calls.
-Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
-                                                        Handle class_loader,
-                                                        Handle protection_domain,
-                                                        TRAPS) {
+//
+// name must be in the form of "java/lang/Object" -- cannot be "Ljava/lang/Object;"
+InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
+                                                                Handle class_loader,
+                                                                Handle protection_domain,
+                                                                TRAPS) {
   assert(name != NULL && !FieldType::is_array(name) &&
          !FieldType::is_obj(name), "invalid class name");
 
@@ -663,7 +681,7 @@
   // before we return a result we call out to java to check for valid protection domain
   // to allow returning the Klass* and add it to the pd_set if it is valid
   {
-    Klass* probe = dictionary->find(d_hash, name, protection_domain);
+    InstanceKlass* probe = dictionary->find(d_hash, name, protection_domain);
     if (probe != NULL) return probe;
   }
 
@@ -706,7 +724,7 @@
     MutexLocker mu(SystemDictionary_lock, THREAD);
     InstanceKlass* check = find_class(d_hash, name, dictionary);
     if (check != NULL) {
-      // Klass is already loaded, so just return it
+      // InstanceKlass is already loaded, so just return it
       class_has_been_loaded = true;
       k = check;
     } else {
@@ -877,7 +895,7 @@
   {
     ClassLoaderData* loader_data = k->class_loader_data();
     MutexLocker mu(SystemDictionary_lock, THREAD);
-    Klass* kk = find_class(name, loader_data);
+    InstanceKlass* kk = find_class(name, loader_data);
     assert(kk == k, "should be present in dictionary");
   }
 #endif
@@ -1308,11 +1326,11 @@
       }
     }
 
-    Array<Klass*>* interfaces = ik->local_interfaces();
+    Array<InstanceKlass*>* interfaces = ik->local_interfaces();
     int num_interfaces = interfaces->length();
     for (int index = 0; index < num_interfaces; index++) {
-      Klass* k = interfaces->at(index);
-      Symbol*  name  = k->name();
+      InstanceKlass* k = interfaces->at(index);
+      Symbol* name  = k->name();
       Klass* i = resolve_super_or_fail(class_name, name, class_loader, protection_domain, false, CHECK_NULL);
       if (k != i) {
         // The dynamically resolved interface class is not the same as the one we used during dump time,
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -280,12 +280,12 @@
   // Resolve a superclass or superinterface. Called from ClassFileParser,
   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
   // "child_name" is the class whose super class or interface is being resolved.
-  static Klass* resolve_super_or_fail(Symbol* child_name,
-                                      Symbol* class_name,
-                                      Handle class_loader,
-                                      Handle protection_domain,
-                                      bool is_superclass,
-                                      TRAPS);
+  static InstanceKlass* resolve_super_or_fail(Symbol* child_name,
+                                              Symbol* class_name,
+                                              Handle class_loader,
+                                              Handle protection_domain,
+                                              bool is_superclass,
+                                              TRAPS);
 
   // Parse new stream. This won't update the dictionary or
   // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
@@ -638,7 +638,11 @@
   static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
 
   // Basic loading operations
-  static Klass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
+  static InstanceKlass* resolve_instance_class_or_null_helper(Symbol* name,
+                                                              Handle class_loader,
+                                                              Handle protection_domain,
+                                                              TRAPS);
+  static InstanceKlass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   static Klass* resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
   static InstanceKlass* handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
   // Wait on SystemDictionary_lock; unlocks lockObject before
--- a/src/hotspot/share/classfile/systemDictionaryShared.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -505,9 +505,9 @@
 
       {
         MutexLocker mu(SystemDictionary_lock, THREAD);
-        Klass* check = find_class(d_hash, name, dictionary);
+        InstanceKlass* check = find_class(d_hash, name, dictionary);
         if (check != NULL) {
-          return InstanceKlass::cast(check);
+          return check;
         }
       }
 
@@ -524,10 +524,9 @@
                  Symbol* class_name, Handle class_loader, TRAPS) {
   assert(UseSharedSpaces, "must be");
   assert(shared_dictionary() != NULL, "already checked");
-  Klass* k = shared_dictionary()->find_class_for_builtin_loader(class_name);
+  InstanceKlass* ik = shared_dictionary()->find_class_for_builtin_loader(class_name);
 
-  if (k != NULL) {
-    InstanceKlass* ik = InstanceKlass::cast(k);
+  if (ik != NULL) {
     if ((ik->is_shared_app_class() &&
          SystemDictionary::is_system_class_loader(class_loader()))  ||
         (ik->is_shared_platform_class() &&
@@ -594,7 +593,7 @@
   }
 
   ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
-  Klass* k;
+  InstanceKlass* k;
 
   { // UNREGISTERED loader
     if (!shared_dictionary()->class_exists_for_unregistered_loader(class_name)) {
@@ -613,7 +612,7 @@
     return NULL;
   }
 
-  return acquire_class_for_current_thread(InstanceKlass::cast(k), class_loader,
+  return acquire_class_for_current_thread(k, class_loader,
                                           protection_domain, THREAD);
 }
 
@@ -672,7 +671,7 @@
 // java/lang/Object id: 0
 // Interface   id: 2 super: 0 source: cust.jar
 // ChildClass  id: 4 super: 0 interfaces: 2 source: cust.jar
-Klass* SystemDictionaryShared::dump_time_resolve_super_or_fail(
+InstanceKlass* SystemDictionaryShared::dump_time_resolve_super_or_fail(
     Symbol* child_name, Symbol* class_name, Handle class_loader,
     Handle protection_domain, bool is_superclass, TRAPS) {
 
@@ -700,14 +699,14 @@
 }
 
 struct SharedMiscInfo {
-  Klass* _klass;
+  InstanceKlass* _klass;
   int _clsfile_size;
   int _clsfile_crc32;
 };
 
 static GrowableArray<SharedMiscInfo>* misc_info_array = NULL;
 
-void SystemDictionaryShared::set_shared_class_misc_info(Klass* k, ClassFileStream* cfs) {
+void SystemDictionaryShared::set_shared_class_misc_info(InstanceKlass* k, ClassFileStream* cfs) {
   assert(DumpSharedSpaces, "only when dumping");
   int clsfile_size  = cfs->length();
   int clsfile_crc32 = ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length());
@@ -731,7 +730,7 @@
   misc_info_array->append(misc_info);
 }
 
-void SystemDictionaryShared::init_shared_dictionary_entry(Klass* k, DictionaryEntry* ent) {
+void SystemDictionaryShared::init_shared_dictionary_entry(InstanceKlass* k, DictionaryEntry* ent) {
   SharedDictionaryEntry* entry = (SharedDictionaryEntry*)ent;
   entry->_id = -1;
   entry->_clsfile_size = -1;
@@ -752,7 +751,7 @@
   }
 }
 
-bool SystemDictionaryShared::add_verification_constraint(Klass* k, Symbol* name,
+bool SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbol* name,
          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
   assert(DumpSharedSpaces, "called at dump time only");
 
@@ -796,7 +795,7 @@
   entry->check_verification_constraints(klass, THREAD);
 }
 
-SharedDictionaryEntry* SharedDictionary::find_entry_for(Klass* klass) {
+SharedDictionaryEntry* SharedDictionary::find_entry_for(InstanceKlass* klass) {
   Symbol* class_name = klass->name();
   unsigned int hash = compute_hash(class_name);
   int index = hash_to_index(hash);
@@ -970,7 +969,7 @@
                               entry != NULL;
                               entry = entry->next()) {
     if (entry->hash() == hash) {
-      Klass* klass = (Klass*)entry->literal();
+      InstanceKlass* klass = entry->instance_klass();
       if (klass->name() == class_name && klass->class_loader_data() == loader_data) {
         // There is already a class defined with the same name
         return false;
@@ -993,22 +992,22 @@
 //-----------------
 
 
-Klass* SharedDictionary::find_class_for_builtin_loader(const Symbol* name) const {
+InstanceKlass* SharedDictionary::find_class_for_builtin_loader(const Symbol* name) const {
   SharedDictionaryEntry* entry = get_entry_for_builtin_loader(name);
-  return entry != NULL ? entry->instance_klass() : (Klass*)NULL;
+  return entry != NULL ? entry->instance_klass() : (InstanceKlass*)NULL;
 }
 
-Klass* SharedDictionary::find_class_for_unregistered_loader(const Symbol* name,
+InstanceKlass* SharedDictionary::find_class_for_unregistered_loader(const Symbol* name,
                                                             int clsfile_size,
                                                             int clsfile_crc32) const {
 
   const SharedDictionaryEntry* entry = get_entry_for_unregistered_loader(name,
                                                                          clsfile_size,
                                                                          clsfile_crc32);
-  return entry != NULL ? entry->instance_klass() : (Klass*)NULL;
+  return entry != NULL ? entry->instance_klass() : NULL;
 }
 
-void SharedDictionary::update_entry(Klass* klass, int id) {
+void SharedDictionary::update_entry(InstanceKlass* klass, int id) {
   assert(DumpSharedSpaces, "supported only when dumping");
   Symbol* class_name = klass->name();
   unsigned int hash = compute_hash(class_name);
--- a/src/hotspot/share/classfile/systemDictionaryShared.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/classfile/systemDictionaryShared.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -132,7 +132,7 @@
 
   // See "Identifying the loader_type of archived classes" comments above.
   LoaderType loader_type() const {
-    Klass* k = (Klass*)literal();
+    InstanceKlass* k = instance_klass();
 
     if ((k->shared_classpath_index() != UNREGISTERED_INDEX)) {
       return LT_BUILTIN;
@@ -171,17 +171,17 @@
   }
 
 public:
-  SharedDictionaryEntry* find_entry_for(Klass* klass);
+  SharedDictionaryEntry* find_entry_for(InstanceKlass* klass);
   void finalize_verification_constraints();
 
   bool add_non_builtin_klass(const Symbol* class_name,
                              ClassLoaderData* loader_data,
                              InstanceKlass* obj);
 
-  void update_entry(Klass* klass, int id);
+  void update_entry(InstanceKlass* klass, int id);
 
-  Klass* find_class_for_builtin_loader(const Symbol* name) const;
-  Klass* find_class_for_unregistered_loader(const Symbol* name,
+  InstanceKlass* find_class_for_builtin_loader(const Symbol* name) const;
+  InstanceKlass* find_class_for_unregistered_loader(const Symbol* name,
                                             int clsfile_size,
                                             int clsfile_crc32) const;
   bool class_exists_for_unregistered_loader(const Symbol* name) {
@@ -317,7 +317,7 @@
 
   static bool add_non_builtin_klass(Symbol* class_name, ClassLoaderData* loader_data,
                                     InstanceKlass* k, TRAPS);
-  static Klass* dump_time_resolve_super_or_fail(Symbol* child_name,
+  static InstanceKlass* dump_time_resolve_super_or_fail(Symbol* child_name,
                                                 Symbol* class_name,
                                                 Handle class_loader,
                                                 Handle protection_domain,
@@ -327,7 +327,7 @@
   static size_t dictionary_entry_size() {
     return (DumpSharedSpaces) ? sizeof(SharedDictionaryEntry) : sizeof(DictionaryEntry);
   }
-  static void init_shared_dictionary_entry(Klass* k, DictionaryEntry* entry) NOT_CDS_RETURN;
+  static void init_shared_dictionary_entry(InstanceKlass* k, DictionaryEntry* entry) NOT_CDS_RETURN;
   static bool is_builtin(DictionaryEntry* ent) {
     // Can't use virtual function is_builtin because DictionaryEntry doesn't initialize
     // vtable because it's not constructed properly.
@@ -345,13 +345,13 @@
     return (SharedDictionary*)ClassLoaderData::the_null_class_loader_data()->dictionary();
   }
 
-  static void update_shared_entry(Klass* klass, int id) {
+  static void update_shared_entry(InstanceKlass* klass, int id) {
     assert(DumpSharedSpaces, "sanity");
     assert((SharedDictionary*)(klass->class_loader_data()->dictionary()) != NULL, "sanity");
     ((SharedDictionary*)(klass->class_loader_data()->dictionary()))->update_entry(klass, id);
   }
 
-  static void set_shared_class_misc_info(Klass* k, ClassFileStream* cfs);
+  static void set_shared_class_misc_info(InstanceKlass* k, ClassFileStream* cfs);
 
   static InstanceKlass* lookup_from_stream(const Symbol* class_name,
                                            Handle class_loader,
@@ -367,7 +367,7 @@
   // ensures that you cannot load a shared class if its super type(s) are changed. However,
   // we need an additional check to ensure that the verification_constraints did not change
   // between dump time and runtime.
-  static bool add_verification_constraint(Klass* k, Symbol* name,
+  static bool add_verification_constraint(InstanceKlass* k, Symbol* name,
                   Symbol* from_name, bool from_field_is_protected,
                   bool from_is_array, bool from_is_object) NOT_CDS_RETURN_(false);
   static void finalize_verification_constraints() NOT_CDS_RETURN;
--- a/src/hotspot/share/classfile/verifier.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/classfile/verifier.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -2678,10 +2678,10 @@
     VerificationType klass_type,
     VerificationType ref_class_type) {
   if (ref_class_type.equals(klass_type)) return true;
-  Array<Klass*>* local_interfaces = klass->local_interfaces();
+  Array<InstanceKlass*>* local_interfaces = klass->local_interfaces();
   if (local_interfaces != NULL) {
     for (int x = 0; x < local_interfaces->length(); x++) {
-      Klass* k = local_interfaces->at(x);
+      InstanceKlass* k = local_interfaces->at(x);
       assert (k != NULL && k->is_interface(), "invalid interface");
       if (ref_class_type.equals(VerificationType::reference_type(k->name()))) {
         return true;
--- a/src/hotspot/share/code/dependencies.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/code/dependencies.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -716,7 +716,7 @@
     // iteration variables:
     ChangeType  _change_type;
     Klass*      _klass;
-    Array<Klass*>* _ti_base;    // i.e., transitive_interfaces
+    Array<InstanceKlass*>* _ti_base;    // i.e., transitive_interfaces
     int         _ti_index;
     int         _ti_limit;
 
--- a/src/hotspot/share/memory/heapInspection.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/memory/heapInspection.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -465,7 +465,7 @@
   }
 }
 
-static void print_interface(outputStream* st, Klass* intf_klass, const char* intf_type, int indent) {
+static void print_interface(outputStream* st, InstanceKlass* intf_klass, const char* intf_type, int indent) {
   print_indent(st, indent);
   st->print("  implements ");
   print_classname(st, intf_klass);
@@ -501,13 +501,13 @@
 
   // Print any interfaces the class has.
   if (print_interfaces) {
-    Array<Klass*>* local_intfs = klass->local_interfaces();
-    Array<Klass*>* trans_intfs = klass->transitive_interfaces();
+    Array<InstanceKlass*>* local_intfs = klass->local_interfaces();
+    Array<InstanceKlass*>* trans_intfs = klass->transitive_interfaces();
     for (int i = 0; i < local_intfs->length(); i++) {
       print_interface(st, local_intfs->at(i), "declared", indent);
     }
     for (int i = 0; i < trans_intfs->length(); i++) {
-      Klass* trans_interface = trans_intfs->at(i);
+      InstanceKlass* trans_interface = trans_intfs->at(i);
       // Only print transitive interfaces if they are not also declared.
       if (!local_intfs->contains(trans_interface)) {
         print_interface(st, trans_interface, "inherited", indent);
--- a/src/hotspot/share/memory/universe.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/memory/universe.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -135,6 +135,7 @@
 Array<int>* Universe::_the_empty_int_array            = NULL;
 Array<u2>* Universe::_the_empty_short_array           = NULL;
 Array<Klass*>* Universe::_the_empty_klass_array     = NULL;
+Array<InstanceKlass*>* Universe::_the_empty_instance_klass_array  = NULL;
 Array<Method*>* Universe::_the_empty_method_array   = NULL;
 
 // These variables are guarded by FullGCALot_lock.
@@ -234,6 +235,7 @@
   it->push(&_the_empty_int_array);
   it->push(&_the_empty_short_array);
   it->push(&_the_empty_klass_array);
+  it->push(&_the_empty_instance_klass_array);
   it->push(&_the_empty_method_array);
   it->push(&_the_array_interfaces_array);
 
@@ -287,6 +289,7 @@
   f->do_ptr((void**)&_the_empty_short_array);
   f->do_ptr((void**)&_the_empty_method_array);
   f->do_ptr((void**)&_the_empty_klass_array);
+  f->do_ptr((void**)&_the_empty_instance_klass_array);
   _finalizer_register_cache->serialize(f);
   _loader_addClass_cache->serialize(f);
   _pd_implies_cache->serialize(f);
@@ -349,11 +352,12 @@
 
         ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
 
-        _the_array_interfaces_array = MetadataFactory::new_array<Klass*>(null_cld, 2, NULL, CHECK);
-        _the_empty_int_array        = MetadataFactory::new_array<int>(null_cld, 0, CHECK);
-        _the_empty_short_array      = MetadataFactory::new_array<u2>(null_cld, 0, CHECK);
-        _the_empty_method_array     = MetadataFactory::new_array<Method*>(null_cld, 0, CHECK);
-        _the_empty_klass_array      = MetadataFactory::new_array<Klass*>(null_cld, 0, CHECK);
+        _the_array_interfaces_array     = MetadataFactory::new_array<Klass*>(null_cld, 2, NULL, CHECK);
+        _the_empty_int_array            = MetadataFactory::new_array<int>(null_cld, 0, CHECK);
+        _the_empty_short_array          = MetadataFactory::new_array<u2>(null_cld, 0, CHECK);
+        _the_empty_method_array         = MetadataFactory::new_array<Method*>(null_cld, 0, CHECK);
+        _the_empty_klass_array          = MetadataFactory::new_array<Klass*>(null_cld, 0, CHECK);
+        _the_empty_instance_klass_array = MetadataFactory::new_array<InstanceKlass*>(null_cld, 0, CHECK);
       }
     }
 
--- a/src/hotspot/share/memory/universe.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/memory/universe.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -161,10 +161,11 @@
   // preallocated cause message for delayed StackOverflowError
   static oop          _delayed_stack_overflow_error_message;
 
-  static Array<int>*       _the_empty_int_array;    // Canonicalized int array
-  static Array<u2>*        _the_empty_short_array;  // Canonicalized short array
-  static Array<Klass*>*  _the_empty_klass_array;  // Canonicalized klass obj array
-  static Array<Method*>* _the_empty_method_array; // Canonicalized method obj array
+  static Array<int>*            _the_empty_int_array;            // Canonicalized int array
+  static Array<u2>*             _the_empty_short_array;          // Canonicalized short array
+  static Array<Klass*>*         _the_empty_klass_array;          // Canonicalized klass array
+  static Array<InstanceKlass*>* _the_empty_instance_klass_array; // Canonicalized instance klass array
+  static Array<Method*>*        _the_empty_method_array;         // Canonicalized method array
 
   static Array<Klass*>*  _the_array_interfaces_array;
 
@@ -357,10 +358,11 @@
   static bool         has_reference_pending_list();
   static oop          swap_reference_pending_list(oop list);
 
-  static Array<int>*       the_empty_int_array()    { return _the_empty_int_array; }
-  static Array<u2>*        the_empty_short_array()  { return _the_empty_short_array; }
-  static Array<Method*>* the_empty_method_array() { return _the_empty_method_array; }
-  static Array<Klass*>*  the_empty_klass_array()  { return _the_empty_klass_array; }
+  static Array<int>*             the_empty_int_array()    { return _the_empty_int_array; }
+  static Array<u2>*              the_empty_short_array()  { return _the_empty_short_array; }
+  static Array<Method*>*         the_empty_method_array() { return _the_empty_method_array; }
+  static Array<Klass*>*          the_empty_klass_array()  { return _the_empty_klass_array; }
+  static Array<InstanceKlass*>*  the_empty_instance_klass_array() { return _the_empty_instance_klass_array; }
 
   // OutOfMemoryError support. Returns an error with the required message. The returned error
   // may or may not have a backtrace. If error has a backtrace then the stack trace is already
--- a/src/hotspot/share/oops/arrayKlass.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/arrayKlass.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -49,7 +49,7 @@
 }
 
 
-Klass* ArrayKlass::java_super() const {
+InstanceKlass* ArrayKlass::java_super() const {
   if (super() == NULL)  return NULL;  // bootstrap case
   // Array klasses have primary supertypes which are not reported to Java.
   // Example super chain:  String[][] -> Object[][] -> Object[] -> Object
@@ -90,7 +90,7 @@
     // the vtable of klass Object.
     set_vtable_length(Universe::base_vtable_size());
     set_name(name);
-    set_super(Universe::is_bootstrapping() ? (Klass*)NULL : SystemDictionary::Object_klass());
+    set_super(Universe::is_bootstrapping() ? NULL : SystemDictionary::Object_klass());
     set_layout_helper(Klass::_lh_neutral_value);
     set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5)
     JFR_ONLY(INIT_ID(this);)
@@ -113,7 +113,7 @@
 }
 
 GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots,
-                                                            Array<Klass*>* transitive_interfaces) {
+                                                            Array<InstanceKlass*>* transitive_interfaces) {
   // interfaces = { cloneable_klass, serializable_klass };
   assert(num_extra_slots == 0, "sanity of primitive array type");
   assert(transitive_interfaces == NULL, "sanity");
--- a/src/hotspot/share/oops/arrayKlass.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/arrayKlass.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -73,7 +73,7 @@
   // type of elements (T_OBJECT for both oop arrays and array-arrays)
   BasicType element_type() const        { return layout_helper_element_type(layout_helper()); }
 
-  virtual Klass* java_super() const;//{ return SystemDictionary::Object_klass(); }
+  virtual InstanceKlass* java_super() const;//{ return SystemDictionary::Object_klass(); }
 
   // Allocation
   // Sizes points to the first dimension of the array, subsequent dimensions
@@ -100,7 +100,7 @@
   }
 
   GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
-                                                  Array<Klass*>* transitive_interfaces);
+                                                  Array<InstanceKlass*>* transitive_interfaces);
   bool compute_is_subtype_of(Klass* k);
 
   // Sizing
--- a/src/hotspot/share/oops/cpCache.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/cpCache.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -493,7 +493,7 @@
       switch (invoke_code) {
       case Bytecodes::_invokeinterface:
         assert(f1->is_klass(), "");
-        return klassItable::method_for_itable_index((Klass*)f1, f2_as_index());
+        return klassItable::method_for_itable_index((InstanceKlass*)f1, f2_as_index());
       case Bytecodes::_invokestatic:
       case Bytecodes::_invokespecial:
         assert(!has_appendix(), "");
--- a/src/hotspot/share/oops/instanceKlass.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -439,24 +439,24 @@
 
 void InstanceKlass::deallocate_interfaces(ClassLoaderData* loader_data,
                                           const Klass* super_klass,
-                                          Array<Klass*>* local_interfaces,
-                                          Array<Klass*>* transitive_interfaces) {
+                                          Array<InstanceKlass*>* local_interfaces,
+                                          Array<InstanceKlass*>* transitive_interfaces) {
   // Only deallocate transitive interfaces if not empty, same as super class
   // or same as local interfaces.  See code in parseClassFile.
-  Array<Klass*>* ti = transitive_interfaces;
-  if (ti != Universe::the_empty_klass_array() && ti != local_interfaces) {
+  Array<InstanceKlass*>* ti = transitive_interfaces;
+  if (ti != Universe::the_empty_instance_klass_array() && ti != local_interfaces) {
     // check that the interfaces don't come from super class
-    Array<Klass*>* sti = (super_klass == NULL) ? NULL :
+    Array<InstanceKlass*>* sti = (super_klass == NULL) ? NULL :
                     InstanceKlass::cast(super_klass)->transitive_interfaces();
     if (ti != sti && ti != NULL && !ti->is_shared()) {
-      MetadataFactory::free_array<Klass*>(loader_data, ti);
+      MetadataFactory::free_array<InstanceKlass*>(loader_data, ti);
     }
   }
 
   // local interfaces can be empty
-  if (local_interfaces != Universe::the_empty_klass_array() &&
+  if (local_interfaces != Universe::the_empty_instance_klass_array() &&
       local_interfaces != NULL && !local_interfaces->is_shared()) {
-    MetadataFactory::free_array<Klass*>(loader_data, local_interfaces);
+    MetadataFactory::free_array<InstanceKlass*>(loader_data, local_interfaces);
   }
 }
 
@@ -517,7 +517,8 @@
   // interfaces.
   if (secondary_supers() != NULL &&
       secondary_supers() != Universe::the_empty_klass_array() &&
-      secondary_supers() != transitive_interfaces() &&
+      // see comments in compute_secondary_supers about the following cast
+      (address)(secondary_supers()) != (address)(transitive_interfaces()) &&
       !secondary_supers()->is_shared()) {
     MetadataFactory::free_array<Klass*>(loader_data, secondary_supers());
   }
@@ -755,10 +756,10 @@
   }
 
   // link all interfaces implemented by this class before linking this class
-  Array<Klass*>* interfaces = local_interfaces();
+  Array<InstanceKlass*>* interfaces = local_interfaces();
   int num_interfaces = interfaces->length();
   for (int index = 0; index < num_interfaces; index++) {
-    InstanceKlass* interk = InstanceKlass::cast(interfaces->at(index));
+    InstanceKlass* interk = interfaces->at(index);
     interk->link_class_impl(throw_verifyerror, CHECK_false);
   }
 
@@ -872,8 +873,7 @@
 void InstanceKlass::initialize_super_interfaces(TRAPS) {
   assert (has_nonstatic_concrete_methods(), "caller should have checked this");
   for (int i = 0; i < local_interfaces()->length(); ++i) {
-    Klass* iface = local_interfaces()->at(i);
-    InstanceKlass* ik = InstanceKlass::cast(iface);
+    InstanceKlass* ik = local_interfaces()->at(i);
 
     // Initialization is depth first search ie. we start with top of the inheritance tree
     // has_nonstatic_concrete_methods drives searching superinterfaces since it
@@ -1117,18 +1117,21 @@
 }
 
 GrowableArray<Klass*>* InstanceKlass::compute_secondary_supers(int num_extra_slots,
-                                                               Array<Klass*>* transitive_interfaces) {
+                                                               Array<InstanceKlass*>* transitive_interfaces) {
   // The secondaries are the implemented interfaces.
-  Array<Klass*>* interfaces = transitive_interfaces;
+  Array<InstanceKlass*>* interfaces = transitive_interfaces;
   int num_secondaries = num_extra_slots + interfaces->length();
   if (num_secondaries == 0) {
     // Must share this for correct bootstrapping!
     set_secondary_supers(Universe::the_empty_klass_array());
     return NULL;
   } else if (num_extra_slots == 0) {
-    // The secondary super list is exactly the same as the transitive interfaces.
+    // The secondary super list is exactly the same as the transitive interfaces, so
+    // let's use it instead of making a copy.
     // Redefine classes has to be careful not to delete this!
-    set_secondary_supers(interfaces);
+    // We need the cast because Array<Klass*> is NOT a supertype of Array<InstanceKlass*>,
+    // (but it's safe to do here because we won't write into _secondary_supers from this point on).
+    set_secondary_supers((Array<Klass*>*)(address)interfaces);
     return NULL;
   } else {
     // Copy transitive interfaces to a temporary growable array to be constructed
@@ -1791,11 +1794,11 @@
 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
                                                        Symbol* signature,
                                                        DefaultsLookupMode defaults_mode) const {
-  Array<Klass*>* all_ifs = transitive_interfaces();
+  Array<InstanceKlass*>* all_ifs = transitive_interfaces();
   int num_ifs = all_ifs->length();
   InstanceKlass *ik = NULL;
   for (int i = 0; i < num_ifs; i++) {
-    ik = InstanceKlass::cast(all_ifs->at(i));
+    ik = all_ifs->at(i);
     Method* m = ik->lookup_method(name, signature);
     if (m != NULL && m->is_public() && !m->is_static() &&
         ((defaults_mode != skip_defaults) || !m->is_default_method())) {
@@ -2142,11 +2145,11 @@
     return false;
   }
 
-  Array<Klass*>* local_interfaces = this->local_interfaces();
+  Array<InstanceKlass*>* local_interfaces = this->local_interfaces();
   if (local_interfaces != NULL) {
     int length = local_interfaces->length();
     for (int i = 0; i < length; i++) {
-      InstanceKlass* intf = InstanceKlass::cast(local_interfaces->at(i));
+      InstanceKlass* intf = local_interfaces->at(i);
       if (!intf->has_passed_fingerprint_check()) {
         ResourceMark rm;
         log_trace(class, fingerprint)("%s : interface %s not fingerprinted", external_name(), intf->external_name());
@@ -2353,10 +2356,10 @@
       }
     }
     if (!bad) {
-      Array<Klass*>* interfaces = transitive_interfaces();
+      Array<InstanceKlass*>* interfaces = transitive_interfaces();
       for (int i = 0; i < interfaces->length(); i++) {
-        Klass* iface = interfaces->at(i);
-        if (InstanceKlass::cast(iface)->is_in_error_state()) {
+        InstanceKlass* iface = interfaces->at(i);
+        if (iface->is_in_error_state()) {
           bad = true;
           break;
         }
@@ -3254,6 +3257,12 @@
   }
 }
 
+bool InstanceKlass::verify_itable_index(int i) {
+  int method_count = klassItable::method_count_for_interface(this);
+  assert(i >= 0 && i < method_count, "index out of bounds");
+  return true;
+}
+
 #endif //PRODUCT
 
 void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) {
@@ -3498,18 +3507,18 @@
 
   // Verify local interfaces
   if (local_interfaces()) {
-    Array<Klass*>* local_interfaces = this->local_interfaces();
+    Array<InstanceKlass*>* local_interfaces = this->local_interfaces();
     for (int j = 0; j < local_interfaces->length(); j++) {
-      Klass* e = local_interfaces->at(j);
+      InstanceKlass* e = local_interfaces->at(j);
       guarantee(e->is_klass() && e->is_interface(), "invalid local interface");
     }
   }
 
   // Verify transitive interfaces
   if (transitive_interfaces() != NULL) {
-    Array<Klass*>* transitive_interfaces = this->transitive_interfaces();
+    Array<InstanceKlass*>* transitive_interfaces = this->transitive_interfaces();
     for (int j = 0; j < transitive_interfaces->length(); j++) {
-      Klass* e = transitive_interfaces->at(j);
+      InstanceKlass* e = transitive_interfaces->at(j);
       guarantee(e->is_klass() && e->is_interface(), "invalid transitive interface");
     }
   }
--- a/src/hotspot/share/oops/instanceKlass.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/instanceKlass.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -279,10 +279,10 @@
   Array<Method*>* _methods;
   // Default Method Array, concrete methods inherited from interfaces
   Array<Method*>* _default_methods;
-  // Interface (Klass*s) this class declares locally to implement.
-  Array<Klass*>* _local_interfaces;
-  // Interface (Klass*s) this class implements transitively.
-  Array<Klass*>* _transitive_interfaces;
+  // Interfaces (InstanceKlass*s) this class declares locally to implement.
+  Array<InstanceKlass*>* _local_interfaces;
+  // Interfaces (InstanceKlass*s) this class implements transitively.
+  Array<InstanceKlass*>* _transitive_interfaces;
   // Int array containing the original order of method in the class file (for JVMTI).
   Array<int>*     _method_ordering;
   // Int array containing the vtable_indices for default_methods
@@ -415,13 +415,13 @@
   Array<int>* create_new_default_vtable_indices(int len, TRAPS);
 
   // interfaces
-  Array<Klass*>* local_interfaces() const          { return _local_interfaces; }
-  void set_local_interfaces(Array<Klass*>* a)      {
+  Array<InstanceKlass*>* local_interfaces() const          { return _local_interfaces; }
+  void set_local_interfaces(Array<InstanceKlass*>* a)      {
     guarantee(_local_interfaces == NULL || a == NULL, "Just checking");
     _local_interfaces = a; }
 
-  Array<Klass*>* transitive_interfaces() const     { return _transitive_interfaces; }
-  void set_transitive_interfaces(Array<Klass*>* a) {
+  Array<InstanceKlass*>* transitive_interfaces() const     { return _transitive_interfaces; }
+  void set_transitive_interfaces(Array<InstanceKlass*>* a) {
     guarantee(_transitive_interfaces == NULL || a == NULL, "Just checking");
     _transitive_interfaces = a;
   }
@@ -1052,7 +1052,7 @@
   // virtual operations from Klass
   bool is_leaf_class() const               { return _subklass == NULL; }
   GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
-                                                  Array<Klass*>* transitive_interfaces);
+                                                  Array<InstanceKlass*>* transitive_interfaces);
   bool compute_is_subtype_of(Klass* k);
   bool can_be_primary_super_slow() const;
   int oop_size(oop obj)  const             { return size_helper(); }
@@ -1080,7 +1080,7 @@
     return static_cast<const InstanceKlass*>(k);
   }
 
-  InstanceKlass* java_super() const {
+  virtual InstanceKlass* java_super() const {
     return (super() == NULL) ? NULL : cast(super());
   }
 
@@ -1201,8 +1201,8 @@
                                  Array<Method*>* methods);
   void static deallocate_interfaces(ClassLoaderData* loader_data,
                                     const Klass* super_klass,
-                                    Array<Klass*>* local_interfaces,
-                                    Array<Klass*>* transitive_interfaces);
+                                    Array<InstanceKlass*>* local_interfaces,
+                                    Array<InstanceKlass*>* transitive_interfaces);
 
   // The constant pool is on stack if any of the methods are executing or
   // referenced by handles.
@@ -1379,6 +1379,7 @@
 
   void print_dependent_nmethods(bool verbose = false);
   bool is_dependent_nmethod(nmethod* nm);
+  bool verify_itable_index(int index);
 #endif
 
   const char* internal_name() const;
--- a/src/hotspot/share/oops/klass.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/klass.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -229,7 +229,7 @@
     return true;
 }
 
-void Klass::initialize_supers(Klass* k, Array<Klass*>* transitive_interfaces, TRAPS) {
+void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, TRAPS) {
   if (FastSuperclassLimit == 0) {
     // None of the other machinery matters.
     set_super(k);
@@ -348,7 +348,7 @@
 }
 
 GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots,
-                                                       Array<Klass*>* transitive_interfaces) {
+                                                       Array<InstanceKlass*>* transitive_interfaces) {
   assert(num_extra_slots == 0, "override for complex klasses");
   assert(transitive_interfaces == NULL, "sanity");
   set_secondary_supers(Universe::the_empty_klass_array());
@@ -765,13 +765,6 @@
   return true;
 }
 
-bool Klass::verify_itable_index(int i) {
-  assert(is_instance_klass(), "");
-  int method_count = klassItable::method_count_for_interface(this);
-  assert(i >= 0 && i < method_count, "index out of bounds");
-  return true;
-}
-
 #endif // PRODUCT
 
 // Caller needs ResourceMark
--- a/src/hotspot/share/oops/klass.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/klass.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -202,21 +202,21 @@
 
   bool is_klass() const volatile { return true; }
 
-  // super
+  // super() cannot be InstanceKlass* -- Java arrays are covariant, and _super is used
+  // to implement that. NB: the _super of "[Ljava/lang/Integer;" is "[Ljava/lang/Number;"
+  // If this is not what your code expects, you're probably looking for Klass::java_super().
   Klass* super() const               { return _super; }
   void set_super(Klass* k)           { _super = k; }
 
   // initializes _super link, _primary_supers & _secondary_supers arrays
-  void initialize_supers(Klass* k, Array<Klass*>* transitive_interfaces, TRAPS);
-  void initialize_supers_impl1(Klass* k);
-  void initialize_supers_impl2(Klass* k);
+  void initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, TRAPS);
 
   // klass-specific helper for initializing _secondary_supers
   virtual GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
-                                                          Array<Klass*>* transitive_interfaces);
+                                                          Array<InstanceKlass*>* transitive_interfaces);
 
   // java_super is the Java-level super type as specified by Class.getSuperClass.
-  virtual Klass* java_super() const  { return NULL; }
+  virtual InstanceKlass* java_super() const  { return NULL; }
 
   juint    super_check_offset() const  { return _super_check_offset; }
   void set_super_check_offset(juint o) { _super_check_offset = o; }
@@ -709,7 +709,6 @@
 
 #ifndef PRODUCT
   bool verify_vtable_index(int index);
-  bool verify_itable_index(int index);
 #endif
 
   virtual void oop_verify_on(oop obj, outputStream* st);
--- a/src/hotspot/share/oops/klassVtable.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/klassVtable.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -66,7 +66,7 @@
     int* vtable_length_ret, int* num_new_mirandas,
     GrowableArray<Method*>* all_mirandas, const Klass* super,
     Array<Method*>* methods, AccessFlags class_flags, u2 major_version,
-    Handle classloader, Symbol* classname, Array<Klass*>* local_interfaces,
+    Handle classloader, Symbol* classname, Array<InstanceKlass*>* local_interfaces,
     TRAPS) {
   NoSafepointVerifier nsv;
 
@@ -166,7 +166,7 @@
 void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) {
 
   // Note:  Arrays can have intermediate array supers.  Use java_super to skip them.
-  Klass* super = _klass->java_super();
+  InstanceKlass* super = _klass->java_super();
   int nofNewEntries = 0;
 
   bool is_shared = _klass->is_shared();
@@ -871,7 +871,7 @@
                                const Klass* super,
                                Array<Method*>* class_methods,
                                Array<Method*>* default_methods,
-                               Array<Klass*>* local_interfaces,
+                               Array<InstanceKlass*>* local_interfaces,
                                bool is_interface) {
   assert((new_mirandas->length() == 0) , "current mirandas must be 0");
 
@@ -883,10 +883,10 @@
                               ik->methods(), class_methods,
                               default_methods, super, is_interface);
     // iterate thru each local's super interfaces
-    Array<Klass*>* super_ifs = ik->transitive_interfaces();
+    Array<InstanceKlass*>* super_ifs = ik->transitive_interfaces();
     int num_super_ifs = super_ifs->length();
     for (int j = 0; j < num_super_ifs; j++) {
-      InstanceKlass *sik = InstanceKlass::cast(super_ifs->at(j));
+      InstanceKlass *sik = super_ifs->at(j);
       add_new_mirandas_to_lists(new_mirandas, all_mirandas,
                                 sik->methods(), class_methods,
                                 default_methods, super, is_interface);
@@ -1082,7 +1082,7 @@
   if (_klass->is_interface()) {
     // This needs to go after vtable indices are assigned but
     // before implementors need to know the number of itable indices.
-    assign_itable_indices_for_interface(_klass, THREAD);
+    assign_itable_indices_for_interface(InstanceKlass::cast(_klass), THREAD);
   }
 
   // Cannot be setup doing bootstrapping, interfaces don't have
@@ -1107,7 +1107,7 @@
       HandleMark hm(THREAD);
       Klass* interf = ioe->interface_klass();
       assert(interf != NULL && ioe->offset() != 0, "bad offset entry in itable");
-      initialize_itable_for_interface(ioe->offset(), interf, checkconstraints, CHECK);
+      initialize_itable_for_interface(ioe->offset(), InstanceKlass::cast(interf), checkconstraints, CHECK);
     }
 
   }
@@ -1128,12 +1128,12 @@
   return true;
 }
 
-int klassItable::assign_itable_indices_for_interface(Klass* klass, TRAPS) {
+int klassItable::assign_itable_indices_for_interface(InstanceKlass* klass, TRAPS) {
   // an interface does not have an itable, but its methods need to be numbered
   ResourceMark rm(THREAD);
   log_develop_debug(itables)("%3d: Initializing itable indices for interface %s",
                              ++initialize_count, klass->name()->as_C_string());
-  Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
+  Array<Method*>* methods = klass->methods();
   int nof_methods = methods->length();
   int ime_num = 0;
   for (int i = 0; i < nof_methods; i++) {
@@ -1170,10 +1170,9 @@
   return ime_num;
 }
 
-int klassItable::method_count_for_interface(Klass* interf) {
-  assert(interf->is_instance_klass(), "must be");
+int klassItable::method_count_for_interface(InstanceKlass* interf) {
   assert(interf->is_interface(), "must be");
-  Array<Method*>* methods = InstanceKlass::cast(interf)->methods();
+  Array<Method*>* methods = interf->methods();
   int nof_methods = methods->length();
   int length = 0;
   while (nof_methods > 0) {
@@ -1197,11 +1196,12 @@
 }
 
 
-void klassItable::initialize_itable_for_interface(int method_table_offset, Klass* interf, bool checkconstraints, TRAPS) {
-  Array<Method*>* methods = InstanceKlass::cast(interf)->methods();
+void klassItable::initialize_itable_for_interface(int method_table_offset, InstanceKlass* interf, bool checkconstraints, TRAPS) {
+  assert(interf->is_interface(), "must be");
+  Array<Method*>* methods = interf->methods();
   int nof_methods = methods->length();
   HandleMark hm;
-  Handle interface_loader (THREAD, InstanceKlass::cast(interf)->class_loader());
+  Handle interface_loader (THREAD, interf->class_loader());
 
   int ime_count = method_count_for_interface(interf);
   for (int i = 0; i < nof_methods; i++) {
@@ -1349,20 +1349,20 @@
 // Setup
 class InterfaceVisiterClosure : public StackObj {
  public:
-  virtual void doit(Klass* intf, int method_count) = 0;
+  virtual void doit(InstanceKlass* intf, int method_count) = 0;
 };
 
 // Visit all interfaces with at least one itable method
-void visit_all_interfaces(Array<Klass*>* transitive_intf, InterfaceVisiterClosure *blk) {
+void visit_all_interfaces(Array<InstanceKlass*>* transitive_intf, InterfaceVisiterClosure *blk) {
   // Handle array argument
   for(int i = 0; i < transitive_intf->length(); i++) {
-    Klass* intf = transitive_intf->at(i);
+    InstanceKlass* intf = transitive_intf->at(i);
     assert(intf->is_interface(), "sanity check");
 
     // Find no. of itable methods
     int method_count = 0;
     // method_count = klassItable::method_count_for_interface(intf);
-    Array<Method*>* methods = InstanceKlass::cast(intf)->methods();
+    Array<Method*>* methods = intf->methods();
     if (methods->length() > 0) {
       for (int i = methods->length(); --i >= 0; ) {
         if (interface_method_needs_itable_index(methods->at(i))) {
@@ -1374,7 +1374,7 @@
     // Visit all interfaces which either have any methods or can participate in receiver type check.
     // We do not bother to count methods in transitive interfaces, although that would allow us to skip
     // this step in the rare case of a zero-method interface extending another zero-method interface.
-    if (method_count > 0 || InstanceKlass::cast(intf)->transitive_interfaces()->length() > 0) {
+    if (method_count > 0 || intf->transitive_interfaces()->length() > 0) {
       blk->doit(intf, method_count);
     }
   }
@@ -1390,7 +1390,7 @@
    int nof_methods() const    { return _nof_methods; }
    int nof_interfaces() const { return _nof_interfaces; }
 
-   void doit(Klass* intf, int method_count) { _nof_methods += method_count; _nof_interfaces++; }
+   void doit(InstanceKlass* intf, int method_count) { _nof_methods += method_count; _nof_interfaces++; }
 };
 
 class SetupItableClosure : public InterfaceVisiterClosure  {
@@ -1407,7 +1407,7 @@
 
   itableMethodEntry* method_entry() const { return _method_entry; }
 
-  void doit(Klass* intf, int method_count) {
+  void doit(InstanceKlass* intf, int method_count) {
     int offset = ((address)_method_entry) - _klass_begin;
     _offset_entry->initialize(intf, offset);
     _offset_entry++;
@@ -1415,7 +1415,7 @@
   }
 };
 
-int klassItable::compute_itable_size(Array<Klass*>* transitive_interfaces) {
+int klassItable::compute_itable_size(Array<InstanceKlass*>* transitive_interfaces) {
   // Count no of interfaces and total number of interface methods
   CountInterfacesClosure cic;
   visit_all_interfaces(transitive_interfaces, &cic);
@@ -1468,8 +1468,8 @@
 
 
 // inverse to itable_index
-Method* klassItable::method_for_itable_index(Klass* intf, int itable_index) {
-  assert(InstanceKlass::cast(intf)->is_interface(), "sanity check");
+Method* klassItable::method_for_itable_index(InstanceKlass* intf, int itable_index) {
+  assert(intf->is_interface(), "sanity check");
   assert(intf->verify_itable_index(itable_index), "");
   Array<Method*>* methods = InstanceKlass::cast(intf)->methods();
 
--- a/src/hotspot/share/oops/klassVtable.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/klassVtable.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -92,7 +92,7 @@
                                                    u2 major_version,
                                                    Handle classloader,
                                                    Symbol* classname,
-                                                   Array<Klass*>* local_interfaces,
+                                                   Array<InstanceKlass*>* local_interfaces,
                                                    TRAPS);
 
 #if INCLUDE_JVMTI
@@ -159,7 +159,7 @@
       const Klass* super,
       Array<Method*>* class_methods,
       Array<Method*>* default_methods,
-      Array<Klass*>* local_interfaces,
+      Array<InstanceKlass*>* local_interfaces,
       bool is_interface);
   void verify_against(outputStream* st, klassVtable* vt, int index);
   inline InstanceKlass* ik() const;
@@ -235,17 +235,17 @@
 
 class itableOffsetEntry {
  private:
-  Klass* _interface;
+  InstanceKlass* _interface;
   int      _offset;
  public:
-  Klass* interface_klass() const { return _interface; }
-  Klass**interface_klass_addr()  { return &_interface; }
+  InstanceKlass* interface_klass() const { return _interface; }
+  InstanceKlass**interface_klass_addr()  { return &_interface; }
   int      offset() const          { return _offset; }
 
   static itableMethodEntry* method_entry(Klass* k, int offset) { return (itableMethodEntry*)(((address)k) + offset); }
   itableMethodEntry* first_method_entry(Klass* k)              { return method_entry(k, _offset); }
 
-  void initialize(Klass* interf, int offset) { _interface = interf; _offset = offset; }
+  void initialize(InstanceKlass* interf, int offset) { _interface = interf; _offset = offset; }
 
   // Static size and offset accessors
   static int size()                       { return sizeof(itableOffsetEntry) / wordSize; }    // size in words
@@ -300,7 +300,7 @@
   int                  _size_offset_table; // size of offset table (in itableOffset entries)
   int                  _size_method_table; // size of methodtable (in itableMethodEntry entries)
 
-  void initialize_itable_for_interface(int method_table_offset, Klass* interf_h, bool checkconstraints, TRAPS);
+  void initialize_itable_for_interface(int method_table_offset, InstanceKlass* interf_h, bool checkconstraints, TRAPS);
  public:
   klassItable(InstanceKlass* klass);
 
@@ -328,13 +328,13 @@
 #endif // INCLUDE_JVMTI
 
   // Setup of itable
-  static int assign_itable_indices_for_interface(Klass* klass, TRAPS);
-  static int method_count_for_interface(Klass* klass);
-  static int compute_itable_size(Array<Klass*>* transitive_interfaces);
+  static int assign_itable_indices_for_interface(InstanceKlass* klass, TRAPS);
+  static int method_count_for_interface(InstanceKlass* klass);
+  static int compute_itable_size(Array<InstanceKlass*>* transitive_interfaces);
   static void setup_itable_offset_table(InstanceKlass* klass);
 
   // Resolving of method to index
-  static Method* method_for_itable_index(Klass* klass, int itable_index);
+  static Method* method_for_itable_index(InstanceKlass* klass, int itable_index);
 
   // Debugging/Statistics
   static void print_statistics() PRODUCT_RETURN;
--- a/src/hotspot/share/oops/objArrayKlass.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/objArrayKlass.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -67,7 +67,7 @@
       bool supers_exist = super_klass != NULL;
       // Also, see if the element has secondary supertypes.
       // We need an array type for each.
-      Array<Klass*>* element_supers = element_klass->secondary_supers();
+      const Array<Klass*>* element_supers = element_klass->secondary_supers();
       for( int i = element_supers->length()-1; i >= 0; i-- ) {
         Klass* elem_super = element_supers->at(i);
         if (elem_super->array_klass_or_null() == NULL) {
@@ -382,10 +382,10 @@
 }
 
 GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots,
-                                                               Array<Klass*>* transitive_interfaces) {
+                                                               Array<InstanceKlass*>* transitive_interfaces) {
   assert(transitive_interfaces == NULL, "sanity");
   // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
-  Array<Klass*>* elem_supers = element_klass()->secondary_supers();
+  const Array<Klass*>* elem_supers = element_klass()->secondary_supers();
   int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length();
   int num_secondaries = num_extra_slots + 2 + num_elem_supers;
   if (num_secondaries == 2) {
@@ -397,7 +397,7 @@
     secondaries->push(SystemDictionary::Cloneable_klass());
     secondaries->push(SystemDictionary::Serializable_klass());
     for (int i = 0; i < num_elem_supers; i++) {
-      Klass* elem_super = (Klass*) elem_supers->at(i);
+      Klass* elem_super = elem_supers->at(i);
       Klass* array_super = elem_super->array_klass_or_null();
       assert(array_super != NULL, "must already have been created");
       secondaries->push(array_super);
--- a/src/hotspot/share/oops/objArrayKlass.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/oops/objArrayKlass.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@
   // Dispatched operation
   bool can_be_primary_super_slow() const;
   GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
-                                                  Array<Klass*>* transitive_interfaces);
+                                                  Array<InstanceKlass*>* transitive_interfaces);
   bool compute_is_subtype_of(Klass* k);
   DEBUG_ONLY(bool is_objArray_klass_slow()  const  { return true; })
   int oop_size(oop obj) const;
--- a/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -808,12 +808,12 @@
 
   // JVMSpec|           u2 interfaces_count;
   // JVMSpec|           u2 interfaces[interfaces_count];
-  Array<Klass*>* interfaces =  ik()->local_interfaces();
+  Array<InstanceKlass*>* interfaces =  ik()->local_interfaces();
   int num_interfaces = interfaces->length();
   write_u2(num_interfaces);
   for (int index = 0; index < num_interfaces; index++) {
     HandleMark hm(thread());
-    InstanceKlass* iik = InstanceKlass::cast(interfaces->at(index));
+    InstanceKlass* iik = interfaces->at(index);
     write_u2(class_symbol_to_cpool_index(iik->name()));
   }
 
--- a/src/hotspot/share/prims/jvmtiEnv.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiEnv.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -2630,11 +2630,11 @@
       return JVMTI_ERROR_NONE;
     }
 
-    Array<Klass*>* interface_list = InstanceKlass::cast(k)->local_interfaces();
+    Array<InstanceKlass*>* interface_list = InstanceKlass::cast(k)->local_interfaces();
     const int result_length = (interface_list == NULL ? 0 : interface_list->length());
     jclass* result_list = (jclass*) jvmtiMalloc(result_length * sizeof(jclass));
     for (int i_index = 0; i_index < result_length; i_index += 1) {
-      Klass* klass_at = interface_list->at(i_index);
+      InstanceKlass* klass_at = interface_list->at(i_index);
       assert(klass_at->is_klass(), "interfaces must be Klass*s");
       assert(klass_at->is_interface(), "interfaces must be interfaces");
       oop mirror_at = klass_at->java_mirror();
--- a/src/hotspot/share/prims/jvmtiImpl.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiImpl.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -621,7 +621,7 @@
     }
   }
   // Compare secondary supers
-  Array<Klass*>* sec_supers = klass->secondary_supers();
+  const Array<Klass*>* sec_supers = klass->secondary_supers();
   for (idx = 0; idx < sec_supers->length(); idx++) {
     if (((Klass*) sec_supers->at(idx))->name() == ty_sym) {
       return true;
--- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -795,8 +795,8 @@
   // technically a bit more difficult, and, more importantly, I am not sure at present that the
   // order of interfaces does not matter on the implementation level, i.e. that the VM does not
   // rely on it somewhere.
-  Array<Klass*>* k_interfaces = the_class->local_interfaces();
-  Array<Klass*>* k_new_interfaces = scratch_class->local_interfaces();
+  Array<InstanceKlass*>* k_interfaces = the_class->local_interfaces();
+  Array<InstanceKlass*>* k_new_interfaces = scratch_class->local_interfaces();
   int n_intfs = k_interfaces->length();
   if (n_intfs != k_new_interfaces->length()) {
     return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED;
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -2838,7 +2838,7 @@
     oop mirror = klass->java_mirror();
 
     // super (only if something more interesting than java.lang.Object)
-    Klass* java_super = ik->java_super();
+    InstanceKlass* java_super = ik->java_super();
     if (java_super != NULL && java_super != SystemDictionary::Object_klass()) {
       oop super = java_super->java_mirror();
       if (!CallbackInvoker::report_superclass_reference(mirror, super)) {
@@ -2894,9 +2894,9 @@
     // interfaces
     // (These will already have been reported as references from the constant pool
     //  but are specified by IterateOverReachableObjects and must be reported).
-    Array<Klass*>* interfaces = ik->local_interfaces();
+    Array<InstanceKlass*>* interfaces = ik->local_interfaces();
     for (i = 0; i < interfaces->length(); i++) {
-      oop interf = ((Klass*)interfaces->at(i))->java_mirror();
+      oop interf = interfaces->at(i)->java_mirror();
       if (interf == NULL) {
         continue;
       }
--- a/src/hotspot/share/prims/methodHandles.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/prims/methodHandles.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -219,7 +219,7 @@
   assert(info.resolved_appendix().is_null(), "only normal methods here");
   methodHandle m = info.resolved_method();
   assert(m.not_null(), "null method handle");
-  Klass* m_klass = m->method_holder();
+  InstanceKlass* m_klass = m->method_holder();
   assert(m_klass != NULL, "null holder for method handle");
   int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS );
   int vmindex = Method::invalid_vtable_index;
@@ -257,7 +257,8 @@
       // This is a vtable call to an interface method (abstract "miranda method" or default method).
       // The vtable index is meaningless without a class (not interface) receiver type, so get one.
       // (LinkResolver should help us figure this out.)
-      Klass* m_klass_non_interface = info.resolved_klass();
+      assert(info.resolved_klass()->is_instance_klass(), "subtype of interface must be an instance klass");
+      InstanceKlass* m_klass_non_interface = InstanceKlass::cast(info.resolved_klass());
       if (m_klass_non_interface->is_interface()) {
         m_klass_non_interface = SystemDictionary::Object_klass();
 #ifdef ASSERT
--- a/src/hotspot/share/runtime/reflectionUtils.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/runtime/reflectionUtils.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -33,7 +33,7 @@
   _base_class_search_defaults = false;
   _defaults_checked = false;
   if (classes_only) {
-    _interfaces = Universe::the_empty_klass_array();
+    _interfaces = Universe::the_empty_instance_klass_array();
   } else {
     _interfaces = klass->transitive_interfaces();
   }
@@ -48,7 +48,7 @@
   if (_local_only) return true;
   if (!_klass->is_interface() && _klass->super() != NULL) {
     // go up superclass chain (not for interfaces)
-    _klass = InstanceKlass::cast(_klass->super());
+    _klass = _klass->java_super();
   // Next for method walks, walk default methods
   } else if (_walk_defaults && (_defaults_checked == false)  && (_base_klass->default_methods() != NULL)) {
       _base_class_search_defaults = true;
@@ -57,7 +57,7 @@
   } else {
     // Next walk transitive interfaces
     if (_interface_index > 0) {
-      _klass = InstanceKlass::cast(_interfaces->at(--_interface_index));
+      _klass = _interfaces->at(--_interface_index);
     } else {
       return true;
     }
--- a/src/hotspot/share/runtime/reflectionUtils.hpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/runtime/reflectionUtils.hpp	Tue Aug 07 15:45:07 2018 -0700
@@ -48,7 +48,7 @@
  protected:
   InstanceKlass*      _klass;           // current klass/interface iterated over
   InstanceKlass*      _base_klass;      // initial klass/interface to iterate over
-  Array<Klass*>*      _interfaces;      // transitive interfaces for initial class
+  Array<InstanceKlass*>*_interfaces;    // transitive interfaces for initial class
   int                 _interface_index; // current interface being processed
   bool                _local_only;      // process initial class/interface only
   bool                _classes_only;    // process classes only (no interfaces)
--- a/src/hotspot/share/runtime/vmStructs.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/runtime/vmStructs.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -225,8 +225,8 @@
   volatile_nonstatic_field(InstanceKlass,      _array_klasses,                                Klass*)                                \
   nonstatic_field(InstanceKlass,               _methods,                                      Array<Method*>*)                       \
   nonstatic_field(InstanceKlass,               _default_methods,                              Array<Method*>*)                       \
-  nonstatic_field(InstanceKlass,               _local_interfaces,                             Array<Klass*>*)                        \
-  nonstatic_field(InstanceKlass,               _transitive_interfaces,                        Array<Klass*>*)                        \
+  nonstatic_field(InstanceKlass,               _local_interfaces,                             Array<InstanceKlass*>*)                \
+  nonstatic_field(InstanceKlass,               _transitive_interfaces,                        Array<InstanceKlass*>*)                \
   nonstatic_field(InstanceKlass,               _fields,                                       Array<u2>*)                            \
   nonstatic_field(InstanceKlass,               _java_fields_count,                            u2)                                    \
   nonstatic_field(InstanceKlass,               _constants,                                    ConstantPool*)                         \
--- a/src/hotspot/share/services/heapDumper.cpp	Tue Aug 07 16:07:47 2018 -0700
+++ b/src/hotspot/share/services/heapDumper.cpp	Tue Aug 07 15:45:07 2018 -0700
@@ -989,7 +989,7 @@
   writer->write_u4(STACK_TRACE_ID);
 
   // super class ID
-  Klass* java_super = ik->java_super();
+  InstanceKlass* java_super = ik->java_super();
   if (java_super == NULL) {
     writer->write_objectID(oop(NULL));
   } else {
@@ -1059,7 +1059,7 @@
     writer->write_u4(STACK_TRACE_ID);
 
     // super class of array classes is java.lang.Object
-    Klass* java_super = klass->java_super();
+    InstanceKlass* java_super = klass->java_super();
     assert(java_super != NULL, "checking");
     writer->write_classID(java_super);