changeset 3845:80e866b1d053

Merge
author coleenp
date Fri, 16 Nov 2012 09:19:12 -0500
parents 6b6ddf8c4329 24e193d2a007
children cfc5309f03b7
files src/share/vm/ci/ciEnv.cpp src/share/vm/classfile/javaClasses.cpp src/share/vm/classfile/javaClasses.hpp src/share/vm/code/dependencies.cpp src/share/vm/interpreter/interpreterRuntime.cpp src/share/vm/memory/universe.cpp src/share/vm/oops/cpCache.cpp src/share/vm/oops/instanceKlass.cpp src/share/vm/prims/jni.cpp src/share/vm/prims/jvmtiExport.cpp src/share/vm/runtime/globals.hpp src/share/vm/runtime/os.cpp src/share/vm/runtime/thread.cpp
diffstat 65 files changed, 516 insertions(+), 482 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/c1/c1_Runtime1.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -374,7 +374,7 @@
 
 JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* thread, oopDesc* obj))
   ResourceMark rm(thread);
-  const char* klass_name = Klass::cast(obj->klass())->external_name();
+  const char* klass_name = obj->klass()->external_name();
   SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayStoreException(), klass_name);
 JRT_END
 
@@ -631,7 +631,7 @@
   NOT_PRODUCT(_throw_class_cast_exception_count++;)
   ResourceMark rm(thread);
   char* message = SharedRuntime::generate_class_cast_message(
-    thread, Klass::cast(object->klass())->external_name());
+    thread, object->klass()->external_name());
   SharedRuntime::throw_and_post_jvmti_exception(
     thread, vmSymbols::java_lang_ClassCastException(), message);
 JRT_END
@@ -876,7 +876,7 @@
       case Bytecodes::_anewarray:
         { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci));
           Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK);
-          k = Klass::cast(ek)->array_klass(CHECK);
+          k = ek->array_klass(CHECK);
         }
         break;
       case Bytecodes::_ldc:
@@ -1236,7 +1236,7 @@
   } else {
     Klass* bound = ObjArrayKlass::cast(dst->klass())->element_klass();
     Klass* stype = ObjArrayKlass::cast(src->klass())->element_klass();
-    if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
+    if (stype == bound || stype->is_subtype_of(bound)) {
       // Elements are guaranteed to be subtypes, so no check necessary
       bs->write_ref_array_pre(dst_addr, length);
       Copy::conjoint_oops_atomic(src_addr, dst_addr, length);
--- a/src/share/vm/ci/ciEnv.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/ci/ciEnv.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -427,7 +427,7 @@
     for (int i = cpool->length() - 1; i >= 1; i--) {
       if (cpool->tag_at(i).is_klass()) {
         Klass* kls = cpool->resolved_klass_at(i);
-        if (Klass::cast(kls)->name() == sym) {
+        if (kls->name() == sym) {
           found_klass = KlassHandle(THREAD, kls);
           break;
         }
--- a/src/share/vm/ci/ciType.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/ci/ciType.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -45,7 +45,7 @@
 }
 
 ciType::ciType(KlassHandle k) : ciMetadata(k()) {
-  _basic_type = Klass::cast(k())->oop_is_array() ? T_ARRAY : T_OBJECT;
+  _basic_type = k()->oop_is_array() ? T_ARRAY : T_OBJECT;
 }
 
 
--- a/src/share/vm/classfile/classFileParser.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/classFileParser.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -824,7 +824,7 @@
       interf = KlassHandle(THREAD, k);
     }
 
-    if (!Klass::cast(interf())->is_interface()) {
+    if (!interf()->is_interface()) {
       THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL);
     }
     if (InstanceKlass::cast(interf())->has_default_methods()) {
@@ -3831,7 +3831,7 @@
     if (TraceClassResolution) {
       ResourceMark rm;
       // print out the superclass.
-      const char * from = Klass::cast(this_klass())->external_name();
+      const char * from = this_klass()->external_name();
       if (this_klass->java_super() != NULL) {
         tty->print("RESOLVE %s %s (super)\n", from, InstanceKlass::cast(this_klass->java_super())->external_name());
       }
@@ -3982,13 +3982,13 @@
     // java.lang.Object has empty default constructor
     k->set_has_vanilla_constructor();
   } else {
-    if (Klass::cast(super)->has_vanilla_constructor() &&
+    if (super->has_vanilla_constructor() &&
         _has_vanilla_constructor) {
       k->set_has_vanilla_constructor();
     }
 #ifdef ASSERT
     bool v = false;
-    if (Klass::cast(super)->has_vanilla_constructor()) {
+    if (super->has_vanilla_constructor()) {
       Method* constructor = k->find_method(vmSymbols::object_initializer_name(
 ), vmSymbols::void_method_signature());
       if (constructor != NULL && constructor->is_vanilla_constructor()) {
@@ -4130,7 +4130,7 @@
   int lng = local_interfaces->length();
   for (int i = lng - 1; i >= 0; i--) {
     Klass* k = local_interfaces->at(i);
-    assert (k != NULL && Klass::cast(k)->is_interface(), "invalid interface");
+    assert (k != NULL && k->is_interface(), "invalid interface");
     if (!Reflection::verify_class_access(this_klass(), k, false)) {
       ResourceMark rm(THREAD);
       Exceptions::fthrow(
--- a/src/share/vm/classfile/dictionary.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/dictionary.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -346,7 +346,7 @@
                            KlassHandle obj) {
   assert_locked_or_safepoint(SystemDictionary_lock);
   assert(obj() != NULL, "adding NULL obj");
-  assert(Klass::cast(obj())->name() == class_name, "sanity check on name");
+  assert(obj()->name() == class_name, "sanity check on name");
 
   unsigned int hash = compute_hash(class_name, loader_data);
   int index = hash_to_index(hash);
@@ -553,7 +553,7 @@
       bool is_defining_class =
          (loader_data == InstanceKlass::cast(e)->class_loader_data());
       tty->print("%s%s", is_defining_class ? " " : "^",
-                   Klass::cast(e)->external_name());
+                   e->external_name());
 
         tty->print(", loader ");
       loader_data->print_value();
@@ -575,7 +575,7 @@
                           probe = probe->next()) {
       Klass* e = probe->klass();
       ClassLoaderData* loader_data = probe->loader_data();
-      guarantee(Klass::cast(e)->oop_is_instance(),
+      guarantee(e->oop_is_instance(),
                               "Verify of system dictionary failed");
       // class loader must be present;  a null class loader is the
       // boostrap loader
--- a/src/share/vm/classfile/javaClasses.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/javaClasses.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -561,7 +561,7 @@
         assert(k->oop_is_objArray(), "Must be");
         Klass* element_klass = ObjArrayKlass::cast(k())->element_klass();
         assert(element_klass != NULL, "Must have an element klass");
-          comp_mirror = Klass::cast(element_klass)->java_mirror();
+          comp_mirror = element_klass->java_mirror();
       }
       assert(comp_mirror.not_null(), "must have a mirror");
 
@@ -644,8 +644,8 @@
     name = vmSymbols::type_signature(primitive_type(java_class));
   } else {
     Klass* k = as_Klass(java_class);
-    is_instance = Klass::cast(k)->oop_is_instance();
-    name = Klass::cast(k)->name();
+    is_instance = k->oop_is_instance();
+    name = k->name();
   }
   if (name == NULL) {
     st->print("<null>");
@@ -667,12 +667,12 @@
     name->increment_refcount();
   } else {
     Klass* k = as_Klass(java_class);
-    if (!Klass::cast(k)->oop_is_instance()) {
-      name = Klass::cast(k)->name();
+    if (!k->oop_is_instance()) {
+      name = k->name();
       name->increment_refcount();
     } else {
       ResourceMark rm;
-      const char* sigstr = Klass::cast(k)->signature_name();
+      const char* sigstr = k->signature_name();
       int         siglen = (int) strlen(sigstr);
       if (!intern_if_not_found) {
         name = SymbolTable::probe(sigstr, siglen);
@@ -687,13 +687,13 @@
 
 Klass* java_lang_Class::array_klass(oop java_class) {
   Klass* k = ((Klass*)java_class->metadata_field(_array_klass_offset));
-  assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_array(), "should be array klass");
+  assert(k == NULL || k->is_klass() && k->oop_is_array(), "should be array klass");
   return k;
 }
 
 
 void java_lang_Class::set_array_klass(oop java_class, Klass* klass) {
-  assert(klass->is_klass() && Klass::cast(klass)->oop_is_array(), "should be array klass");
+  assert(klass->is_klass() && klass->oop_is_array(), "should be array klass");
   java_class->metadata_field_put(_array_klass_offset, klass);
 }
 
--- a/src/share/vm/classfile/javaClasses.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/javaClasses.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -914,7 +914,7 @@
 
   // Testers
   static bool is_subclass(Klass* klass) {
-    return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass());
+    return klass->is_subclass_of(SystemDictionary::MethodHandle_klass());
   }
   static bool is_instance(oop obj) {
     return obj != NULL && is_subclass(obj->klass());
@@ -944,7 +944,7 @@
   // Testers
   static bool is_subclass(Klass* klass) {
     return SystemDictionary::LambdaForm_klass() != NULL &&
-      Klass::cast(klass)->is_subclass_of(SystemDictionary::LambdaForm_klass());
+      klass->is_subclass_of(SystemDictionary::LambdaForm_klass());
   }
   static bool is_instance(oop obj) {
     return obj != NULL && is_subclass(obj->klass());
@@ -1006,7 +1006,7 @@
 
   // Testers
   static bool is_subclass(Klass* klass) {
-    return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass());
+    return klass->is_subclass_of(SystemDictionary::MemberName_klass());
   }
   static bool is_instance(oop obj) {
     return obj != NULL && is_subclass(obj->klass());
@@ -1092,7 +1092,7 @@
 
   // Testers
   static bool is_subclass(Klass* klass) {
-    return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass());
+    return klass->is_subclass_of(SystemDictionary::CallSite_klass());
   }
   static bool is_instance(oop obj) {
     return obj != NULL && is_subclass(obj->klass());
@@ -1162,7 +1162,7 @@
 
   // Testers
   static bool is_subclass(Klass* klass) {
-    return Klass::cast(klass)->is_subclass_of(SystemDictionary::ClassLoader_klass());
+    return klass->is_subclass_of(SystemDictionary::ClassLoader_klass());
   }
   static bool is_instance(oop obj) {
     return obj != NULL && is_subclass(obj->klass());
--- a/src/share/vm/classfile/loaderConstraints.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/loaderConstraints.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -320,7 +320,7 @@
                                                        Handle loader) {
   LoaderConstraintEntry *p = *(find_loader_constraint(name, loader));
   if (p != NULL && p->klass() != NULL) {
-    if (Klass::cast(p->klass())->oop_is_instance() && !InstanceKlass::cast(p->klass())->is_loaded()) {
+    if (p->klass()->oop_is_instance() && !InstanceKlass::cast(p->klass())->is_loaded()) {
       // Only return fully loaded classes.  Classes found through the
       // constraints might still be in the process of loading.
       return NULL;
--- a/src/share/vm/classfile/placeholders.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/placeholders.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -45,7 +45,7 @@
   entry->set_loadInstanceThreadQ(NULL);
   entry->set_defineThreadQ(NULL);
   entry->set_definer(NULL);
-  entry->set_instanceKlass(NULL);
+  entry->set_instance_klass(NULL);
   return entry;
 }
 
@@ -188,7 +188,7 @@
 void PlaceholderEntry::classes_do(KlassClosure* closure) {
   assert(klassname() != NULL, "should have a non-null klass");
   if (_instanceKlass != NULL) {
-    closure->do_klass(InstanceKlass());
+    closure->do_klass(instance_klass());
   }
 }
 
@@ -220,9 +220,9 @@
     tty->print(", definer ");
     definer()->print_value();
   }
-  if (InstanceKlass() != NULL) {
+  if (instance_klass() != NULL) {
     tty->print(", InstanceKlass ");
-    InstanceKlass()->print_value();
+    instance_klass()->print_value();
   }
   tty->print("\n");
   tty->print("loadInstanceThreadQ threads:");
@@ -241,9 +241,9 @@
   guarantee(loader_data() != NULL, "Must have been setup.");
   guarantee(loader_data()->class_loader() == NULL || loader_data()->class_loader()->is_instance(),
             "checking type of _loader");
-  guarantee(InstanceKlass() == NULL
-            || Klass::cast(InstanceKlass())->oop_is_instance(),
-            "checking type of InstanceKlass result");
+  guarantee(instance_klass() == NULL
+            || instance_klass()->oop_is_instance(),
+            "checking type of instance_klass result");
 }
 
 void PlaceholderTable::verify() {
--- a/src/share/vm/classfile/placeholders.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/placeholders.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -191,8 +191,8 @@
   Thread*            definer()             const {return _definer; }
   void               set_definer(Thread* definer) { _definer = definer; }
 
-  Klass*             InstanceKlass()     const {return _instanceKlass; }
-  void               set_instanceKlass(Klass* InstanceKlass) { _instanceKlass = InstanceKlass; }
+  Klass*             instance_klass()      const {return _instanceKlass; }
+  void               set_instance_klass(Klass* ik) { _instanceKlass = ik; }
 
   SeenThread*        superThreadQ()        const { return _superThreadQ; }
   void               set_superThreadQ(SeenThread* SeenThread) { _superThreadQ = SeenThread; }
--- a/src/share/vm/classfile/symbolTable.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/symbolTable.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -262,19 +262,14 @@
   // The string table
   static StringTable* the_table() { return _the_table; }
 
+  // Size of one bucket in the string table.  Used when checking for rollover.
+  static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }
+
   static void create_table() {
     assert(_the_table == NULL, "One string table allowed.");
     _the_table = new StringTable();
   }
 
-  static void create_table(HashtableBucket<mtSymbol>* t, int length,
-                           int number_of_entries) {
-    assert(_the_table == NULL, "One string table allowed.");
-    assert((size_t)length == StringTableSize * sizeof(HashtableBucket<mtSymbol>),
-           "bad shared string size.");
-    _the_table = new StringTable(t, number_of_entries);
-  }
-
   // GC support
   //   Delete pointers to otherwise-unreachable objects.
   static void unlink(BoolObjectClosure* cl);
--- a/src/share/vm/classfile/systemDictionary.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/classfile/systemDictionary.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -240,7 +240,7 @@
                                                          protection_domain,
                                                          CHECK_NULL);
     if (k != NULL) {
-      k = Klass::cast(k)->array_klass(fd.dimension(), CHECK_NULL);
+      k = k->array_klass(fd.dimension(), CHECK_NULL);
     }
   } else {
     k = Universe::typeArrayKlassObj(t);
@@ -328,8 +328,8 @@
     if ((childk != NULL ) && (is_superclass) &&
        ((quicksuperk = InstanceKlass::cast(childk)->super()) != NULL) &&
 
-         ((Klass::cast(quicksuperk)->name() == class_name) &&
-            (Klass::cast(quicksuperk)->class_loader()  == class_loader()))) {
+         ((quicksuperk->name() == class_name) &&
+            (quicksuperk->class_loader()  == class_loader()))) {
            return quicksuperk;
     } else {
       PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, loader_data);
@@ -928,7 +928,7 @@
       k = SystemDictionary::find(fd.object_key(), class_loader, protection_domain, THREAD);
     }
     if (k != NULL) {
-      k = Klass::cast(k)->array_klass_or_null(fd.dimension());
+      k = k->array_klass_or_null(fd.dimension());
     }
   } else {
     k = find(class_name, class_loader, protection_domain, THREAD);
@@ -1537,7 +1537,7 @@
     // Only special cases allow parallel defines and can use other thread's results
     // Other cases fall through, and may run into duplicate defines
     // caught by finding an entry in the SystemDictionary
-    if ((UnsyncloadClass || is_parallelDefine(class_loader)) && (probe->InstanceKlass() != NULL)) {
+    if ((UnsyncloadClass || is_parallelDefine(class_loader)) && (probe->instance_klass() != NULL)) {
         probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS);
         placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, THREAD);
         SystemDictionary_lock->notify_all();
@@ -1545,7 +1545,7 @@
         Klass* check = find_class(d_index, d_hash, name_h, loader_data);
         assert(check != NULL, "definer missed recording success");
 #endif
-        return(instanceKlassHandle(THREAD, probe->InstanceKlass()));
+        return(instanceKlassHandle(THREAD, probe->instance_klass()));
     } else {
       // This thread will define the class (even if earlier thread tried and had an error)
       probe->set_definer(THREAD);
@@ -1566,7 +1566,7 @@
         linkage_exception = Handle(THREAD,PENDING_EXCEPTION);
         CLEAR_PENDING_EXCEPTION;
       } else {
-        probe->set_instanceKlass(k());
+        probe->set_instance_klass(k());
       }
       probe->set_definer(NULL);
       probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS);
@@ -2149,7 +2149,7 @@
     }
     // If element class already loaded, allocate array klass
     if (klass != NULL) {
-      klass = Klass::cast(klass)->array_klass_or_null(fd.dimension());
+      klass = klass->array_klass_or_null(fd.dimension());
     }
   } else {
     MutexLocker mu(SystemDictionary_lock, THREAD);
@@ -2466,9 +2466,9 @@
       Klass* sel_klass = java_lang_Class::as_Klass(mirror);
       mirror = NULL;  // safety
       // Emulate ConstantPool::verify_constant_pool_resolve.
-      if (Klass::cast(sel_klass)->oop_is_objArray())
+      if (sel_klass->oop_is_objArray())
         sel_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass();
-      if (Klass::cast(sel_klass)->oop_is_instance()) {
+      if (sel_klass->oop_is_instance()) {
         KlassHandle sel_kh(THREAD, sel_klass);
         LinkResolver::check_klass_accessability(accessing_klass, sel_kh, CHECK_(empty));
       }
--- a/src/share/vm/code/dependencies.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/code/dependencies.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -552,7 +552,7 @@
     }
     tty->print("  %s = %s", what, (put_star? "*": ""));
     if (arg.is_klass())
-      tty->print("%s", Klass::cast((Klass*)arg.metadata_value())->external_name());
+      tty->print("%s", ((Klass*)arg.metadata_value())->external_name());
     else if (arg.is_method())
       ((Method*)arg.metadata_value())->print_value();
     else
@@ -563,7 +563,7 @@
     bool put_star = !Dependencies::is_concrete_klass(witness);
     tty->print_cr("  witness = %s%s",
                   (put_star? "*": ""),
-                  Klass::cast(witness)->external_name());
+                  witness->external_name());
   }
 }
 
@@ -809,7 +809,7 @@
     if (!(m->is_public() || m->is_protected()))
       // The override story is complex when packages get involved.
       return true;  // Must punt the assertion to true.
-    Klass* k = Klass::cast(ctxk);
+    Klass* k = ctxk;
     Method* lm = k->lookup_method(m->name(), m->signature());
     if (lm == NULL && k->oop_is_instance()) {
       // It might be an abstract interface method, devoid of mirandas.
@@ -836,7 +836,7 @@
     }
     ResourceMark rm;
     tty->print_cr("Dependency method not found in the associated context:");
-    tty->print_cr("  context = %s", Klass::cast(ctxk)->external_name());
+    tty->print_cr("  context = %s", ctxk->external_name());
     tty->print(   "  method = "); m->print_short_name(tty); tty->cr();
     if (lm != NULL) {
       tty->print( "  found = "); lm->print_short_name(tty); tty->cr();
@@ -1011,7 +1011,7 @@
     for (int i = 0; i < num_participants(); i++) {
       Klass* part = participant(i);
       if (part == NULL)  continue;
-      assert(changes.involves_context(part) == Klass::cast(new_type)->is_subtype_of(part),
+      assert(changes.involves_context(part) == new_type->is_subtype_of(part),
              "correct marking of participants, b/c new_type is unique");
       if (changes.involves_context(part)) {
         // new guy is protected from this check by previous participant
@@ -1147,7 +1147,7 @@
 
 
 bool Dependencies::is_concrete_klass(Klass* k) {
-  if (Klass::cast(k)->is_abstract())  return false;
+  if (k->is_abstract())  return false;
   // %%% We could treat classes which are concrete but
   // have not yet been instantiated as virtually abstract.
   // This would require a deoptimization barrier on first instantiation.
@@ -1706,12 +1706,12 @@
 }
 
 bool KlassDepChange::involves_context(Klass* k) {
-  if (k == NULL || !Klass::cast(k)->oop_is_instance()) {
+  if (k == NULL || !k->oop_is_instance()) {
     return false;
   }
   InstanceKlass* ik = InstanceKlass::cast(k);
   bool is_contained = ik->is_marked_dependent();
-  assert(is_contained == Klass::cast(new_type())->is_subtype_of(k),
+  assert(is_contained == new_type()->is_subtype_of(k),
          "correct marking of potential context types");
   return is_contained;
 }
--- a/src/share/vm/code/nmethod.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/code/nmethod.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -2568,9 +2568,8 @@
     deps.print_dependency();
     Klass* ctxk = deps.context_type();
     if (ctxk != NULL) {
-      Klass* k = Klass::cast(ctxk);
-      if (k->oop_is_instance() && ((InstanceKlass*)k)->is_dependent_nmethod(this)) {
-        tty->print_cr("   [nmethod<=klass]%s", k->external_name());
+      if (ctxk->oop_is_instance() && ((InstanceKlass*)ctxk)->is_dependent_nmethod(this)) {
+        tty->print_cr("   [nmethod<=klass]%s", ctxk->external_name());
       }
     }
     deps.log_dependency();  // put it into the xml log also
--- a/src/share/vm/compiler/disassembler.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/compiler/disassembler.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -353,7 +353,7 @@
       obj->print_value_on(st);
       if (st->count() == c) {
         // No output.  (Can happen in product builds.)
-        st->print("(a %s)", Klass::cast(obj->klass())->external_name());
+        st->print("(a %s)", obj->klass()->external_name());
       }
       return;
     }
--- a/src/share/vm/interpreter/bytecodeInterpreter.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -2043,8 +2043,8 @@
             if (objKlassOop != klassOf &&
                 !objKlassOop->is_subtype_of(klassOf)) {
               ResourceMark rm(THREAD);
-              const char* objName = Klass::cast(objKlassOop)->external_name();
-              const char* klassName = Klass::cast(klassOf)->external_name();
+              const char* objName = objKlassOop->external_name();
+              const char* klassName = klassOf->external_name();
               char* message = SharedRuntime::generate_class_cast_message(
                 objName, klassName);
               VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message);
--- a/src/share/vm/interpreter/interpreterRuntime.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -312,7 +312,7 @@
 
 IRT_ENTRY(void, InterpreterRuntime::create_klass_exception(JavaThread* thread, char* name, oopDesc* obj))
   ResourceMark rm(thread);
-  const char* klass_name = Klass::cast(obj->klass())->external_name();
+  const char* klass_name = obj->klass()->external_name();
   // lookup exception klass
   TempNewSymbol s = SymbolTable::new_symbol(name, CHECK);
   if (ProfileTraps) {
@@ -341,7 +341,7 @@
 
   ResourceMark rm(thread);
   char* message = SharedRuntime::generate_class_cast_message(
-    thread, Klass::cast(obj->klass())->external_name());
+    thread, obj->klass()->external_name());
 
   if (ProfileTraps) {
     note_trap(thread, Deoptimization::Reason_class_check, CHECK);
--- a/src/share/vm/interpreter/linkResolver.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/interpreter/linkResolver.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -203,7 +203,7 @@
   Method* result_oop = klass->uncached_lookup_method(name, signature);
   result = methodHandle(THREAD, result_oop);
   while (!result.is_null() && result->is_static()) {
-    klass = KlassHandle(THREAD, Klass::cast(result->method_holder())->super());
+    klass = KlassHandle(THREAD, result->method_holder()->super());
     result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature));
   }
 }
@@ -428,7 +428,7 @@
       // 3. method lookup failed
       ResourceMark rm(THREAD);
       THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(),
-                      Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+                      Method::name_and_sig_as_C_string(resolved_klass(),
                                                               method_name,
                                                               method_signature),
                       nested_exception);
@@ -448,7 +448,7 @@
   if (resolved_method->is_abstract() && !resolved_klass->is_abstract()) {
     ResourceMark rm(THREAD);
     THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-              Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+              Method::name_and_sig_as_C_string(resolved_klass(),
                                                       method_name,
                                                       method_signature));
   }
@@ -477,7 +477,7 @@
           " \"%s\" the class loader (instance of %s) of the current class, %s,"
           " and the class loader (instance of %s) for resolved class, %s, have"
           " different Class objects for the type %s used in the signature";
-        char* sig = Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature);
+        char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature);
         const char* loader1 = SystemDictionary::loader_name(loader());
         char* current = InstanceKlass::cast(current_klass())->name()->as_C_string();
         const char* loader2 = SystemDictionary::loader_name(class_loader());
@@ -505,7 +505,7 @@
   if (!resolved_klass->is_interface()) {
     ResourceMark rm(THREAD);
     char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", Klass::cast(resolved_klass())->external_name());
+    jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name());
     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
@@ -519,7 +519,7 @@
       // no method found
       ResourceMark rm(THREAD);
       THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
-                Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+                Method::name_and_sig_as_C_string(resolved_klass(),
                                                         method_name,
                                                         method_signature));
     }
@@ -540,7 +540,7 @@
           "current class, %s, and the class loader (instance of %s) for "
           "resolved class, %s, have different Class objects for the type %s "
           "used in the signature";
-        char* sig = Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature);
+        char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature);
         const char* loader1 = SystemDictionary::loader_name(loader());
         char* current = InstanceKlass::cast(current_klass())->name()->as_C_string();
         const char* loader2 = SystemDictionary::loader_name(class_loader());
@@ -627,7 +627,7 @@
   if (is_static != fd.is_static()) {
     ResourceMark rm(THREAD);
     char msg[200];
-    jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", Klass::cast(resolved_klass())->external_name(), fd.name()->as_C_string());
+    jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string());
     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
   }
 
@@ -701,7 +701,7 @@
                                        bool check_access, bool initialize_class, TRAPS) {
   methodHandle resolved_method;
   linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
-  resolved_klass = KlassHandle(THREAD, Klass::cast(resolved_method->method_holder()));
+  resolved_klass = KlassHandle(THREAD, resolved_method->method_holder());
 
   // Initialize klass (this should only happen if everything is ok)
   if (initialize_class && resolved_klass->should_be_initialized()) {
@@ -725,7 +725,7 @@
   if (!resolved_method->is_static()) {
     ResourceMark rm(THREAD);
     char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+    jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(),
                                                       resolved_method->name(),
                                                       resolved_method->signature()));
     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
@@ -789,7 +789,7 @@
     char buf[200];
     jio_snprintf(buf, sizeof(buf),
                  "Expecting non-static method %s",
-                 Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+                 Method::name_and_sig_as_C_string(resolved_klass(),
                                                          resolved_method->name(),
                                                          resolved_method->signature()));
     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
@@ -829,7 +829,7 @@
       if (sel_method.is_null()) {
         ResourceMark rm(THREAD);
         THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-                  Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+                  Method::name_and_sig_as_C_string(resolved_klass(),
                                             resolved_method->name(),
                                             resolved_method->signature()));
       }
@@ -840,7 +840,7 @@
   if (sel_method->is_static()) {
     ResourceMark rm(THREAD);
     char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(),
                                                                                                              resolved_method->name(),
                                                                                                              resolved_method->signature()));
     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
@@ -850,7 +850,7 @@
   if (sel_method->is_abstract()) {
     ResourceMark rm(THREAD);
     THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-              Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+              Method::name_and_sig_as_C_string(resolved_klass(),
                                                       sel_method->name(),
                                                       sel_method->signature()));
   }
@@ -881,7 +881,7 @@
   if (resolved_method->is_static()) {
     ResourceMark rm(THREAD);
     char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(),
                                                                                                              resolved_method->name(),
                                                                                                              resolved_method->signature()));
     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
@@ -950,7 +950,7 @@
   if (selected_method.is_null()) {
     ResourceMark rm(THREAD);
     THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-              Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+              Method::name_and_sig_as_C_string(resolved_klass(),
                                                       resolved_method->name(),
                                                       resolved_method->signature()));
   }
@@ -959,7 +959,7 @@
   if (check_null_and_abstract && selected_method->is_abstract()) {
     ResourceMark rm(THREAD);
     THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-              Method::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+              Method::name_and_sig_as_C_string(resolved_klass(),
                                                       selected_method->name(),
                                                       selected_method->signature()));
   }
@@ -999,8 +999,8 @@
     ResourceMark rm(THREAD);
     char buf[200];
     jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s",
-                 (Klass::cast(recv_klass()))->external_name(),
-                 (Klass::cast(resolved_klass()))->external_name());
+                 recv_klass()->external_name(),
+                 resolved_klass()->external_name());
     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
   // do lookup based on receiver klass
@@ -1012,7 +1012,7 @@
   if (sel_method.is_null()) {
     ResourceMark rm(THREAD);
     THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-              Method::name_and_sig_as_C_string(Klass::cast(recv_klass()),
+              Method::name_and_sig_as_C_string(recv_klass(),
                                                       resolved_method->name(),
                                                       resolved_method->signature()));
   }
@@ -1020,7 +1020,7 @@
   if (!sel_method->is_public()) {
     ResourceMark rm(THREAD);
     THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
-              Method::name_and_sig_as_C_string(Klass::cast(recv_klass()),
+              Method::name_and_sig_as_C_string(recv_klass(),
                                                       sel_method->name(),
                                                       sel_method->signature()));
   }
@@ -1028,7 +1028,7 @@
   if (check_null_and_abstract && sel_method->is_abstract()) {
     ResourceMark rm(THREAD);
     THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-              Method::name_and_sig_as_C_string(Klass::cast(recv_klass()),
+              Method::name_and_sig_as_C_string(recv_klass(),
                                                       sel_method->name(),
                                                       sel_method->signature()));
   }
--- a/src/share/vm/memory/metaspaceShared.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/memory/metaspaceShared.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -431,7 +431,7 @@
 }
 
 static void link_shared_classes(Klass* obj, TRAPS) {
-  Klass* k = Klass::cast(obj);
+  Klass* k = obj;
   if (k->oop_is_instance()) {
     InstanceKlass* ik = (InstanceKlass*) k;
     // Link the class to cause the bytecodes to be rewritten and the
--- a/src/share/vm/memory/universe.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/memory/universe.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -346,7 +346,7 @@
   // ---
   // New
   // Have already been initialized.
-  Klass::cast(_objectArrayKlassObj)->append_to_sibling_list();
+  _objectArrayKlassObj->append_to_sibling_list();
 
   // Compute is_jdk version flags.
   // Only 1.3 or later has the java.lang.Shutdown class.
--- a/src/share/vm/oops/arrayKlass.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/arrayKlass.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -67,7 +67,7 @@
 Method* ArrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
   // There are no methods in an array klass but the super class (Object) has some
   assert(super(), "super klass must be present");
-  return Klass::cast(super())->uncached_lookup_method(name, signature);
+  return super()->uncached_lookup_method(name, signature);
 }
 
 ArrayKlass::ArrayKlass(Symbol* name) {
--- a/src/share/vm/oops/cpCache.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/cpCache.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -371,7 +371,7 @@
         int holder_index = cpool->uncached_klass_ref_index_at(constant_pool_index());
         if (cpool->tag_at(holder_index).is_klass()) {
           Klass* klass = cpool->resolved_klass_at(holder_index);
-          if (!Klass::cast(klass)->oop_is_instance())
+          if (!klass->oop_is_instance())
             klass = SystemDictionary::Object_klass();
           return InstanceKlass::cast(klass)->method_at_vtable(f2_as_index());
         }
--- a/src/share/vm/oops/instanceKlass.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/instanceKlass.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -727,8 +727,8 @@
 
   // Step 7
   Klass* super_klass = this_oop->super();
-  if (super_klass != NULL && !this_oop->is_interface() && Klass::cast(super_klass)->should_be_initialized()) {
-    Klass::cast(super_klass)->initialize(THREAD);
+  if (super_klass != NULL && !this_oop->is_interface() && super_klass->should_be_initialized()) {
+    super_klass->initialize(THREAD);
 
     if (HAS_PENDING_EXCEPTION) {
       Handle e(THREAD, PENDING_EXCEPTION);
@@ -924,7 +924,7 @@
 }
 
 bool InstanceKlass::compute_is_subtype_of(Klass* k) {
-  if (Klass::cast(k)->is_interface()) {
+  if (k->is_interface()) {
     return implements_interface(k);
   } else {
     return Klass::compute_is_subtype_of(k);
@@ -933,7 +933,7 @@
 
 bool InstanceKlass::implements_interface(Klass* k) const {
   if (this == k) return true;
-  assert(Klass::cast(k)->is_interface(), "should be an interface class");
+  assert(k->is_interface(), "should be an interface class");
   for (int i = 0; i < transitive_interfaces()->length(); i++) {
     if (transitive_interfaces()->at(i) == k) {
       return true;
@@ -1107,7 +1107,7 @@
   const int n = local_interfaces()->length();
   for (int i = 0; i < n; i++) {
     Klass* intf1 = local_interfaces()->at(i);
-    assert(Klass::cast(intf1)->is_interface(), "just checking type");
+    assert(intf1->is_interface(), "just checking type");
     // search for field in current interface
     if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) {
       assert(fd->is_static(), "interface field must be static");
@@ -1178,7 +1178,7 @@
     if (InstanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) {
       return true;
     }
-    klass = Klass::cast(klass)->super();
+    klass = klass->super();
   }
   return false;
 }
@@ -2366,19 +2366,19 @@
 bool InstanceKlass::is_same_class_package(Klass* class2) {
   Klass* class1 = this;
   oop classloader1 = InstanceKlass::cast(class1)->class_loader();
-  Symbol* classname1 = Klass::cast(class1)->name();
-
-  if (Klass::cast(class2)->oop_is_objArray()) {
+  Symbol* classname1 = class1->name();
+
+  if (class2->oop_is_objArray()) {
     class2 = ObjArrayKlass::cast(class2)->bottom_klass();
   }
   oop classloader2;
-  if (Klass::cast(class2)->oop_is_instance()) {
+  if (class2->oop_is_instance()) {
     classloader2 = InstanceKlass::cast(class2)->class_loader();
   } else {
-    assert(Klass::cast(class2)->oop_is_typeArray(), "should be type array");
+    assert(class2->oop_is_typeArray(), "should be type array");
     classloader2 = NULL;
   }
-  Symbol* classname2 = Klass::cast(class2)->name();
+  Symbol* classname2 = class2->name();
 
   return InstanceKlass::is_same_class_package(classloader1, classname1,
                                               classloader2, classname2);
@@ -2387,7 +2387,7 @@
 bool InstanceKlass::is_same_class_package(oop classloader2, Symbol* classname2) {
   Klass* class1 = this;
   oop classloader1 = InstanceKlass::cast(class1)->class_loader();
-  Symbol* classname1 = Klass::cast(class1)->name();
+  Symbol* classname1 = class1->name();
 
   return InstanceKlass::is_same_class_package(classloader1, classname1,
                                               classloader2, classname2);
@@ -2478,7 +2478,7 @@
 bool InstanceKlass::is_same_package_member_impl(instanceKlassHandle class1,
                                                 Klass* class2_oop, TRAPS) {
   if (class2_oop == class1())                       return true;
-  if (!Klass::cast(class2_oop)->oop_is_instance())  return false;
+  if (!class2_oop->oop_is_instance())  return false;
   instanceKlassHandle class2(THREAD, class2_oop);
 
   // must be in same package before we try anything else
@@ -3011,7 +3011,7 @@
   if (im != NULL) {
     guarantee(is_interface(), "only interfaces should have implementor set");
     guarantee(im->is_klass(), "should be klass");
-    guarantee(!Klass::cast(im)->is_interface() || im == this,
+    guarantee(!im->is_interface() || im == this,
       "implementors cannot be interfaces");
   }
 
@@ -3020,7 +3020,7 @@
     Array<Klass*>* local_interfaces = this->local_interfaces();
     for (int j = 0; j < local_interfaces->length(); j++) {
       Klass* e = local_interfaces->at(j);
-      guarantee(e->is_klass() && Klass::cast(e)->is_interface(), "invalid local interface");
+      guarantee(e->is_klass() && e->is_interface(), "invalid local interface");
     }
   }
 
@@ -3029,7 +3029,7 @@
     Array<Klass*>* transitive_interfaces = this->transitive_interfaces();
     for (int j = 0; j < transitive_interfaces->length(); j++) {
       Klass* e = transitive_interfaces->at(j);
-      guarantee(e->is_klass() && Klass::cast(e)->is_interface(), "invalid transitive interface");
+      guarantee(e->is_klass() && e->is_interface(), "invalid transitive interface");
     }
   }
 
--- a/src/share/vm/oops/klass.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/klass.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -56,7 +56,7 @@
 
   while (t != NULL) {
     if (t == k) return true;
-    t = Klass::cast(t)->super();
+    t = t->super();
   }
   return false;
 }
@@ -243,16 +243,16 @@
       juint j = super_depth();
       assert(j == my_depth, "computed accessor gets right answer");
       Klass* t = this;
-      while (!Klass::cast(t)->can_be_primary_super()) {
-        t = Klass::cast(t)->super();
-        j = Klass::cast(t)->super_depth();
+      while (!t->can_be_primary_super()) {
+        t = t->super();
+        j = t->super_depth();
       }
       for (juint j1 = j+1; j1 < primary_super_limit(); j1++) {
         assert(primary_super_of_depth(j1) == NULL, "super list padding");
       }
       while (t != NULL) {
         assert(primary_super_of_depth(j) == t, "super list initialization");
-        t = Klass::cast(t)->super();
+        t = t->super();
         --j;
       }
       assert(j == (juint)-1, "correct depth count");
@@ -333,7 +333,7 @@
 
 
 Klass* Klass::subklass() const {
-  return _subklass == NULL ? NULL : Klass::cast(_subklass);
+  return _subklass == NULL ? NULL : _subklass;
 }
 
 InstanceKlass* Klass::superklass() const {
@@ -342,7 +342,7 @@
 }
 
 Klass* Klass::next_sibling() const {
-  return _next_sibling == NULL ? NULL : Klass::cast(_next_sibling);
+  return _next_sibling == NULL ? NULL : _next_sibling;
 }
 
 void Klass::set_subklass(Klass* s) {
--- a/src/share/vm/oops/klass.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/klass.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -422,12 +422,6 @@
   // if not, throw either an Error or an Exception.
   virtual void check_valid_for_instantiation(bool throwError, TRAPS);
 
-  // Casting
-  static Klass* cast(Klass* k) {
-    assert(k->is_klass(), "cast to Klass");
-    return k;
-  }
-
   // array copying
   virtual void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
 
--- a/src/share/vm/oops/klassVtable.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/klassVtable.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -746,7 +746,7 @@
     while (target != NULL && target->is_static()) {
       // continue with recursive lookup through the superclass
       Klass* super = target->method_holder()->super();
-      target = (super == NULL) ? (Method*)NULL : Klass::cast(super)->uncached_lookup_method(method_name, method_signature);
+      target = (super == NULL) ? (Method*)NULL : super->uncached_lookup_method(method_name, method_signature);
     }
     if (target == NULL || !target->is_public() || target->is_abstract()) {
       // Entry do not resolve. Leave it empty
@@ -852,7 +852,7 @@
   // Handle array argument
   for(int i = 0; i < transitive_intf->length(); i++) {
     Klass* intf = transitive_intf->at(i);
-    assert(Klass::cast(intf)->is_interface(), "sanity check");
+    assert(intf->is_interface(), "sanity check");
 
     // Find no. of methods excluding a <clinit>
     int method_count = InstanceKlass::cast(intf)->methods()->length();
--- a/src/share/vm/oops/method.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/method.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -152,11 +152,11 @@
 }
 
 char* Method::name_and_sig_as_C_string() const {
-  return name_and_sig_as_C_string(Klass::cast(constants()->pool_holder()), name(), signature());
+  return name_and_sig_as_C_string(constants()->pool_holder(), name(), signature());
 }
 
 char* Method::name_and_sig_as_C_string(char* buf, int size) const {
-  return name_and_sig_as_C_string(Klass::cast(constants()->pool_holder()), name(), signature(), buf, size);
+  return name_and_sig_as_C_string(constants()->pool_holder(), name(), signature(), buf, size);
 }
 
 char* Method::name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature) {
@@ -578,8 +578,8 @@
     for (int i = 0; i < length; i++) {
       CheckedExceptionElement* table = h_this->checked_exceptions_start(); // recompute on each iteration, not gc safe
       Klass* k = h_this->constants()->klass_at(table[i].class_cp_index, CHECK_(objArrayHandle()));
-      assert(Klass::cast(k)->is_subclass_of(SystemDictionary::Throwable_klass()), "invalid exception class");
-      mirrors->obj_at_put(i, Klass::cast(k)->java_mirror());
+      assert(k->is_subclass_of(SystemDictionary::Throwable_klass()), "invalid exception class");
+      mirrors->obj_at_put(i, k->java_mirror());
     }
     return mirrors;
   }
@@ -618,7 +618,7 @@
     Thread *thread = Thread::current();
     Symbol* klass_name = constants()->klass_name_at(klass_index);
     Handle loader(thread, method_holder()->class_loader());
-    Handle prot  (thread, Klass::cast(method_holder())->protection_domain());
+    Handle prot  (thread, method_holder()->protection_domain());
     return SystemDictionary::find(klass_name, loader, prot, thread) != NULL;
   } else {
     return true;
@@ -1067,8 +1067,8 @@
 }
 
 Klass* Method::check_non_bcp_klass(Klass* klass) {
-  if (klass != NULL && Klass::cast(klass)->class_loader() != NULL) {
-    if (Klass::cast(klass)->oop_is_objArray())
+  if (klass != NULL && klass->class_loader() != NULL) {
+    if (klass->oop_is_objArray())
       klass = ObjArrayKlass::cast(klass)->bottom_klass();
     return klass;
   }
--- a/src/share/vm/oops/objArrayKlass.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/objArrayKlass.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -81,7 +81,7 @@
       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 (Klass::cast(elem_super)->array_klass_or_null() == NULL) {
+        if (elem_super->array_klass_or_null() == NULL) {
           supers_exist = false;
           break;
         }
@@ -172,7 +172,7 @@
   } else {
     bk = element_klass();
   }
-  assert(bk != NULL && (Klass::cast(bk)->oop_is_instance() || Klass::cast(bk)->oop_is_typeArray()), "invalid bottom klass");
+  assert(bk != NULL && (bk->oop_is_instance() || bk->oop_is_typeArray()), "invalid bottom klass");
   this->set_bottom_klass(bk);
   this->set_class_loader_data(bk->class_loader_data());
 
@@ -254,7 +254,7 @@
     // We have to make sure all elements conform to the destination array
     Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
     Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
-    if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
+    if (stype == bound || stype->is_subtype_of(bound)) {
       // elements are guaranteed to be subtypes, so no check necessary
       bs->write_ref_array_pre(dst, length);
       Copy::conjoint_oops_atomic(src, dst, length);
@@ -271,7 +271,7 @@
         oop new_val = element_is_null ? oop(NULL)
                                       : oopDesc::decode_heap_oop_not_null(element);
         if (element_is_null ||
-            Klass::cast((new_val->klass()))->is_subtype_of(bound)) {
+            (new_val->klass())->is_subtype_of(bound)) {
           bs->write_ref_field_pre(p, new_val);
           *p = *from;
         } else {
@@ -381,7 +381,7 @@
 
 GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots) {
   // interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
-  Array<Klass*>* elem_supers = Klass::cast(element_klass())->secondary_supers();
+  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) {
@@ -411,7 +411,7 @@
 }
 
 void ObjArrayKlass::initialize(TRAPS) {
-  Klass::cast(bottom_klass())->initialize(THREAD);  // dispatches to either InstanceKlass or TypeArrayKlass
+  bottom_klass()->initialize(THREAD);  // dispatches to either InstanceKlass or TypeArrayKlass
 }
 
 #define ObjArrayKlass_SPECIALIZED_OOP_ITERATE(T, a, p, do_oop) \
@@ -607,7 +607,7 @@
     return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
   }
   // Return the flags of the bottom element type.
-  jint element_flags = Klass::cast(bottom_klass())->compute_modifier_flags(CHECK_0);
+  jint element_flags = bottom_klass()->compute_modifier_flags(CHECK_0);
 
   return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
                         | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
@@ -686,7 +686,7 @@
   guarantee(element_klass()->is_klass(), "should be klass");
   guarantee(bottom_klass()->is_metadata(), "should be in metaspace");
   guarantee(bottom_klass()->is_klass(), "should be klass");
-  Klass* bk = Klass::cast(bottom_klass());
+  Klass* bk = bottom_klass();
   guarantee(bk->oop_is_instance() || bk->oop_is_typeArray(),  "invalid bottom klass");
 }
 
--- a/src/share/vm/oops/objArrayKlass.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/oops/objArrayKlass.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -74,7 +74,7 @@
   void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
 
   // Compute protection domain
-  oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); }
+  oop protection_domain() { return bottom_klass()->protection_domain(); }
 
  private:
   // Either oop or narrowOop depending on UseCompressedOops.
--- a/src/share/vm/opto/runtime.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/opto/runtime.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -236,7 +236,7 @@
   assert(check_compiled_frame(thread), "incorrect caller");
 
   // These checks are cheap to make and support reflective allocation.
-  int lh = Klass::cast(klass)->layout_helper();
+  int lh = klass->layout_helper();
   if (Klass::layout_helper_needs_slow_path(lh)
       || !InstanceKlass::cast(klass)->is_initialized()) {
     KlassHandle kh(THREAD, klass);
@@ -283,7 +283,7 @@
   // Scavenge and allocate an instance.
   oop result;
 
-  if (Klass::cast(array_type)->oop_is_typeArray()) {
+  if (array_type->oop_is_typeArray()) {
     // The oopFactory likes to work with the element type.
     // (We could bypass the oopFactory, since it doesn't add much value.)
     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
@@ -321,7 +321,7 @@
   // Scavenge and allocate an instance.
   oop result;
 
-  assert(Klass::cast(array_type)->oop_is_typeArray(), "should be called only for type array");
+  assert(array_type->oop_is_typeArray(), "should be called only for type array");
   // The oopFactory likes to work with the element type.
   BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
   result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
--- a/src/share/vm/prims/jni.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jni.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -234,13 +234,13 @@
 intptr_t jfieldIDWorkaround::encode_klass_hash(Klass* k, intptr_t offset) {
   if (offset <= small_offset_mask) {
     Klass* field_klass = k;
-    Klass* super_klass = Klass::cast(field_klass)->super();
+    Klass* super_klass = field_klass->super();
     // With compressed oops the most super class with nonstatic fields would
     // be the owner of fields embedded in the header.
     while (InstanceKlass::cast(super_klass)->has_nonstatic_fields() &&
            InstanceKlass::cast(super_klass)->contains_field_offset(offset)) {
       field_klass = super_klass;   // super contains the field also
-      super_klass = Klass::cast(field_klass)->super();
+      super_klass = field_klass->super();
     }
     debug_only(No_Safepoint_Verifier nosafepoint;)
     uintptr_t klass_hash = field_klass->identity_hash();
@@ -250,7 +250,7 @@
     #ifndef PRODUCT
     {
       ResourceMark rm;
-      warning("VerifyJNIFields: long offset %d in %s", offset, Klass::cast(k)->external_name());
+      warning("VerifyJNIFields: long offset %d in %s", offset, k->external_name());
     }
     #endif
 #endif
@@ -266,7 +266,7 @@
     // Could use a non-blocking query for identity_hash here...
     if ((k->identity_hash() & klass_mask) == klass_hash)
       return true;
-    k = Klass::cast(k)->super();
+    k = k->super();
   } while (k != NULL);
   return false;
 }
@@ -284,7 +284,7 @@
       #ifndef PRODUCT
       if (Verbose) {
   ResourceMark rm;
-  warning("VerifyJNIFields: unverified offset %d for %s", offset, Klass::cast(k)->external_name());
+  warning("VerifyJNIFields: unverified offset %d for %s", offset, k->external_name());
       }
       #endif
 #endif
@@ -416,7 +416,7 @@
   }
 
   cls = (jclass)JNIHandles::make_local(
-    env, Klass::cast(k)->java_mirror());
+    env, k->java_mirror());
   return cls;
 JNI_END
 
@@ -537,7 +537,7 @@
 
   KlassHandle k1(THREAD, k);
   // Make sure class is initialized before handing id's out to methods
-  Klass::cast(k1())->initialize(CHECK_NULL);
+  k1()->initialize(CHECK_NULL);
   Method* m = InstanceKlass::cast(k1())->method_with_idnum(slot);
   ret = m==NULL? NULL : m->jmethod_id();  // return NULL if reflected method deleted
   return ret;
@@ -570,7 +570,7 @@
 
   KlassHandle k1(THREAD, k);
   // Make sure class is initialized before handing id's out to fields
-  Klass::cast(k1())->initialize(CHECK_NULL);
+  k1()->initialize(CHECK_NULL);
 
   // First check if this is a static field
   if (modifiers & JVM_ACC_STATIC) {
@@ -649,17 +649,17 @@
   // interfaces return NULL
   // proper classes return Klass::super()
   Klass* k = java_lang_Class::as_Klass(mirror);
-  if (Klass::cast(k)->is_interface()) return NULL;
+  if (k->is_interface()) return NULL;
 
   // return mirror for superclass
-  Klass* super = Klass::cast(k)->java_super();
+  Klass* super = k->java_super();
   // super2 is the value computed by the compiler's getSuperClass intrinsic:
-  debug_only(Klass* super2 = ( Klass::cast(k)->oop_is_array()
+  debug_only(Klass* super2 = ( k->oop_is_array()
                                  ? SystemDictionary::Object_klass()
-                                 : Klass::cast(k)->super() ) );
+                                 : k->super() ) );
   assert(super == super2,
          "java_super computation depends on interface, array, other super");
-  obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(Klass::cast(super)->java_mirror());
+  obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(super->java_mirror());
   return obj;
 JNI_END
 
@@ -687,7 +687,7 @@
   Klass* sub_klass   = java_lang_Class::as_Klass(sub_mirror);
   Klass* super_klass = java_lang_Class::as_Klass(super_mirror);
   assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom");
-  jboolean ret = Klass::cast(sub_klass)->is_subtype_of(super_klass) ?
+  jboolean ret = sub_klass->is_subtype_of(super_klass) ?
                    JNI_TRUE : JNI_FALSE;
 #ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret);
@@ -821,7 +821,7 @@
         ResourceMark rm(THREAD);
         jio_fprintf(defaultStream::error_stream(),
         ". Uncaught exception of type %s.",
-        Klass::cast(ex->klass())->external_name());
+        ex->klass()->external_name());
       }
     }
   }
@@ -1359,7 +1359,7 @@
     Method* m = Method::resolve_jmethod_id(method_id);
     number_of_parameters = m->size_of_parameters();
     Klass* holder = m->method_holder();
-    if (!(Klass::cast(holder))->is_interface()) {
+    if (!(holder)->is_interface()) {
       // non-interface call -- for that little speed boost, don't handlize
       debug_only(No_Safepoint_Verifier nosafepoint;)
       if (call_type == JNI_VIRTUAL) {
@@ -1424,7 +1424,7 @@
 
 static instanceOop alloc_object(jclass clazz, TRAPS) {
   KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
-  Klass::cast(k())->check_valid_for_instantiation(false, CHECK_NULL);
+  k()->check_valid_for_instantiation(false, CHECK_NULL);
   InstanceKlass::cast(k())->initialize(CHECK_NULL);
   instanceOop ih = InstanceKlass::cast(k())->allocate_instance(THREAD);
   return ih;
@@ -1546,7 +1546,7 @@
 #endif /* USDT2 */
   Klass* k = JNIHandles::resolve_non_null(obj)->klass();
   jclass ret =
-    (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
+    (jclass) JNIHandles::make_local(env, k->java_mirror());
 #ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret);
 #else /* USDT2 */
@@ -1611,7 +1611,7 @@
 
   // Make sure class is linked and initialized before handing id's out to
   // Method*s.
-  Klass::cast(klass())->initialize(CHECK_NULL);
+  klass()->initialize(CHECK_NULL);
 
   Method* m;
   if (name == vmSymbols::object_initializer_name() ||
@@ -2427,7 +2427,7 @@
   JNI_ArgumentPusherVaArg ap(methodID, args); \
   /* Make sure class is initialized before trying to invoke its method */ \
   KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); \
-  Klass::cast(k())->initialize(CHECK_0); \
+  k()->initialize(CHECK_0); \
   jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \
   va_end(args); \
   ret = jvalue.get_##ResultType(); \
@@ -2612,10 +2612,10 @@
   KlassHandle k(THREAD,
                 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
   // Make sure class is initialized before handing id's out to fields
-  Klass::cast(k())->initialize(CHECK_NULL);
+  k()->initialize(CHECK_NULL);
 
   fieldDescriptor fd;
-  if (!Klass::cast(k())->oop_is_instance() ||
+  if (!k()->oop_is_instance() ||
       !InstanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) {
     THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
   }
@@ -2977,10 +2977,10 @@
   KlassHandle k(THREAD,
                 java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
   // Make sure class is initialized before handing id's out to static fields
-  Klass::cast(k())->initialize(CHECK_NULL);
+  k()->initialize(CHECK_NULL);
 
   fieldDescriptor fd;
-  if (!Klass::cast(k())->oop_is_instance() ||
+  if (!k()->oop_is_instance() ||
       !InstanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) {
     THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
   }
@@ -3440,7 +3440,7 @@
   jobjectArray ret = NULL;
   DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret);
   KlassHandle ek(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass)));
-  Klass* ako = Klass::cast(ek())->array_klass(CHECK_NULL);
+  Klass* ako = ek()->array_klass(CHECK_NULL);
   KlassHandle ak = KlassHandle(THREAD, ako);
   ObjArrayKlass::cast(ak())->initialize(CHECK_NULL);
   objArrayOop result = ObjArrayKlass::cast(ak())->allocate(length, CHECK_NULL);
@@ -3971,7 +3971,7 @@
     if (trial_name == NULL) {
       continue; // no such symbol, so this prefix wasn't used, try the next prefix
     }
-    method = Klass::cast(k())->lookup_method(trial_name, signature);
+    method = k()->lookup_method(trial_name, signature);
     if (method == NULL) {
       continue; // signature doesn't match, try the next prefix
     }
@@ -3988,12 +3988,12 @@
 }
 
 static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) {
-  Method* method = Klass::cast(k())->lookup_method(name, signature);
+  Method* method = k()->lookup_method(name, signature);
   if (method == NULL) {
     ResourceMark rm;
     stringStream st;
     st.print("Method %s name or signature does not match",
-             Method::name_and_sig_as_C_string(Klass::cast(k()), name, signature));
+             Method::name_and_sig_as_C_string(k(), name, signature));
     THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
   }
   if (!method->is_native()) {
@@ -4003,7 +4003,7 @@
       ResourceMark rm;
       stringStream st;
       st.print("Method %s is not declared as native",
-               Method::name_and_sig_as_C_string(Klass::cast(k()), name, signature));
+               Method::name_and_sig_as_C_string(k(), name, signature));
       THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
     }
   }
@@ -4059,7 +4059,7 @@
     if (name == NULL || signature == NULL) {
       ResourceMark rm;
       stringStream st;
-      st.print("Method %s.%s%s not found", Klass::cast(h_k())->external_name(), meth_name, meth_sig);
+      st.print("Method %s.%s%s not found", h_k()->external_name(), meth_name, meth_sig);
       // Must return negative value on failure
       THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1);
     }
@@ -4085,7 +4085,7 @@
 #endif /* USDT2 */
   Klass* k   = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
   //%note jni_2
-  if (Klass::cast(k)->oop_is_instance()) {
+  if (k->oop_is_instance()) {
     for (int index = 0; index < InstanceKlass::cast(k)->methods()->length(); index++) {
       Method* m = InstanceKlass::cast(k)->methods()->at(index);
       if (m->is_native()) {
--- a/src/share/vm/prims/jniCheck.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jniCheck.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -383,7 +383,7 @@
   ASSERT_OOPS_ALLOWED;
   assert(klass != NULL, "klass argument must have a value");
 
-  if (!Klass::cast(klass)->oop_is_instance() ||
+  if (!klass->oop_is_instance() ||
       !InstanceKlass::cast(klass)->is_subclass_of(SystemDictionary::Throwable_klass())) {
     ReportJNIFatalError(thr, fatal_class_not_a_throwable_class);
   }
--- a/src/share/vm/prims/jvm.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvm.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -305,7 +305,7 @@
   assert(s->is_oop(), "JVM_ArrayCopy: src not an oop");
   assert(d->is_oop(), "JVM_ArrayCopy: dst not an oop");
   // Do copy
-  Klass::cast(s->klass())->copy_array(s, src_pos, d, dst_pos, length, thread);
+  s->klass()->copy_array(s, src_pos, d, dst_pos, length, thread);
 JVM_END
 
 
@@ -675,7 +675,7 @@
 JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth))
   JVMWrapper("JVM_GetCallerClass");
   Klass* k = thread->security_get_caller_class(depth);
-  return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
+  return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror());
 JVM_END
 
 
@@ -739,7 +739,7 @@
   if (TraceClassResolution) {
     trace_class_resolution(k);
   }
-  return (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
+  return (jclass) JNIHandles::make_local(env, k->java_mirror());
 JVM_END
 
 JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name,
@@ -785,8 +785,8 @@
   oop class_loader = NULL;
   oop protection_domain = NULL;
   if (from_class != NULL) {
-    class_loader = Klass::cast(from_class)->class_loader();
-    protection_domain = Klass::cast(from_class)->protection_domain();
+    class_loader = from_class->class_loader();
+    protection_domain = from_class->protection_domain();
   }
   Handle h_loader(THREAD, class_loader);
   Handle h_prot  (THREAD, protection_domain);
@@ -798,11 +798,11 @@
     ResourceMark rm;
     oop from_mirror = JNIHandles::resolve_non_null(from);
     Klass* from_class = java_lang_Class::as_Klass(from_mirror);
-    const char * from_name = Klass::cast(from_class)->external_name();
+    const char * from_name = from_class->external_name();
 
     oop mirror = JNIHandles::resolve_non_null(result);
     Klass* to_class = java_lang_Class::as_Klass(mirror);
-    const char * to = Klass::cast(to_class)->external_name();
+    const char * to = to_class->external_name();
     tty->print("RESOLVE %s %s (verification)\n", from_name, to);
   }
 
@@ -875,7 +875,7 @@
     trace_class_resolution(k);
   }
 
-  return (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
+  return (jclass) JNIHandles::make_local(env, k->java_mirror());
 }
 
 
@@ -936,7 +936,7 @@
                                                               CHECK_NULL);
 
   return (k == NULL) ? NULL :
-            (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
+            (jclass) JNIHandles::make_local(env, k->java_mirror());
 JVM_END
 
 
@@ -954,7 +954,7 @@
     // Consider caching interned string in Klass
     Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
     assert(k->is_klass(), "just checking");
-    name = Klass::cast(k)->external_name();
+    name = k->external_name();
   }
   oop result = StringTable::intern((char*) name, CHECK_NULL);
   return (jstring) JNIHandles::make_local(env, result);
@@ -991,12 +991,12 @@
     // Regular instance klass, fill in all local interfaces
     for (int index = 0; index < size; index++) {
       Klass* k = InstanceKlass::cast(klass())->local_interfaces()->at(index);
-      result->obj_at_put(index, Klass::cast(k)->java_mirror());
+      result->obj_at_put(index, k->java_mirror());
     }
   } else {
     // All arrays implement java.lang.Cloneable and java.io.Serializable
-    result->obj_at_put(0, Klass::cast(SystemDictionary::Cloneable_klass())->java_mirror());
-    result->obj_at_put(1, Klass::cast(SystemDictionary::Serializable_klass())->java_mirror());
+    result->obj_at_put(0, SystemDictionary::Cloneable_klass()->java_mirror());
+    result->obj_at_put(1, SystemDictionary::Serializable_klass()->java_mirror());
   }
   return (jobjectArray) JNIHandles::make_local(env, result());
 JVM_END
@@ -1008,7 +1008,7 @@
     return NULL;
   }
   Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
-  oop loader = Klass::cast(k)->class_loader();
+  oop loader = k->class_loader();
   return JNIHandles::make_local(env, loader);
 JVM_END
 
@@ -1020,8 +1020,8 @@
     return JNI_FALSE;
   }
   Klass* k = java_lang_Class::as_Klass(mirror);
-  jboolean result = Klass::cast(k)->is_interface();
-  assert(!result || Klass::cast(k)->oop_is_instance(),
+  jboolean result = k->is_interface();
+  assert(!result || k->oop_is_instance(),
          "all interfaces are instance types");
   // The compiler intrinsic for isInterface tests the
   // Klass::_access_flags bits in the same way.
@@ -1039,7 +1039,7 @@
 
   Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
   objArrayOop signers = NULL;
-  if (Klass::cast(k)->oop_is_instance()) {
+  if (k->oop_is_instance()) {
     signers = InstanceKlass::cast(k)->signers();
   }
 
@@ -1066,7 +1066,7 @@
     // Signers are only set once, ClassLoader.java, and thus shouldn't
     // be called with an array.  Only the bootstrap loader creates arrays.
     Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
-    if (Klass::cast(k)->oop_is_instance()) {
+    if (k->oop_is_instance()) {
       InstanceKlass::cast(k)->set_signers(objArrayOop(JNIHandles::resolve(signers)));
     }
   }
@@ -1085,7 +1085,7 @@
   }
 
   Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
-  return (jobject) JNIHandles::make_local(env, Klass::cast(k)->protection_domain());
+  return (jobject) JNIHandles::make_local(env, k->protection_domain());
 JVM_END
 
 
@@ -1101,7 +1101,7 @@
     Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
 
     // cls won't be an array, as this called only from ClassLoader.defineClass
-    if (Klass::cast(k)->oop_is_instance()) {
+    if (k->oop_is_instance()) {
       oop pd = JNIHandles::resolve(protection_domain);
       assert(pd == NULL || pd->is_oop(), "just checking");
       InstanceKlass::cast(k)->set_protection_domain(pd);
@@ -1124,7 +1124,7 @@
   Handle object (THREAD, JNIHandles::resolve(action));
 
   // get run() method
-  Method* m_oop = Klass::cast(object->klass())->uncached_lookup_method(
+  Method* m_oop = object->klass()->uncached_lookup_method(
                                            vmSymbols::run_method_name(),
                                            vmSymbols::void_object_signature());
   methodHandle m (THREAD, m_oop);
@@ -1267,7 +1267,7 @@
 JVM_QUICK_ENTRY(jboolean, JVM_IsArrayClass(JNIEnv *env, jclass cls))
   JVMWrapper("JVM_IsArrayClass");
   Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
-  return (k != NULL) && Klass::cast(k)->oop_is_array() ? true : false;
+  return (k != NULL) && k->oop_is_array() ? true : false;
 JVM_END
 
 
@@ -1293,7 +1293,7 @@
     return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
   }
 
-  Klass* k = Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)));
+  Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
   debug_only(int computed_modifiers = k->compute_modifier_flags(CHECK_0));
   assert(k->modifier_flags() == computed_modifiers, "modifiers cache is OK");
   return k->modifier_flags();
@@ -1308,7 +1308,7 @@
   // of an InstanceKlass
 
   if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) ||
-      ! Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_instance()) {
+      ! java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_instance()) {
     oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL);
     return (jobjectArray)JNIHandles::make_local(env, result);
   }
@@ -1372,7 +1372,7 @@
 {
   // ofClass is a reference to a java_lang_Class object.
   if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) ||
-      ! Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_instance()) {
+      ! java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_instance()) {
     return NULL;
   }
 
@@ -1382,7 +1382,7 @@
                           )->compute_enclosing_class(&inner_is_member, CHECK_NULL);
   if (outer_klass == NULL)  return NULL;  // already a top-level class
   if (!inner_is_member)  return NULL;     // an anonymous class (inside a method)
-  return (jclass) JNIHandles::make_local(env, Klass::cast(outer_klass)->java_mirror());
+  return (jclass) JNIHandles::make_local(env, outer_klass->java_mirror());
 }
 JVM_END
 
@@ -1452,7 +1452,7 @@
   // Return null for arrays and primatives
   if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
     Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
-    if (Klass::cast(k)->oop_is_instance()) {
+    if (k->oop_is_instance()) {
       Symbol* sym = InstanceKlass::cast(k)->generic_signature();
       if (sym == NULL) return NULL;
       Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
@@ -1470,7 +1470,7 @@
   // Return null for arrays and primitives
   if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
     Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
-    if (Klass::cast(k)->oop_is_instance()) {
+    if (k->oop_is_instance()) {
       typeArrayOop a = Annotations::make_java_array(InstanceKlass::cast(k)->class_annotations(), CHECK_NULL);
       return (jbyteArray) JNIHandles::make_local(env, a);
     }
@@ -1583,7 +1583,7 @@
 
   // Exclude primitive types and array types
   if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) ||
-      Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) {
+      java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) {
     // Return empty array
     oop res = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), 0, CHECK_NULL);
     return (jobjectArray) JNIHandles::make_local(env, res);
@@ -1646,7 +1646,7 @@
 
   // Exclude primitive types and array types
   if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass))
-      || Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) {
+      || java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) {
     // Return empty array
     oop res = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), 0, CHECK_NULL);
     return (jobjectArray) JNIHandles::make_local(env, res);
@@ -1698,7 +1698,7 @@
 
   // Exclude primitive types and array types
   if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass))
-      || Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) {
+      || java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) {
     // Return empty array
     oop res = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), 0 , CHECK_NULL);
     return (jobjectArray) JNIHandles::make_local(env, res);
@@ -1751,7 +1751,7 @@
     return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
   }
 
-  Klass* k = Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)));
+  Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
   return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS;
 }
 JVM_END
@@ -1767,7 +1767,7 @@
   // Return null for primitives and arrays
   if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) {
     Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
-    if (Klass::cast(k)->oop_is_instance()) {
+    if (k->oop_is_instance()) {
       instanceKlassHandle k_h(THREAD, k);
       Handle jcp = sun_reflect_ConstantPool::create(CHECK_NULL);
       sun_reflect_ConstantPool::set_cp(jcp(), k_h->constants());
@@ -2043,12 +2043,12 @@
   if (java_lang_Class::is_primitive(r)) return false;
 
   Klass* k = java_lang_Class::as_Klass(r);
-  assert(Klass::cast(k)->oop_is_instance(), "must be an instance klass");
-  if (! Klass::cast(k)->oop_is_instance()) return false;
+  assert(k->oop_is_instance(), "must be an instance klass");
+  if (! k->oop_is_instance()) return false;
 
   ResourceMark rm(THREAD);
-  const char* name = Klass::cast(k)->name()->as_C_string();
-  bool system_class = Klass::cast(k)->class_loader() == NULL;
+  const char* name = k->name()->as_C_string();
+  bool system_class = k->class_loader() == NULL;
   return JavaAssertions::enabled(name, system_class);
 
 JVM_END
@@ -2079,7 +2079,7 @@
   JVMWrapper("JVM_GetClassNameUTF");
   Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
-  return Klass::cast(k)->name()->as_utf8();
+  return k->name()->as_utf8();
 JVM_END
 
 
@@ -2089,7 +2089,7 @@
   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
   // types will have length zero if this is not an InstanceKlass
   // (length is determined by call to JVM_GetClassCPEntriesCount)
-  if (Klass::cast(k)->oop_is_instance()) {
+  if (k->oop_is_instance()) {
     ConstantPool* cp = InstanceKlass::cast(k)->constants();
     for (int index = cp->length() - 1; index >= 0; index--) {
       constantTag tag = cp->tag_at(index);
@@ -2103,7 +2103,7 @@
   JVMWrapper("JVM_GetClassCPEntriesCount");
   Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
-  if (!Klass::cast(k)->oop_is_instance())
+  if (!k->oop_is_instance())
     return 0;
   return InstanceKlass::cast(k)->constants()->length();
 JVM_END
@@ -2113,7 +2113,7 @@
   JVMWrapper("JVM_GetClassFieldsCount");
   Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
-  if (!Klass::cast(k)->oop_is_instance())
+  if (!k->oop_is_instance())
     return 0;
   return InstanceKlass::cast(k)->java_fields_count();
 JVM_END
@@ -2123,7 +2123,7 @@
   JVMWrapper("JVM_GetClassMethodsCount");
   Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
-  if (!Klass::cast(k)->oop_is_instance())
+  if (!k->oop_is_instance())
     return 0;
   return InstanceKlass::cast(k)->methods()->length();
 JVM_END
@@ -3123,7 +3123,7 @@
   // Fill in mirrors corresponding to method holders
   int index = 0;
   while (first != NULL) {
-    result->obj_at_put(index++, Klass::cast(first->klass())->java_mirror());
+    result->obj_at_put(index++, first->klass()->java_mirror());
     first = first->next;
   }
   assert(index == depth, "just checking");
@@ -3217,7 +3217,7 @@
 
   if (access.is_protected()) {
     // See if current_class is a subclass of field_class
-    if (Klass::cast(current_class)->is_subclass_of(field_class)) {
+    if (current_class->is_subclass_of(field_class)) {
       return true;
     }
   }
@@ -3241,8 +3241,8 @@
   }
 
   // Arrays not allowed here, must use JVM_AllocateNewArray
-  if (Klass::cast(java_lang_Class::as_Klass(curr_mirror))->oop_is_array() ||
-      Klass::cast(java_lang_Class::as_Klass(init_mirror))->oop_is_array()) {
+  if (java_lang_Class::as_Klass(curr_mirror)->oop_is_array() ||
+      java_lang_Class::as_Klass(init_mirror)->oop_is_array()) {
     ResourceMark rm(THREAD);
     THROW_0(vmSymbols::java_lang_InvalidClassException());
   }
@@ -3264,7 +3264,7 @@
   if (m.is_null()) {
     ResourceMark rm(THREAD);
     THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(),
-                Method::name_and_sig_as_C_string(Klass::cast(init_klass()),
+                Method::name_and_sig_as_C_string(init_klass(),
                                           vmSymbols::object_initializer_name(),
                                           vmSymbols::void_method_signature()));
   }
@@ -4245,7 +4245,7 @@
     return NULL;
   }
   Klass* k = java_lang_Class::as_Klass(mirror());
-  if (!Klass::cast(k)->oop_is_instance()) {
+  if (!k->oop_is_instance()) {
     return NULL;
   }
   instanceKlassHandle ik_h(THREAD, k);
@@ -4256,7 +4256,7 @@
   objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL);
   objArrayHandle dest(THREAD, dest_o);
   Klass* enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL);
-  dest->obj_at_put(0, Klass::cast(enc_k)->java_mirror());
+  dest->obj_at_put(0, enc_k->java_mirror());
   int encl_method_method_idx = ik_h->enclosing_method_method_index();
   if (encl_method_method_idx != 0) {
     Symbol* sym = ik_h->constants()->symbol_at(
--- a/src/share/vm/prims/jvmtiClassFileReconstituter.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiClassFileReconstituter.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -228,7 +228,7 @@
 
   write_attribute_name_index("Code");
   write_u4(size);
-  write_u2(method->max_stack());
+  write_u2(method->verifier_max_stack());
   write_u2(method->max_locals());
   write_u4(code_size);
   copy_bytecodes(method, (unsigned char*)writeable_address(code_size));
--- a/src/share/vm/prims/jvmtiEnv.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiEnv.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -2116,7 +2116,7 @@
       result[0] = tchar;
       result[1] = '\0';
     } else {
-      const char* class_sig = Klass::cast(k)->signature_name();
+      const char* class_sig = k->signature_name();
       result = (char *) jvmtiMalloc(strlen(class_sig)+1);
       strcpy(result, class_sig);
     }
@@ -2124,7 +2124,7 @@
   }
   if (generic_ptr != NULL) {
     *generic_ptr = NULL;
-    if (!isPrimitive && Klass::cast(k)->oop_is_instance()) {
+    if (!isPrimitive && k->oop_is_instance()) {
       Symbol* soo = InstanceKlass::cast(k)->generic_signature();
       if (soo != NULL) {
         const char *gen_sig = soo->as_C_string();
@@ -2155,7 +2155,7 @@
   } else {
     Klass* k = java_lang_Class::as_Klass(k_mirror);
     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
-    result = Klass::cast(k)->jvmti_class_status();
+    result = k->jvmti_class_status();
   }
   *status_ptr = result;
 
@@ -2173,7 +2173,7 @@
   Klass* k_klass = java_lang_Class::as_Klass(k_mirror);
   NULL_CHECK(k_klass, JVMTI_ERROR_INVALID_CLASS);
 
-  if (!Klass::cast(k_klass)->oop_is_instance()) {
+  if (!k_klass->oop_is_instance()) {
     return JVMTI_ERROR_ABSENT_INFORMATION;
   }
 
@@ -2200,7 +2200,7 @@
   if (!java_lang_Class::is_primitive(k_mirror)) {
     Klass* k = java_lang_Class::as_Klass(k_mirror);
     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
-    result = Klass::cast(k)->compute_modifier_flags(current_thread);
+    result = k->compute_modifier_flags(current_thread);
     JavaThread* THREAD = current_thread; // pass to macros
     if (HAS_PENDING_EXCEPTION) {
       CLEAR_PENDING_EXCEPTION;
@@ -2208,7 +2208,7 @@
     };
 
     // Reset the deleted  ACC_SUPER bit ( deleted in compute_modifier_flags()).
-    if(Klass::cast(k)->is_super()) {
+    if(k->is_super()) {
       result |= JVM_ACC_SUPER;
     }
   } else {
@@ -2237,11 +2237,11 @@
   NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
 
   // Return CLASS_NOT_PREPARED error as per JVMTI spec.
-  if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) {
+  if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) {
     return JVMTI_ERROR_CLASS_NOT_PREPARED;
   }
 
-  if (!Klass::cast(k)->oop_is_instance()) {
+  if (!k->oop_is_instance()) {
     *method_count_ptr = 0;
     *methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID));
     return JVMTI_ERROR_NONE;
@@ -2293,11 +2293,11 @@
   NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
 
   // Return CLASS_NOT_PREPARED error as per JVMTI spec.
-  if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) {
+  if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) {
     return JVMTI_ERROR_CLASS_NOT_PREPARED;
   }
 
-  if (!Klass::cast(k)->oop_is_instance()) {
+  if (!k->oop_is_instance()) {
     *field_count_ptr = 0;
     *fields_ptr = (jfieldID*) jvmtiMalloc(0 * sizeof(jfieldID));
     return JVMTI_ERROR_NONE;
@@ -2348,10 +2348,10 @@
     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
 
     // Return CLASS_NOT_PREPARED error as per JVMTI spec.
-    if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) ))
+    if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) ))
       return JVMTI_ERROR_CLASS_NOT_PREPARED;
 
-    if (!Klass::cast(k)->oop_is_instance()) {
+    if (!k->oop_is_instance()) {
       *interface_count_ptr = 0;
       *interfaces_ptr = (jclass*) jvmtiMalloc(0 * sizeof(jclass));
       return JVMTI_ERROR_NONE;
@@ -2363,8 +2363,8 @@
     for (int i_index = 0; i_index < result_length; i_index += 1) {
       Klass* klass_at = interface_list->at(i_index);
       assert(klass_at->is_klass(), "interfaces must be Klass*s");
-      assert(Klass::cast(klass_at)->is_interface(), "interfaces must be interfaces");
-      oop mirror_at = Klass::cast(klass_at)->java_mirror();
+      assert(klass_at->is_interface(), "interfaces must be interfaces");
+      oop mirror_at = klass_at->java_mirror();
       Handle handle_at = Handle(current_thread, mirror_at);
       result_list[i_index] = (jclass) jni_reference(handle_at);
     }
@@ -2468,7 +2468,7 @@
     bool result = false;
     if (!java_lang_Class::is_primitive(k_mirror)) {
       Klass* k = java_lang_Class::as_Klass(k_mirror);
-      if (k != NULL && Klass::cast(k)->is_interface()) {
+      if (k != NULL && k->is_interface()) {
         result = true;
       }
     }
@@ -2487,7 +2487,7 @@
     bool result = false;
     if (!java_lang_Class::is_primitive(k_mirror)) {
       Klass* k = java_lang_Class::as_Klass(k_mirror);
-      if (k != NULL && Klass::cast(k)->oop_is_array()) {
+      if (k != NULL && k->oop_is_array()) {
         result = true;
       }
     }
@@ -2512,7 +2512,7 @@
     Klass* k = java_lang_Class::as_Klass(k_mirror);
     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
 
-    oop result_oop = Klass::cast(k)->class_loader();
+    oop result_oop = k->class_loader();
     if (result_oop == NULL) {
       *classloader_ptr = (jclass) jni_reference(Handle());
       return JVMTI_ERROR_NONE;
@@ -2535,7 +2535,7 @@
     }
     Klass* k = java_lang_Class::as_Klass(k_mirror);
     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
-    if (!Klass::cast(k)->oop_is_instance()) {
+    if (!k->oop_is_instance()) {
       return JVMTI_ERROR_ABSENT_INFORMATION;
     }
     char* sde = InstanceKlass::cast(k)->source_debug_extension();
--- a/src/share/vm/prims/jvmtiEnvBase.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiEnvBase.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -590,7 +590,7 @@
 jclass
 JvmtiEnvBase::get_jni_class_non_null(Klass* k) {
   assert(k != NULL, "k != NULL");
-  return (jclass)jni_reference(Klass::cast(k)->java_mirror());
+  return (jclass)jni_reference(k->java_mirror());
 }
 
 #ifndef JVMTI_KERNEL
@@ -1365,7 +1365,7 @@
     // Method return type signature.
     char* ty_sign = 1 + strchr(signature->as_C_string(), ')');
 
-    if (!VM_GetOrSetLocal::is_assignable(ty_sign, Klass::cast(ob_kh()), current_thread)) {
+    if (!VM_GetOrSetLocal::is_assignable(ty_sign, ob_kh(), current_thread)) {
       return JVMTI_ERROR_TYPE_MISMATCH;
     }
     *ret_ob_h = ob_h;
--- a/src/share/vm/prims/jvmtiExport.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiExport.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -196,7 +196,7 @@
   jobject to_jobject(oop obj) { return JNIHandles::make_local(_thread,obj); }
 #endif
 
-  jclass to_jclass(Klass* klass) { return (klass == NULL ? NULL : (jclass)to_jobject(Klass::cast(klass)->java_mirror())); }
+  jclass to_jclass(Klass* klass) { return (klass == NULL ? NULL : (jclass)to_jobject(klass->java_mirror())); }
 
   jmethodID to_jmethodID(methodHandle method) { return method->jmethod_id(); }
 
@@ -920,7 +920,7 @@
     if (ets->is_enabled(JVMTI_EVENT_CLASS_LOAD)) {
       EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("JVMTI [%s] Evt Class Load sent %s",
                                          JvmtiTrace::safe_get_thread_name(thread),
-                                         kh()==NULL? "NULL" : Klass::cast(kh())->external_name() ));
+                                         kh()==NULL? "NULL" : kh()->external_name() ));
 
       JvmtiEnv *env = ets->get_env();
       JvmtiClassEventMark jem(thread, kh());
@@ -949,7 +949,7 @@
     if (ets->is_enabled(JVMTI_EVENT_CLASS_PREPARE)) {
       EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("JVMTI [%s] Evt Class Prepare sent %s",
                                             JvmtiTrace::safe_get_thread_name(thread),
-                                            kh()==NULL? "NULL" : Klass::cast(kh())->external_name() ));
+                                            kh()==NULL? "NULL" : kh()->external_name() ));
 
       JvmtiEnv *env = ets->get_env();
       JvmtiClassEventMark jem(thread, kh());
@@ -979,12 +979,12 @@
     for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
       if (env->is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) {
         EVT_TRACE(EXT_EVENT_CLASS_UNLOAD, ("JVMTI [?] Evt Class Unload sent %s",
-                  kh()==NULL? "NULL" : Klass::cast(kh())->external_name() ));
+                  kh()==NULL? "NULL" : kh()->external_name() ));
 
         // do everything manually, since this is a proxy - needs special care
         JNIEnv* jni_env = real_thread->jni_environment();
         jthread jt = (jthread)JNIHandles::make_local(real_thread, real_thread->threadObj());
-        jclass jk = (jclass)JNIHandles::make_local(real_thread, Klass::cast(kh())->java_mirror());
+        jclass jk = (jclass)JNIHandles::make_local(real_thread, kh()->java_mirror());
 
         // Before we call the JVMTI agent, we have to set the state in the
         // thread for which we are proxying.
@@ -2121,7 +2121,7 @@
     if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC)) {
       EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("JVMTI [%s] Evt vmobject alloc sent %s",
                                          JvmtiTrace::safe_get_thread_name(thread),
-                                         object==NULL? "NULL" : Klass::cast(java_lang_Class::as_Klass(object))->external_name()));
+                                         object==NULL? "NULL" : java_lang_Class::as_Klass(object)->external_name()));
 
       JvmtiVMObjectAllocEventMark jem(thread, h());
       JvmtiJavaThreadEventTransition jet(thread);
--- a/src/share/vm/prims/jvmtiGetLoadedClasses.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiGetLoadedClasses.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -169,7 +169,7 @@
   static void increment(Klass* k) {
     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
     if (that->get_initiatingLoader() == NULL) {
-      for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
+      for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
         that->set_count(that->get_count() + 1);
       }
     } else if (k != NULL) {
@@ -182,7 +182,7 @@
     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
     oop class_loader = loader_data->class_loader();
     if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) {
-      for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
+      for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
         that->set_count(that->get_count() + 1);
       }
     }
@@ -200,14 +200,14 @@
     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
     if (that->available()) {
       if (that->get_initiatingLoader() == NULL) {
-        for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
-          oop mirror = Klass::cast(l)->java_mirror();
+        for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
+          oop mirror = l->java_mirror();
           that->set_element(that->get_index(), mirror);
           that->set_index(that->get_index() + 1);
         }
       } else if (k != NULL) {
         // if initiating loader not null, just include the instance with 1 dimension
-        oop mirror = Klass::cast(k)->java_mirror();
+        oop mirror = k->java_mirror();
         that->set_element(that->get_index(), mirror);
         that->set_index(that->get_index() + 1);
       }
@@ -219,8 +219,8 @@
     if (that->available()) {
       oop class_loader = loader_data->class_loader();
       if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) {
-        for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
-          oop mirror = Klass::cast(l)->java_mirror();
+        for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
+          oop mirror = l->java_mirror();
           that->set_element(that->get_index(), mirror);
           that->set_index(that->get_index() + 1);
         }
@@ -234,7 +234,7 @@
   static void increment_for_basic_type_arrays(Klass* k) {
     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
     assert(that != NULL, "no JvmtiGetLoadedClassesClosure");
-    for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
+    for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
       that->set_count(that->get_count() + 1);
     }
   }
@@ -244,8 +244,8 @@
     JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
     assert(that != NULL, "no JvmtiGetLoadedClassesClosure");
     assert(that->available(), "no list");
-    for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
-      oop mirror = Klass::cast(l)->java_mirror();
+    for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
+      oop mirror = l->java_mirror();
       that->set_element(that->get_index(), mirror);
       that->set_index(that->get_index() + 1);
     }
--- a/src/share/vm/prims/jvmtiImpl.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiImpl.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -641,14 +641,14 @@
   int super_depth = klass->super_depth();
   int idx;
   for (idx = 0; idx < super_depth; idx++) {
-    if (Klass::cast(klass->primary_super_of_depth(idx))->name() == ty_sym) {
+    if (klass->primary_super_of_depth(idx)->name() == ty_sym) {
       return true;
     }
   }
   // Compare secondary supers
   Array<Klass*>* sec_supers = klass->secondary_supers();
   for (idx = 0; idx < sec_supers->length(); idx++) {
-    if (Klass::cast((Klass*) sec_supers->at(idx))->name() == ty_sym) {
+    if (((Klass*) sec_supers->at(idx))->name() == ty_sym) {
       return true;
     }
   }
@@ -726,7 +726,7 @@
     KlassHandle ob_kh = KlassHandle(cur_thread, obj->klass());
     NULL_CHECK(ob_kh, (_result = JVMTI_ERROR_INVALID_OBJECT, false));
 
-    if (!is_assignable(signature, Klass::cast(ob_kh()), cur_thread)) {
+    if (!is_assignable(signature, ob_kh(), cur_thread)) {
       _result = JVMTI_ERROR_TYPE_MISMATCH;
       return false;
     }
--- a/src/share/vm/prims/jvmtiRedefineClasses.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -222,7 +222,7 @@
   }
   Klass* the_class_oop = java_lang_Class::as_Klass(klass_mirror);
   // classes for arrays cannot be redefined
-  if (the_class_oop == NULL || !Klass::cast(the_class_oop)->oop_is_instance()) {
+  if (the_class_oop == NULL || !the_class_oop->oop_is_instance()) {
     return false;
   }
   return true;
@@ -573,8 +573,8 @@
   // Check for NULL superclass first since this might be java.lang.Object
   if (the_class->super() != scratch_class->super() &&
       (the_class->super() == NULL || scratch_class->super() == NULL ||
-       Klass::cast(the_class->super())->name() !=
-       Klass::cast(scratch_class->super())->name())) {
+       the_class->super()->name() !=
+       scratch_class->super()->name())) {
     return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED;
   }
 
@@ -592,8 +592,8 @@
     return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED;
   }
   for (i = 0; i < n_intfs; i++) {
-    if (Klass::cast(k_interfaces->at(i))->name() !=
-        Klass::cast(k_new_interfaces->at(i))->name()) {
+    if (k_interfaces->at(i)->name() !=
+        k_new_interfaces->at(i)->name()) {
       return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED;
     }
   }
@@ -2684,7 +2684,7 @@
     // interface, then we have to call adjust_method_entries() for
     // every InstanceKlass that has an itable since there isn't a
     // subclass relationship between an interface and an InstanceKlass.
-    if (ik->itable_length() > 0 && (Klass::cast(_the_class_oop)->is_interface()
+    if (ik->itable_length() > 0 && (_the_class_oop->is_interface()
         || ik->is_subclass_of(_the_class_oop))) {
       // ik->itable() creates a wrapper object; rm cleans it up
       ResourceMark rm(THREAD);
@@ -2929,7 +2929,7 @@
                                      Symbol* signature) {
     TempNewSymbol name_symbol = SymbolTable::probe(name_str, (int)name_len);
     if (name_symbol != NULL) {
-      Method* method = Klass::cast(the_class())->lookup_method(name_symbol, signature);
+      Method* method = the_class()->lookup_method(name_symbol, signature);
       if (method != NULL) {
         // Even if prefixed, intermediate methods must exist.
         if (method->is_native()) {
--- a/src/share/vm/prims/jvmtiTagMap.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiTagMap.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -2774,7 +2774,7 @@
 // a type array references its class
 inline bool VM_HeapWalkOperation::iterate_over_type_array(oop o) {
   Klass* k = o->klass();
-  oop mirror = Klass::cast(k)->java_mirror();
+  oop mirror = k->java_mirror();
   if (!CallbackInvoker::report_class_reference(o, mirror)) {
     return false;
   }
@@ -2823,7 +2823,7 @@
     // super (only if something more interesting than java.lang.Object)
     Klass* java_super = ik->java_super();
     if (java_super != NULL && java_super != SystemDictionary::Object_klass()) {
-      oop super = Klass::cast(java_super)->java_mirror();
+      oop super = java_super->java_mirror();
       if (!CallbackInvoker::report_superclass_reference(mirror, super)) {
         return false;
       }
@@ -2865,7 +2865,7 @@
             // If the entry is non-null it is resolved.
             if (entry == NULL) continue;
           } else {
-            entry = Klass::cast(pool->resolved_klass_at(i))->java_mirror();
+            entry = pool->resolved_klass_at(i)->java_mirror();
           }
           if (!CallbackInvoker::report_constant_pool_reference(mirror, entry, (jint)i)) {
             return false;
@@ -2879,7 +2879,7 @@
     //  but are specified by IterateOverReachableObjects and must be reported).
     Array<Klass*>* interfaces = ik->local_interfaces();
     for (i = 0; i < interfaces->length(); i++) {
-      oop interf = Klass::cast((Klass*)interfaces->at(i))->java_mirror();
+      oop interf = ((Klass*)interfaces->at(i))->java_mirror();
       if (interf == NULL) {
         continue;
       }
@@ -2928,7 +2928,7 @@
 // references from the class).
 inline bool VM_HeapWalkOperation::iterate_over_object(oop o) {
   // reference to the class
-  if (!CallbackInvoker::report_class_reference(o, Klass::cast(o->klass())->java_mirror())) {
+  if (!CallbackInvoker::report_class_reference(o, o->klass()->java_mirror())) {
     return false;
   }
 
--- a/src/share/vm/prims/jvmtiTrace.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/jvmtiTrace.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -292,7 +292,7 @@
   if (k_oop == NULL) {
     return "INVALID";
   }
-  return Klass::cast(k_oop)->external_name();
+  return k_oop->external_name();
 }
 
 #endif /*JVMTI_TRACE */
--- a/src/share/vm/prims/methodHandles.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/methodHandles.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -138,7 +138,7 @@
     oop clazz  = java_lang_reflect_Method::clazz(target_oop);
     int slot   = java_lang_reflect_Method::slot(target_oop);
     Klass* k = java_lang_Class::as_Klass(clazz);
-    if (k != NULL && Klass::cast(k)->oop_is_instance()) {
+    if (k != NULL && k->oop_is_instance()) {
       Method* m = InstanceKlass::cast(k)->method_with_idnum(slot);
       return init_method_MemberName(mname_oop, m, true, k);
     }
@@ -146,7 +146,7 @@
     oop clazz  = java_lang_reflect_Constructor::clazz(target_oop);
     int slot   = java_lang_reflect_Constructor::slot(target_oop);
     Klass* k = java_lang_Class::as_Klass(clazz);
-    if (k != NULL && Klass::cast(k)->oop_is_instance()) {
+    if (k != NULL && k->oop_is_instance()) {
       Method* m = InstanceKlass::cast(k)->method_with_idnum(slot);
       return init_method_MemberName(mname_oop, m, false, k);
     }
@@ -187,14 +187,14 @@
   } else if (mods.is_static()) {
     flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT);
   } else if (receiver_limit != mklass &&
-             !Klass::cast(receiver_limit)->is_subtype_of(mklass)) {
+             !receiver_limit->is_subtype_of(mklass)) {
     return NULL;  // bad receiver limit
-  } else if (Klass::cast(receiver_limit)->is_interface() &&
-             Klass::cast(mklass)->is_interface()) {
+  } else if (receiver_limit->is_interface() &&
+             mklass->is_interface()) {
     flags |= IS_METHOD | (JVM_REF_invokeInterface << REFERENCE_KIND_SHIFT);
     receiver_limit = mklass;  // ignore passed-in limit; interfaces are interconvertible
     vmindex = klassItable::compute_itable_index(m);
-  } else if (mklass != receiver_limit && Klass::cast(mklass)->is_interface()) {
+  } else if (mklass != receiver_limit && mklass->is_interface()) {
     flags |= IS_METHOD | (JVM_REF_invokeVirtual << REFERENCE_KIND_SHIFT);
     // it is a miranda method, so m->vtable_index is not what we want
     ResourceMark rm;
@@ -210,7 +210,7 @@
   java_lang_invoke_MemberName::set_flags(mname_oop,    flags);
   java_lang_invoke_MemberName::set_vmtarget(mname_oop, m);
   java_lang_invoke_MemberName::set_vmindex(mname_oop,  vmindex);   // vtable/itable index
-  java_lang_invoke_MemberName::set_clazz(mname_oop,    Klass::cast(receiver_limit)->java_mirror());
+  java_lang_invoke_MemberName::set_clazz(mname_oop,    receiver_limit->java_mirror());
   // Note:  name and type can be lazily computed by resolve_MemberName,
   // if Java code needs them as resolved String and MethodType objects.
   // The clazz must be eagerly stored, because it provides a GC
@@ -258,7 +258,7 @@
   java_lang_invoke_MemberName::set_flags(mname_oop,    flags);
   java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget);
   java_lang_invoke_MemberName::set_vmindex(mname_oop,  vmindex);
-  java_lang_invoke_MemberName::set_clazz(mname_oop,    Klass::cast(field_holder)->java_mirror());
+  java_lang_invoke_MemberName::set_clazz(mname_oop,    field_holder->java_mirror());
   if (name != NULL)
     java_lang_invoke_MemberName::set_name(mname_oop,   name);
   if (type != NULL)
@@ -299,7 +299,7 @@
   // The following test will fail spuriously during bootstrap of MethodHandle itself:
   //    if (klass != SystemDictionary::MethodHandle_klass())
   // Test the name instead:
-  if (Klass::cast(klass)->name() != vmSymbols::java_lang_invoke_MethodHandle())
+  if (klass->name() != vmSymbols::java_lang_invoke_MethodHandle())
     return false;
   Symbol* poly_sig = vmSymbols::object_array_object_signature();
   Method* m = InstanceKlass::cast(klass)->find_method(name, poly_sig);
@@ -363,7 +363,7 @@
 
 vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Klass* klass, Symbol* name) {
   if (klass != NULL &&
-      Klass::cast(klass)->name() == vmSymbols::java_lang_invoke_MethodHandle()) {
+      klass->name() == vmSymbols::java_lang_invoke_MethodHandle()) {
     vmIntrinsics::ID iid = signature_polymorphic_name_id(name);
     if (iid != vmIntrinsics::_none)
       return iid;
@@ -539,7 +539,7 @@
 
 
 static oop object_java_mirror() {
-  return Klass::cast(SystemDictionary::Object_klass())->java_mirror();
+  return SystemDictionary::Object_klass()->java_mirror();
 }
 
 static oop field_name_or_null(Symbol* s) {
@@ -560,9 +560,9 @@
     if (s == vmSymbols::object_signature()) {
       return object_java_mirror();
     } else if (s == vmSymbols::class_signature()) {
-      return Klass::cast(SystemDictionary::Class_klass())->java_mirror();
+      return SystemDictionary::Class_klass()->java_mirror();
     } else if (s == vmSymbols::string_signature()) {
-      return Klass::cast(SystemDictionary::String_klass())->java_mirror();
+      return SystemDictionary::String_klass()->java_mirror();
     }
   }
   return NULL;
@@ -603,8 +603,8 @@
   {
     Klass* defc_klass = java_lang_Class::as_Klass(defc_oop());
     if (defc_klass == NULL)  return empty;  // a primitive; no resolution possible
-    if (!Klass::cast(defc_klass)->oop_is_instance()) {
-      if (!Klass::cast(defc_klass)->oop_is_array())  return empty;
+    if (!defc_klass->oop_is_instance()) {
+      if (!defc_klass->oop_is_array())  return empty;
       defc_klass = SystemDictionary::Object_klass();
     }
     defc = instanceKlassHandle(THREAD, defc_klass);
@@ -767,7 +767,7 @@
     {
       // This is taken from LinkResolver::resolve_field, sans access checks.
       assert(vmtarget->is_klass(), "field vmtarget is Klass*");
-      if (!Klass::cast((Klass*) vmtarget)->oop_is_instance())  break;
+      if (!((Klass*) vmtarget)->oop_is_instance())  break;
       instanceKlassHandle defc(THREAD, (Klass*) vmtarget);
       DEBUG_ONLY(vmtarget = NULL);  // safety
       bool is_static = ((flags & JVM_ACC_STATIC) != 0);
@@ -805,7 +805,7 @@
 
   // %%% take caller into account!
 
-  if (k == NULL || !Klass::cast(k)->oop_is_instance())  return -1;
+  if (k == NULL || !k->oop_is_instance())  return -1;
 
   int rfill = 0, rlimit = results->length(), rskip = skip;
   // overflow measurement:
@@ -1032,7 +1032,7 @@
       if (!Reflection::verify_class_access(caller,
                                            reference_klass,
                                            true)) {
-        THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), Klass::cast(reference_klass)->external_name());
+        THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), reference_klass->external_name());
       }
     }
   }
@@ -1108,7 +1108,7 @@
   if (vmtarget == NULL) {
     x = NULL;
   } else if (vmtarget->is_klass()) {
-    x = Klass::cast((Klass*) vmtarget)->java_mirror();
+    x = ((Klass*) vmtarget)->java_mirror();
   } else if (vmtarget->is_method()) {
     Handle mname2 = MethodHandles::new_MemberName(CHECK_NULL);
     x = MethodHandles::init_method_MemberName(mname2(), (Method*)vmtarget, false, NULL);
@@ -1237,7 +1237,7 @@
   if (SystemDictionary::MethodHandle_klass() == NULL) {
     enable_MH = false;
   } else {
-    oop mirror = Klass::cast(SystemDictionary::MethodHandle_klass())->java_mirror();
+    oop mirror = SystemDictionary::MethodHandle_klass()->java_mirror();
     MH_class = (jclass) JNIHandles::make_local(env, mirror);
   }
 
--- a/src/share/vm/prims/nativeLookup.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/nativeLookup.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -349,7 +349,7 @@
     TempNewSymbol wrapper_symbol = SymbolTable::probe(wrapper_name, wrapper_name_len);
     if (wrapper_symbol != NULL) {
       KlassHandle kh(method->method_holder());
-      Method* wrapper_method = Klass::cast(kh())->lookup_method(wrapper_symbol,
+      Method* wrapper_method = kh()->lookup_method(wrapper_symbol,
                                                                   method->signature());
       if (wrapper_method != NULL && !wrapper_method->is_native()) {
         // we found a wrapper method, use its native entry
--- a/src/share/vm/prims/unsafe.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/prims/unsafe.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -771,7 +771,7 @@
   oop mirror = JNIHandles::resolve_non_null(clazz);
 
   Klass* klass = java_lang_Class::as_Klass(mirror);
-  if (klass != NULL && Klass::cast(klass)->should_be_initialized()) {
+  if (klass != NULL && klass->should_be_initialized()) {
     InstanceKlass* k = InstanceKlass::cast(klass);
     k->initialize(CHECK);
   }
@@ -785,7 +785,7 @@
   }
   oop mirror = JNIHandles::resolve_non_null(clazz);
   Klass* klass = java_lang_Class::as_Klass(mirror);
-  if (klass != NULL && Klass::cast(klass)->should_be_initialized()) {
+  if (klass != NULL && klass->should_be_initialized()) {
     return true;
   }
   return false;
--- a/src/share/vm/runtime/arguments.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/arguments.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/javaAssertions.hpp"
+#include "classfile/symbolTable.hpp"
 #include "compiler/compilerOracle.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/cardTableRS.hpp"
@@ -1844,6 +1845,11 @@
   status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
   status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
 
+  // Divide by bucket size to prevent a large size from causing rollover when
+  // calculating amount of memory needed to be allocated for the String table.
+  status = status && verify_interval(StringTableSize, defaultStringTableSize,
+    (max_uintx / StringTable::bucket_size()), "StringTable size");
+
   if (MinHeapFreeRatio > MaxHeapFreeRatio) {
     jio_fprintf(defaultStream::error_stream(),
                 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
--- a/src/share/vm/runtime/biasedLocking.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/biasedLocking.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -39,7 +39,7 @@
 static GrowableArray<markOop>* _preserved_mark_stack = NULL;
 
 static void enable_biased_locking(Klass* k) {
-  Klass::cast(k)->set_prototype_header(markOopDesc::biased_locking_prototype());
+  k->set_prototype_header(markOopDesc::biased_locking_prototype());
 }
 
 class VM_EnableBiasedLocking: public VM_Operation {
@@ -149,7 +149,7 @@
     if (TraceBiasedLocking) {
       ResourceMark rm;
       tty->print_cr("  (Skipping revocation of object of type %s because it's no longer biased)",
-                    Klass::cast(obj->klass())->external_name());
+                    obj->klass()->external_name());
     }
     return BiasedLocking::NOT_BIASED;
   }
@@ -161,7 +161,7 @@
   if (TraceBiasedLocking && (Verbose || !is_bulk)) {
     ResourceMark rm;
     tty->print_cr("Revoking bias of object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s , prototype header " INTPTR_FORMAT " , allow rebias %d , requesting thread " INTPTR_FORMAT,
-                  (intptr_t) obj, (intptr_t) mark, Klass::cast(obj->klass())->external_name(), (intptr_t) Klass::cast(obj->klass())->prototype_header(), (allow_rebias ? 1 : 0), (intptr_t) requesting_thread);
+                  (intptr_t) obj, (intptr_t) mark, obj->klass()->external_name(), (intptr_t) obj->klass()->prototype_header(), (allow_rebias ? 1 : 0), (intptr_t) requesting_thread);
   }
 
   JavaThread* biased_thread = mark->biased_locker();
@@ -326,7 +326,7 @@
     tty->print_cr("* Beginning bulk revocation (kind == %s) because of object "
                   INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
                   (bulk_rebias ? "rebias" : "revoke"),
-                  (intptr_t) o, (intptr_t) o->mark(), Klass::cast(o->klass())->external_name());
+                  (intptr_t) o, (intptr_t) o->mark(), o->klass()->external_name());
   }
 
   jlong cur_time = os::javaTimeMillis();
@@ -334,7 +334,7 @@
 
 
   Klass* k_o = o->klass();
-  Klass* klass = Klass::cast(k_o);
+  Klass* klass = k_o;
 
   if (bulk_rebias) {
     // Use the epoch in the klass of the object to implicitly revoke
@@ -546,7 +546,7 @@
       return BIAS_REVOKED;
     }
   } else if (mark->has_bias_pattern()) {
-    Klass* k = Klass::cast(obj->klass());
+    Klass* k = obj->klass();
     markOop prototype_header = k->prototype_header();
     if (!prototype_header->has_bias_pattern()) {
       // This object has a stale bias from before the bulk revocation
@@ -590,7 +590,7 @@
   if (heuristics == HR_NOT_BIASED) {
     return NOT_BIASED;
   } else if (heuristics == HR_SINGLE_REVOKE) {
-    Klass *k = Klass::cast(obj->klass());
+    Klass *k = obj->klass();
     markOop prototype_header = k->prototype_header();
     if (mark->biased_locker() == THREAD &&
         prototype_header->bias_epoch() == mark->bias_epoch()) {
--- a/src/share/vm/runtime/globals.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/globals.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -3613,7 +3613,7 @@
   diagnostic(bool, PrintDTraceDOF, false,                                   \
              "Print the DTrace DOF passed to the system for JSDT probes")   \
                                                                             \
-  product(uintx, StringTableSize, 1009,                                     \
+  product(uintx, StringTableSize, defaultStringTableSize,                   \
           "Number of buckets in the interned String table")                 \
                                                                             \
   develop(bool, TraceDefaultMethods, false,                                 \
--- a/src/share/vm/runtime/os.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/os.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -582,7 +582,9 @@
     // if NULL is returned the calling functions assume out of memory.
     size = 1;
   }
-
+  if (size > size + space_before + space_after) { // Check for rollover.
+    return NULL;
+  }
   NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap());
   u_char* ptr = (u_char*)::malloc(size + space_before + space_after);
 
--- a/src/share/vm/runtime/reflection.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/reflection.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -70,8 +70,8 @@
     }
   }
   if (caller != NULL) {
-    const char * from = Klass::cast(caller)->external_name();
-    const char * to = Klass::cast(to_class)->external_name();
+    const char * from = caller->external_name();
+    const char * to = to_class->external_name();
     // print in a single call to reduce interleaving between threads
     if (source_file != NULL) {
       tty->print("RESOLVE %s %s %s:%d (reflection)\n", from, to, source_file, line_number);
@@ -330,7 +330,7 @@
     return TypeArrayKlass::cast(tak)->allocate(length, THREAD);
   } else {
     Klass* k = java_lang_Class::as_Klass(element_mirror);
-    if (Klass::cast(k)->oop_is_array() && ArrayKlass::cast(k)->dimension() >= MAX_DIM) {
+    if (k->oop_is_array() && ArrayKlass::cast(k)->dimension() >= MAX_DIM) {
       THROW_0(vmSymbols::java_lang_IllegalArgumentException());
     }
     return oopFactory::new_objArray(k, length, THREAD);
@@ -366,7 +366,7 @@
     klass = basic_type_mirror_to_arrayklass(element_mirror, CHECK_NULL);
   } else {
     klass = java_lang_Class::as_Klass(element_mirror);
-    if (Klass::cast(klass)->oop_is_array()) {
+    if (klass->oop_is_array()) {
       int k_dim = ArrayKlass::cast(klass)->dimension();
       if (k_dim + len > MAX_DIM) {
         THROW_0(vmSymbols::java_lang_IllegalArgumentException());
@@ -374,7 +374,7 @@
       dim += k_dim;
     }
   }
-  klass = Klass::cast(klass)->array_klass(dim, CHECK_NULL);
+  klass = klass->array_klass(dim, CHECK_NULL);
   oop obj = ArrayKlass::cast(klass)->multi_allocate(len, dimensions, THREAD);
   assert(obj->is_array(), "just checking");
   return arrayOop(obj);
@@ -387,7 +387,7 @@
   }
 
   Klass* klass = java_lang_Class::as_Klass(mirror);
-  if (!Klass::cast(klass)->oop_is_array()) {
+  if (!klass->oop_is_array()) {
     return NULL;
   }
 
@@ -395,15 +395,15 @@
 #ifdef ASSERT
   oop result2 = NULL;
   if (ArrayKlass::cast(klass)->dimension() == 1) {
-    if (Klass::cast(klass)->oop_is_typeArray()) {
+    if (klass->oop_is_typeArray()) {
       result2 = basic_type_arrayklass_to_mirror(klass, CHECK_NULL);
     } else {
-      result2 = Klass::cast(ObjArrayKlass::cast(klass)->element_klass())->java_mirror();
+      result2 = ObjArrayKlass::cast(klass)->element_klass()->java_mirror();
     }
   } else {
     Klass* lower_dim = ArrayKlass::cast(klass)->lower_dimension();
-    assert(Klass::cast(lower_dim)->oop_is_array(), "just checking");
-    result2 = Klass::cast(lower_dim)->java_mirror();
+    assert(lower_dim->oop_is_array(), "just checking");
+    result2 = lower_dim->java_mirror();
   }
   assert(result == result2, "results must be consistent");
 #endif //ASSERT
@@ -442,7 +442,7 @@
   if (acc.is_protected()) {
     if (target_class != client_class) {
       if (!is_same_class_package(client_class, field_class)) {
-        if (!Klass::cast(target_class)->is_subclass_of(client_class)) {
+        if (!target_class->is_subclass_of(client_class)) {
           THROW_(vmSymbols::java_lang_IllegalAccessException(), false);
         }
       }
@@ -468,7 +468,7 @@
   // sun/reflect/MagicAccessorImpl subclasses to succeed trivially.
   if (   JDK_Version::is_gte_jdk14x_version()
       && UseNewReflection
-      && Klass::cast(current_class)->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
+      && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
     return true;
   }
 
@@ -546,12 +546,12 @@
   if (access.is_protected()) {
     if (!protected_restriction) {
       // See if current_class is a subclass of field_class
-      if (Klass::cast(current_class)->is_subclass_of(field_class)) {
+      if (current_class->is_subclass_of(field_class)) {
         if (access.is_static() || // static fields are ok, see 6622385
             current_class == resolved_class ||
             field_class == resolved_class ||
-            Klass::cast(current_class)->is_subclass_of(resolved_class) ||
-            Klass::cast(resolved_class)->is_subclass_of(current_class)) {
+            current_class->is_subclass_of(resolved_class) ||
+            resolved_class->is_subclass_of(current_class)) {
           return true;
         }
       }
@@ -566,7 +566,7 @@
   // sun/reflect/MagicAccessorImpl subclasses to succeed trivially.
   if (   JDK_Version::is_gte_jdk14x_version()
       && UseNewReflection
-      && Klass::cast(current_class)->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
+      && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
     return true;
   }
 
@@ -693,7 +693,7 @@
   }
 
   oop loader = InstanceKlass::cast(k())->class_loader();
-  oop protection_domain = Klass::cast(k())->protection_domain();
+  oop protection_domain = k()->protection_domain();
   Klass* result = SystemDictionary::resolve_or_fail(signature,
                                     Handle(THREAD, loader),
                                     Handle(THREAD, protection_domain),
@@ -703,7 +703,7 @@
     trace_class_resolution(result);
   }
 
-  oop nt = Klass::cast(result)->java_mirror();
+  oop nt = result->java_mirror();
   return Handle(THREAD, nt);
 }
 
@@ -937,7 +937,7 @@
               ResourceMark rm(THREAD);
               Handle h_origexception = Exceptions::new_exception(THREAD,
                      vmSymbols::java_lang_AbstractMethodError(),
-                     Method::name_and_sig_as_C_string(Klass::cast(target_klass()),
+                     Method::name_and_sig_as_C_string(target_klass(),
                      method->name(),
                      method->signature()));
               JavaCallArguments args(h_origexception);
@@ -947,7 +947,7 @@
             } else {
               ResourceMark rm(THREAD);
               THROW_MSG_0(vmSymbols::java_lang_AbstractMethodError(),
-                        Method::name_and_sig_as_C_string(Klass::cast(target_klass()),
+                        Method::name_and_sig_as_C_string(target_klass(),
                                                                 method->name(),
                                                                 method->signature()));
             }
@@ -962,7 +962,7 @@
   if (method.is_null()) {
     ResourceMark rm(THREAD);
     THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(),
-                Method::name_and_sig_as_C_string(Klass::cast(klass()),
+                Method::name_and_sig_as_C_string(klass(),
                                                         reflected_method->name(),
                                                         reflected_method->signature()));
   }
--- a/src/share/vm/runtime/sharedRuntime.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -1775,7 +1775,7 @@
   // The copy_array mechanism is awkward and could be removed, but
   // the compilers don't call this function except as a last resort,
   // so it probably doesn't matter.
-  Klass::cast(src->klass())->copy_array((arrayOopDesc*)src,  src_pos,
+  src->klass()->copy_array((arrayOopDesc*)src,  src_pos,
                                         (arrayOopDesc*)dest, dest_pos,
                                         length, thread);
 }
@@ -1788,8 +1788,8 @@
   vframeStream vfst(thread, true);
   assert(!vfst.at_end(), "Java frame must exist");
   Bytecode_checkcast cc(vfst.method(), vfst.method()->bcp_from(vfst.bci()));
-  Klass* targetKlass = Klass::cast(vfst.method()->constants()->klass_at(
-    cc.index(), thread));
+  Klass* targetKlass = vfst.method()->constants()->klass_at(
+    cc.index(), thread);
   return generate_class_cast_message(objName, targetKlass->external_name());
 }
 
--- a/src/share/vm/runtime/signature.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/signature.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -354,7 +354,7 @@
     return Universe::java_mirror(type());
   Klass* klass = as_klass(class_loader, protection_domain, failure_mode, CHECK_NULL);
   if (klass == NULL)  return NULL;
-  return Klass::cast(klass)->java_mirror();
+  return klass->java_mirror();
 }
 
 Symbol* SignatureStream::as_symbol_or_null() {
--- a/src/share/vm/runtime/synchronizer.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/synchronizer.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -1323,7 +1323,7 @@
               ResourceMark rm;
               tty->print_cr("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
                 (intptr_t) object, (intptr_t) object->mark(),
-                Klass::cast(object->klass())->external_name());
+                object->klass()->external_name());
             }
           }
           return m ;
@@ -1373,7 +1373,7 @@
           ResourceMark rm;
           tty->print_cr("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
             (intptr_t) object, (intptr_t) object->mark(),
-            Klass::cast(object->klass())->external_name());
+            object->klass()->external_name());
         }
       }
       return m ;
@@ -1440,7 +1440,7 @@
        if (obj->is_instance()) {
          ResourceMark rm;
            tty->print_cr("Deflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s",
-                (intptr_t) obj, (intptr_t) obj->mark(), Klass::cast(obj->klass())->external_name());
+                (intptr_t) obj, (intptr_t) obj->mark(), obj->klass()->external_name());
        }
      }
 
--- a/src/share/vm/runtime/thread.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/thread.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -1785,7 +1785,7 @@
           jio_fprintf(defaultStream::error_stream(),
                 "\nException: %s thrown from the UncaughtExceptionHandler"
                 " in thread \"%s\"\n",
-                Klass::cast(pending_exception()->klass())->external_name(),
+                pending_exception()->klass()->external_name(),
                 get_thread_name());
           CLEAR_PENDING_EXCEPTION;
         }
--- a/src/share/vm/runtime/vframe.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/runtime/vframe.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -149,7 +149,7 @@
       Klass* target_klass = java_lang_Class::as_Klass(obj());
       st->print_cr("(a java.lang.Class for %s)", InstanceKlass::cast(target_klass)->external_name());
     } else {
-      Klass* k = Klass::cast(obj->klass());
+      Klass* k = obj->klass();
       st->print_cr("(a %s)", k->external_name());
     }
   }
@@ -172,7 +172,7 @@
       }
     } else if (thread()->current_park_blocker() != NULL) {
       oop obj = thread()->current_park_blocker();
-      Klass* k = Klass::cast(obj->klass());
+      Klass* k = obj->klass();
       st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", (address)obj, k->external_name());
     }
   }
@@ -550,7 +550,7 @@
   InstanceKlass*     k = m->method_holder();
   tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")",
                 _fr.sp(),  _fr.unextended_sp(), _fr.fp(), _fr.pc());
-  tty->print("%s.%s", Klass::cast(k)->internal_name(), m->name()->as_C_string());
+  tty->print("%s.%s", k->internal_name(), m->name()->as_C_string());
 
   if (!m->is_native()) {
     Symbol*  source_name = k->source_file_name();
--- a/src/share/vm/services/classLoadingService.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/classLoadingService.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -135,7 +135,7 @@
     // The spec is unclear at this point to count array klasses or not
     // and also indirect creation of array of super class and secondaries
     //
-    // for (Klass* l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
+    // for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
     //  KlassHandle h(_current_thread, l);
     //  _loaded_classes->append(h);
     // }
--- a/src/share/vm/services/heapDumper.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/heapDumper.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -879,7 +879,7 @@
   writer->write_u4(STACK_TRACE_ID);
 
   // class ID
-  writer->write_classID(Klass::cast(k));
+  writer->write_classID(k);
 
   // number of bytes that follow
   writer->write_u4(instance_size(k) );
@@ -891,7 +891,7 @@
 // creates HPROF_GC_CLASS_DUMP record for the given class and each of
 // its array classes
 void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) {
-  Klass* klass = Klass::cast(k);
+  Klass* klass = k;
   assert(klass->oop_is_instance(), "not an InstanceKlass");
   InstanceKlass* ik = (InstanceKlass*)klass;
 
@@ -906,7 +906,7 @@
   if (java_super == NULL) {
     writer->write_objectID(oop(NULL));
   } else {
-    writer->write_classID(Klass::cast(java_super));
+    writer->write_classID(java_super);
   }
 
   writer->write_objectID(ik->class_loader());
@@ -932,7 +932,7 @@
   // array classes
   k = klass->array_klass_or_null();
   while (k != NULL) {
-    Klass* klass = Klass::cast(k);
+    Klass* klass = k;
     assert(klass->oop_is_objArray(), "not an ObjArrayKlass");
 
     writer->write_u1(HPROF_GC_CLASS_DUMP);
@@ -942,7 +942,7 @@
     // super class of array classes is java.lang.Object
     java_super = klass->java_super();
     assert(java_super != NULL, "checking");
-    writer->write_classID(Klass::cast(java_super));
+    writer->write_classID(java_super);
 
     writer->write_objectID(ik->class_loader());
     writer->write_objectID(ik->signers());
@@ -965,7 +965,7 @@
 void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, Klass* k) {
  // array classes
  while (k != NULL) {
-    Klass* klass = Klass::cast(k);
+    Klass* klass = k;
 
     writer->write_u1(HPROF_GC_CLASS_DUMP);
     writer->write_classID(klass);
@@ -974,7 +974,7 @@
     // super class of array classes is java.lang.Object
     Klass* java_super = klass->java_super();
     assert(java_super != NULL, "checking");
-    writer->write_classID(Klass::cast(java_super));
+    writer->write_classID(java_super);
 
     writer->write_objectID(oop(NULL));    // loader
     writer->write_objectID(oop(NULL));    // signers
@@ -1001,7 +1001,7 @@
   writer->write_u4((u4)array->length());
 
   // array class ID
-  writer->write_classID(Klass::cast(array->klass()));
+  writer->write_classID(array->klass());
 
   // [id]* elements
   for (int index=0; index<array->length(); index++) {
@@ -1525,7 +1525,7 @@
     writer()->write_u4(++class_serial_num);
 
     // class ID
-    Klass* klass = Klass::cast(k);
+    Klass* klass = k;
     writer()->write_classID(klass);
 
     // add the Klass* and class serial number pair
@@ -1796,7 +1796,7 @@
       // write fake frame that makes it look like the thread, which caused OOME,
       // is in the OutOfMemoryError zero-parameter constructor
       if (thread == _oome_thread && _oome_constructor != NULL) {
-        int oome_serial_num = _klass_map->find(Klass::cast(_oome_constructor->method_holder()));
+        int oome_serial_num = _klass_map->find(_oome_constructor->method_holder());
         // the class serial number starts from 1
         assert(oome_serial_num > 0, "OutOfMemoryError class not found");
         DumperSupport::dump_stack_frame(writer(), ++frame_serial_num, oome_serial_num,
@@ -1806,7 +1806,7 @@
       for (int j=0; j < depth; j++) {
         StackFrameInfo* frame = stack_trace->stack_frame_at(j);
         Method* m = frame->method();
-        int class_serial_num = _klass_map->find(Klass::cast(m->method_holder()));
+        int class_serial_num = _klass_map->find(m->method_holder());
         // the class serial number starts from 1
         assert(class_serial_num > 0, "class not found");
         DumperSupport::dump_stack_frame(writer(), ++frame_serial_num, class_serial_num, m, frame->bci());
--- a/src/share/vm/services/management.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/management.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -1417,7 +1417,7 @@
 
   for (int i = 0; i < num_classes; i++) {
     KlassHandle kh = lce.get_klass(i);
-    oop mirror = Klass::cast(kh())->java_mirror();
+    oop mirror = kh()->java_mirror();
     classes_ah->obj_at_put(i, mirror);
   }
 
--- a/src/share/vm/services/memBaseline.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/memBaseline.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -115,17 +115,25 @@
   while (malloc_ptr != NULL) {
     index = flag2index(FLAGS_TO_MEMORY_TYPE(malloc_ptr->flags()));
     size_t size = malloc_ptr->size();
-    _total_malloced += size;
-    _malloc_data[index].inc(size);
-    if (MemPointerRecord::is_arena_record(malloc_ptr->flags())) {
-      // see if arena size record present
-      MemPointerRecord* next_malloc_ptr = (MemPointerRecordEx*)malloc_itr.peek_next();
-      if (MemPointerRecord::is_arena_size_record(next_malloc_ptr->flags())) {
-        assert(next_malloc_ptr->is_size_record_of_arena(malloc_ptr), "arena records do not match");
-        size = next_malloc_ptr->size();
-        _arena_data[index].inc(size);
-        used_arena_size += size;
-        malloc_itr.next();
+    if (malloc_ptr->is_arena_memory_record()) {
+      // We do have anonymous arenas, they are either used as value objects,
+      // which are embedded inside other objects, or used as stack objects.
+      _arena_data[index].inc(size);
+      used_arena_size += size;
+    } else {
+      _total_malloced += size;
+      _malloc_data[index].inc(size);
+      if (malloc_ptr->is_arena_record()) {
+        // see if arena memory record present
+        MemPointerRecord* next_malloc_ptr = (MemPointerRecordEx*)malloc_itr.peek_next();
+        if (next_malloc_ptr->is_arena_memory_record()) {
+          assert(next_malloc_ptr->is_memory_record_of_arena(malloc_ptr),
+             "Arena records do not match");
+          size = next_malloc_ptr->size();
+          _arena_data[index].inc(size);
+          used_arena_size += size;
+          malloc_itr.next();
+        }
       }
     }
     malloc_ptr = (MemPointerRecordEx*)malloc_itr.next();
@@ -193,7 +201,7 @@
 
   // baseline memory that is totaled over 1 KB
   while (malloc_ptr != NULL) {
-    if (!MemPointerRecord::is_arena_size_record(malloc_ptr->flags())) {
+    if (!MemPointerRecord::is_arena_memory_record(malloc_ptr->flags())) {
       // skip thread stacks
       if (!IS_MEMORY_TYPE(malloc_ptr->flags(), mtThreadStack)) {
         if (malloc_callsite.addr() != malloc_ptr->pc()) {
--- a/src/share/vm/services/memPtr.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/memPtr.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -165,7 +165,7 @@
     return (flags & (otArena | tag_size)) == otArena;
   }
 
-  inline static bool is_arena_size_record(MEMFLAGS flags) {
+  inline static bool is_arena_memory_record(MEMFLAGS flags) {
     return (flags & (otArena | tag_size)) == (otArena | tag_size);
   }
 
@@ -256,8 +256,8 @@
   }
 
   // if this record records a size information of an arena
-  inline bool is_arena_size_record() const {
-    return is_arena_size_record(_flags);
+  inline bool is_arena_memory_record() const {
+    return is_arena_memory_record(_flags);
   }
 
   // if this pointer represents an address to an arena object
@@ -266,8 +266,8 @@
   }
 
   // if this record represents a size information of specific arena
-  inline bool is_size_record_of_arena(const MemPointerRecord* arena_rc) {
-    assert(is_arena_size_record(), "not size record");
+  inline bool is_memory_record_of_arena(const MemPointerRecord* arena_rc) {
+    assert(is_arena_memory_record(), "not size record");
     assert(arena_rc->is_arena_record(), "not arena record");
     return (arena_rc->addr() + sizeof(void*)) == addr();
   }
--- a/src/share/vm/services/memSnapshot.cpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/memSnapshot.cpp	Fri Nov 16 09:19:12 2012 -0500
@@ -50,7 +50,7 @@
       tty->print_cr(" (tag)");
     }
   } else {
-    if (rec->is_arena_size_record()) {
+    if (rec->is_arena_memory_record()) {
       tty->print_cr(" (arena size)");
     } else if (rec->is_allocation_record()) {
       tty->print_cr(" (malloc)");
@@ -123,20 +123,31 @@
 // in different types.
 bool VMMemPointerIterator::add_reserved_region(MemPointerRecord* rec) {
   assert(rec->is_allocation_record(), "Sanity check");
-  VMMemRegion* cur = (VMMemRegion*)current();
+  VMMemRegion* reserved_region = (VMMemRegion*)current();
 
   // we don't have anything yet
-  if (cur == NULL) {
+  if (reserved_region == NULL) {
     return insert_record(rec);
   }
 
-  assert(cur->is_reserved_region(), "Sanity check");
+  assert(reserved_region->is_reserved_region(), "Sanity check");
   // duplicated records
-  if (cur->is_same_region(rec)) {
+  if (reserved_region->is_same_region(rec)) {
     return true;
   }
-  assert(cur->base() > rec->addr(), "Just check: locate()");
-  assert(!cur->overlaps_region(rec), "overlapping reserved regions");
+  // Overlapping stack regions indicate that a JNI thread failed to
+  // detach from the VM before exiting. This leaks the JavaThread object.
+  if (CheckJNICalls)  {
+      guarantee(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) != mtThreadStack ||
+         !reserved_region->overlaps_region(rec),
+         "Attached JNI thread exited without being detached");
+  }
+  // otherwise, we should not have overlapping reserved regions
+  assert(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) == mtThreadStack ||
+    reserved_region->base() > rec->addr(), "Just check: locate()");
+  assert(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) == mtThreadStack ||
+    !reserved_region->overlaps_region(rec), "overlapping reserved regions");
+
   return insert_record(rec);
 }
 
@@ -390,21 +401,31 @@
   }
 }
 
-void MemSnapshot::copy_pointer(MemPointerRecord* dest, const MemPointerRecord* src) {
+
+void MemSnapshot::copy_seq_pointer(MemPointerRecord* dest, const MemPointerRecord* src) {
   assert(dest != NULL && src != NULL, "Just check");
   assert(dest->addr() == src->addr(), "Just check");
+  assert(dest->seq() > 0 && src->seq() > 0, "not sequenced");
 
-  MEMFLAGS flags = dest->flags();
+  if (MemTracker::track_callsite()) {
+    *(SeqMemPointerRecordEx*)dest = *(SeqMemPointerRecordEx*)src;
+  } else {
+    *(SeqMemPointerRecord*)dest = *(SeqMemPointerRecord*)src;
+  }
+}
+
+void MemSnapshot::assign_pointer(MemPointerRecord*dest, const MemPointerRecord* src) {
+  assert(src != NULL && dest != NULL, "Just check");
+  assert(dest->seq() == 0 && src->seq() >0, "cast away sequence");
 
   if (MemTracker::track_callsite()) {
     *(MemPointerRecordEx*)dest = *(MemPointerRecordEx*)src;
   } else {
-    *dest = *src;
+    *(MemPointerRecord*)dest = *(MemPointerRecord*)src;
   }
 }
 
-
-// merge a per-thread memory recorder to the staging area
+// merge a recorder to the staging area
 bool MemSnapshot::merge(MemRecorder* rec) {
   assert(rec != NULL && !rec->out_of_memory(), "Just check");
 
@@ -412,71 +433,45 @@
 
   MutexLockerEx lock(_lock, true);
   MemPointerIterator malloc_staging_itr(_staging_area.malloc_data());
-  MemPointerRecord *p1, *p2;
-  p1 = (MemPointerRecord*) itr.current();
-  while (p1 != NULL) {
-    if (p1->is_vm_pointer()) {
+  MemPointerRecord* incoming_rec = (MemPointerRecord*) itr.current();
+  MemPointerRecord* matched_rec;
+
+  while (incoming_rec != NULL) {
+    if (incoming_rec->is_vm_pointer()) {
       // we don't do anything with virtual memory records during merge
-      if (!_staging_area.vm_data()->append(p1)) {
+      if (!_staging_area.vm_data()->append(incoming_rec)) {
         return false;
       }
     } else {
       // locate matched record and/or also position the iterator to proper
       // location for this incoming record.
-      p2 = (MemPointerRecord*)malloc_staging_itr.locate(p1->addr());
-      // we have not seen this memory block, so just add to staging area
-      if (p2 == NULL) {
-        if (!malloc_staging_itr.insert(p1)) {
+      matched_rec = (MemPointerRecord*)malloc_staging_itr.locate(incoming_rec->addr());
+      // we have not seen this memory block in this generation,
+      // so just add to staging area
+      if (matched_rec == NULL) {
+        if (!malloc_staging_itr.insert(incoming_rec)) {
           return false;
         }
-      } else if (p1->addr() == p2->addr()) {
-        MemPointerRecord* staging_next = (MemPointerRecord*)malloc_staging_itr.peek_next();
-        // a memory block can have many tagging records, find right one to replace or
-        // right position to insert
-        while (staging_next != NULL && staging_next->addr() == p1->addr()) {
-          if ((staging_next->flags() & MemPointerRecord::tag_masks) <=
-            (p1->flags() & MemPointerRecord::tag_masks)) {
-            p2 = (MemPointerRecord*)malloc_staging_itr.next();
-            staging_next = (MemPointerRecord*)malloc_staging_itr.peek_next();
-          } else {
-            break;
-          }
+      } else if (incoming_rec->addr() == matched_rec->addr()) {
+        // whoever has higher sequence number wins
+        if (incoming_rec->seq() > matched_rec->seq()) {
+          copy_seq_pointer(matched_rec, incoming_rec);
         }
-        int df = (p1->flags() & MemPointerRecord::tag_masks) -
-          (p2->flags() & MemPointerRecord::tag_masks);
-        if (df == 0) {
-          assert(p1->seq() > 0, "not sequenced");
-          assert(p2->seq() > 0, "not sequenced");
-          if (p1->seq() > p2->seq()) {
-            copy_pointer(p2, p1);
-          }
-        } else if (df < 0) {
-          if (!malloc_staging_itr.insert(p1)) {
-            return false;
-          }
-        } else {
-          if (!malloc_staging_itr.insert_after(p1)) {
-            return false;
-          }
-        }
-      } else if (p1->addr() < p2->addr()) {
-        if (!malloc_staging_itr.insert(p1)) {
+      } else if (incoming_rec->addr() < matched_rec->addr()) {
+        if (!malloc_staging_itr.insert(incoming_rec)) {
           return false;
         }
       } else {
-        if (!malloc_staging_itr.insert_after(p1)) {
-          return false;
-        }
+        ShouldNotReachHere();
       }
     }
-    p1 = (MemPointerRecord*)itr.next();
+    incoming_rec = (MemPointerRecord*)itr.next();
   }
   NOT_PRODUCT(void check_staging_data();)
   return true;
 }
 
 
-
 // promote data to next generation
 bool MemSnapshot::promote() {
   assert(_alloc_ptrs != NULL && _vm_ptrs != NULL, "Just check");
@@ -507,20 +502,25 @@
     // found matched memory block
     if (matched_rec != NULL && new_rec->addr() == matched_rec->addr()) {
       // snapshot already contains 'live' records
-      assert(matched_rec->is_allocation_record() || matched_rec->is_arena_size_record(),
+      assert(matched_rec->is_allocation_record() || matched_rec->is_arena_memory_record(),
              "Sanity check");
       // update block states
-      if (new_rec->is_allocation_record() || new_rec->is_arena_size_record()) {
-        copy_pointer(matched_rec, new_rec);
+      if (new_rec->is_allocation_record()) {
+        assign_pointer(matched_rec, new_rec);
+      } else if (new_rec->is_arena_memory_record()) {
+        if (new_rec->size() == 0) {
+          // remove size record once size drops to 0
+          malloc_snapshot_itr.remove();
+        } else {
+          assign_pointer(matched_rec, new_rec);
+        }
       } else {
         // a deallocation record
         assert(new_rec->is_deallocation_record(), "Sanity check");
         // an arena record can be followed by a size record, we need to remove both
         if (matched_rec->is_arena_record()) {
           MemPointerRecord* next = (MemPointerRecord*)malloc_snapshot_itr.peek_next();
-          if (next->is_arena_size_record()) {
-            // it has to match the arena record
-            assert(next->is_size_record_of_arena(matched_rec), "Sanity check");
+          if (next->is_arena_memory_record() && next->is_memory_record_of_arena(matched_rec)) {
             malloc_snapshot_itr.remove();
           }
         }
@@ -528,17 +528,13 @@
         malloc_snapshot_itr.remove();
       }
     } else {
-      // it is a new record, insert into snapshot
-      if (new_rec->is_arena_size_record()) {
-        MemPointerRecord* prev = (MemPointerRecord*)malloc_snapshot_itr.peek_prev();
-        if (prev == NULL || !prev->is_arena_record() || !new_rec->is_size_record_of_arena(prev)) {
-          // no matched arena record, ignore the size record
-          new_rec = NULL;
-        }
+      // don't insert size 0 record
+      if (new_rec->is_arena_memory_record() && new_rec->size() == 0) {
+        new_rec = NULL;
       }
-      // only 'live' record can go into snapshot
+
       if (new_rec != NULL) {
-        if  (new_rec->is_allocation_record() || new_rec->is_arena_size_record()) {
+        if  (new_rec->is_allocation_record() || new_rec->is_arena_memory_record()) {
           if (matched_rec != NULL && new_rec->addr() > matched_rec->addr()) {
             if (!malloc_snapshot_itr.insert_after(new_rec)) {
               return false;
--- a/src/share/vm/services/memSnapshot.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/memSnapshot.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -31,7 +31,6 @@
 #include "services/memBaseline.hpp"
 #include "services/memPtrArray.hpp"
 
-
 // Snapshot pointer array iterator
 
 // The pointer array contains malloc-ed pointers
@@ -165,39 +164,58 @@
 };
 
 class MallocRecordIterator : public MemPointerArrayIterator {
- protected:
+ private:
   MemPointerArrayIteratorImpl  _itr;
 
+
+
  public:
   MallocRecordIterator(MemPointerArray* arr) : _itr(arr) {
   }
 
   virtual MemPointer* current() const {
-    MemPointerRecord* cur = (MemPointerRecord*)_itr.current();
-    assert(cur == NULL || !cur->is_vm_pointer(), "seek error");
-    MemPointerRecord* next = (MemPointerRecord*)_itr.peek_next();
-    if (next == NULL || next->addr() != cur->addr()) {
-      return cur;
-    } else {
-      assert(!cur->is_vm_pointer(), "Sanity check");
-      assert(cur->is_allocation_record() && next->is_deallocation_record(),
-             "sorting order");
-      assert(cur->seq() != next->seq(), "Sanity check");
-      return cur->seq() >  next->seq() ? cur : next;
+#ifdef ASSERT
+    MemPointer* cur_rec = _itr.current();
+    if (cur_rec != NULL) {
+      MemPointer* prev_rec = _itr.peek_prev();
+      MemPointer* next_rec = _itr.peek_next();
+      assert(prev_rec == NULL || prev_rec->addr() < cur_rec->addr(), "Sorting order");
+      assert(next_rec == NULL || next_rec->addr() > cur_rec->addr(), "Sorting order");
     }
+#endif
+    return _itr.current();
   }
-
   virtual MemPointer* next() {
-    MemPointerRecord* cur = (MemPointerRecord*)_itr.current();
-    assert(cur == NULL || !cur->is_vm_pointer(), "Sanity check");
-    MemPointerRecord* next = (MemPointerRecord*)_itr.next();
-    if (next == NULL) {
-      return NULL;
+    MemPointerRecord* next_rec = (MemPointerRecord*)_itr.next();
+    // arena memory record is a special case, which we have to compare
+    // sequence number against its associated arena record.
+    if (next_rec != NULL && next_rec->is_arena_memory_record()) {
+      MemPointerRecord* prev_rec = (MemPointerRecord*)_itr.peek_prev();
+      // if there is an associated arena record, it has to be previous
+      // record because of sorting order (by address) - NMT generates a pseudo address
+      // for arena's size record by offsetting arena's address, that guarantees
+      // the order of arena record and it's size record.
+      if (prev_rec != NULL && prev_rec->is_arena_record() &&
+        next_rec->is_memory_record_of_arena(prev_rec)) {
+        if (prev_rec->seq() > next_rec->seq()) {
+          // Skip this arena memory record
+          // Two scenarios:
+          //   - if the arena record is an allocation record, this early
+          //     size record must be leftover by previous arena,
+          //     and the last size record should have size = 0.
+          //   - if the arena record is a deallocation record, this
+          //     size record should be its cleanup record, which should
+          //     also have size = 0. In other world, arena alway reset
+          //     its size before gone (see Arena's destructor)
+          assert(next_rec->size() == 0, "size not reset");
+          return _itr.next();
+        } else {
+          assert(prev_rec->is_allocation_record(),
+            "Arena size record ahead of allocation record");
+        }
+      }
     }
-    if (cur->addr() == next->addr()) {
-      next = (MemPointerRecord*)_itr.next();
-    }
-    return current();
+    return next_rec;
   }
 
   MemPointer* peek_next() const      { ShouldNotReachHere(); return NULL; }
@@ -213,9 +231,12 @@
 // still chances seeing duplicated records during promotion.
 // We want to use the record with higher sequence number, because it has
 // more accurate callsite pc.
-class VMRecordIterator : public MallocRecordIterator {
+class VMRecordIterator : public MemPointerArrayIterator {
+ private:
+  MemPointerArrayIteratorImpl  _itr;
+
  public:
-  VMRecordIterator(MemPointerArray* arr) : MallocRecordIterator(arr) {
+  VMRecordIterator(MemPointerArray* arr) : _itr(arr) {
     MemPointerRecord* cur = (MemPointerRecord*)_itr.current();
     MemPointerRecord* next = (MemPointerRecord*)_itr.peek_next();
     while (next != NULL) {
@@ -256,6 +277,12 @@
     return cur;
   }
 
+  MemPointer* peek_next() const      { ShouldNotReachHere(); return NULL; }
+  MemPointer* peek_prev() const      { ShouldNotReachHere(); return NULL; }
+  void remove()                      { ShouldNotReachHere(); }
+  bool insert(MemPointer* ptr)       { ShouldNotReachHere(); return false; }
+  bool insert_after(MemPointer* ptr) { ShouldNotReachHere(); return false; }
+
  private:
   bool is_duplicated_record(MemPointerRecord* p1, MemPointerRecord* p2) const {
     bool ret = (p1->addr() == p2->addr() && p1->size() == p2->size() && p1->flags() == p2->flags());
@@ -348,8 +375,10 @@
   DEBUG_ONLY( void dump_all_vm_pointers();)
 
  private:
-   // copy pointer data from src to dest
-   void copy_pointer(MemPointerRecord* dest, const MemPointerRecord* src);
+   // copy sequenced pointer from src to dest
+   void copy_seq_pointer(MemPointerRecord* dest, const MemPointerRecord* src);
+   // assign a sequenced pointer to non-sequenced pointer
+   void assign_pointer(MemPointerRecord*dest, const MemPointerRecord* src);
 
    bool promote_malloc_records(MemPointerArrayIterator* itr);
    bool promote_virtual_memory_records(MemPointerArrayIterator* itr);
--- a/src/share/vm/services/memTracker.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/memTracker.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -284,14 +284,14 @@
     }
   }
 
-  // record arena size
+  // record arena memory size
   static inline void record_arena_size(address addr, size_t size) {
-    // we add a positive offset to arena address, so we can have arena size record
+    // we add a positive offset to arena address, so we can have arena memory record
     // sorted after arena record
     if (is_on() && !UseMallocOnly) {
       assert(addr != NULL, "Sanity check");
       create_memory_record((addr + sizeof(void*)), MemPointerRecord::arena_size_tag(), size,
-        0, NULL);
+        DEBUG_CALLER_PC, NULL);
     }
   }
 
--- a/src/share/vm/services/serviceUtil.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/services/serviceUtil.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -57,14 +57,13 @@
       if (k->is_klass()) {
         // if it's a class for an object, an object array, or
         // primitive (type) array then it's visible.
-        Klass* klass = k;
-        if (Klass::cast(klass)->oop_is_instance()) {
+        if (k->oop_is_instance()) {
           return true;
         }
-        if (Klass::cast(klass)->oop_is_objArray()) {
+        if (k->oop_is_objArray()) {
           return true;
         }
-        if (Klass::cast(klass)->oop_is_typeArray()) {
+        if (k->oop_is_typeArray()) {
           return true;
         }
       }
--- a/src/share/vm/utilities/globalDefinitions.hpp	Fri Nov 16 09:59:08 2012 +0100
+++ b/src/share/vm/utilities/globalDefinitions.hpp	Fri Nov 16 09:19:12 2012 -0500
@@ -328,6 +328,12 @@
 
 
 //----------------------------------------------------------------------------------------------------
+// Minimum StringTableSize value
+
+const int defaultStringTableSize=1009;
+
+
+//----------------------------------------------------------------------------------------------------
 // HotSwap - for JVMTI   aka Class File Replacement and PopFrame
 //
 // Determines whether on-the-fly class replacement and frame popping are enabled.