8232881: Remove unnecessary InstanceKlass::casts
authorredestad
Wed, 23 Oct 2019 18:34:25 +0200
changeset 58760 1f7f707c1aa9
parent 58759 4242e35767b5
child 58764 015949faea55
child 58766 54ffb15c4839
8232881: Remove unnecessary InstanceKlass::casts Reviewed-by: coleenp
src/hotspot/share/classfile/classListParser.cpp
src/hotspot/share/classfile/defaultMethods.cpp
src/hotspot/share/classfile/systemDictionary.cpp
src/hotspot/share/classfile/verificationType.cpp
src/hotspot/share/jvmci/jvmciRuntime.cpp
src/hotspot/share/prims/jniCheck.cpp
--- a/src/hotspot/share/classfile/classListParser.cpp	Wed Oct 23 17:35:32 2019 +0200
+++ b/src/hotspot/share/classfile/classListParser.cpp	Wed Oct 23 18:34:25 2019 +0200
@@ -229,17 +229,17 @@
   jio_fprintf(defaultStream::error_stream(), "}\n");
 }
 
-void ClassListParser::print_actual_interfaces(InstanceKlass *ik) {
+void ClassListParser::print_actual_interfaces(InstanceKlass* ik) {
   int n = ik->local_interfaces()->length();
   jio_fprintf(defaultStream::error_stream(), "Actual interfaces[%d] = {\n", n);
   for (int i = 0; i < n; i++) {
-    InstanceKlass* e = InstanceKlass::cast(ik->local_interfaces()->at(i));
+    InstanceKlass* e = ik->local_interfaces()->at(i);
     jio_fprintf(defaultStream::error_stream(), "  %s\n", e->name()->as_klass_external_name());
   }
   jio_fprintf(defaultStream::error_stream(), "}\n");
 }
 
-void ClassListParser::error(const char *msg, ...) {
+void ClassListParser::error(const char* msg, ...) {
   va_list ap;
   va_start(ap, msg);
   int error_index = _token - _line;
@@ -328,7 +328,7 @@
 Klass* ClassListParser::load_current_class(TRAPS) {
   TempNewSymbol class_name_symbol = SymbolTable::new_symbol(_class_name);
 
-  Klass *klass = NULL;
+  Klass* klass = NULL;
   if (!is_loading_from_source()) {
     // Load classes for the boot/platform/app loaders only.
     if (is_super_specified()) {
--- a/src/hotspot/share/classfile/defaultMethods.cpp	Wed Oct 23 17:35:32 2019 +0200
+++ b/src/hotspot/share/classfile/defaultMethods.cpp	Wed Oct 23 18:34:25 2019 +0200
@@ -146,7 +146,7 @@
       return interface_index() >= number_of_interfaces();
     }
     InstanceKlass* interface_at(int index) {
-      return InstanceKlass::cast(_class->local_interfaces()->at(index));
+      return _class->local_interfaces()->at(index);
     }
     InstanceKlass* next_super() { return _class->java_super(); }
     InstanceKlass* next_interface() {
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Wed Oct 23 17:35:32 2019 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Wed Oct 23 18:34:25 2019 +0200
@@ -1989,14 +1989,14 @@
   resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Reference_klass), scan, CHECK);
 
   // Preload ref klasses and set reference types
-  InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER);
+  WK_KLASS(Reference_klass)->set_reference_type(REF_OTHER);
   InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass));
 
   resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK);
-  InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT);
-  InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK);
-  InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL);
-  InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM);
+  WK_KLASS(SoftReference_klass)->set_reference_type(REF_SOFT);
+  WK_KLASS(WeakReference_klass)->set_reference_type(REF_WEAK);
+  WK_KLASS(FinalReference_klass)->set_reference_type(REF_FINAL);
+  WK_KLASS(PhantomReference_klass)->set_reference_type(REF_PHANTOM);
 
   // JSR 292 classes
   WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
--- a/src/hotspot/share/classfile/verificationType.cpp	Wed Oct 23 17:35:32 2019 +0200
+++ b/src/hotspot/share/classfile/verificationType.cpp	Wed Oct 23 18:34:25 2019 +0200
@@ -71,7 +71,7 @@
     if (log_is_enabled(Debug, class, resolve)) {
       Verifier::trace_class_resolution(from_class, klass);
     }
-    return InstanceKlass::cast(from_class)->is_subclass_of(this_class);
+    return from_class->is_subclass_of(this_class);
   }
 
   return false;
--- a/src/hotspot/share/jvmci/jvmciRuntime.cpp	Wed Oct 23 17:35:32 2019 +0200
+++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp	Wed Oct 23 18:34:25 2019 +0200
@@ -1271,7 +1271,7 @@
   if (method_holder->is_instance_klass()) {
     return InstanceKlass::cast(method_holder);
   } else if (method_holder->is_array_klass()) {
-    return InstanceKlass::cast(SystemDictionary::Object_klass());
+    return SystemDictionary::Object_klass();
   } else {
     ShouldNotReachHere();
   }
--- a/src/hotspot/share/prims/jniCheck.cpp	Wed Oct 23 17:35:32 2019 +0200
+++ b/src/hotspot/share/prims/jniCheck.cpp	Wed Oct 23 18:34:25 2019 +0200
@@ -266,7 +266,7 @@
   /* check for proper subclass hierarchy */
   JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fid);
   Klass* f_oop = id->holder();
-  if (!InstanceKlass::cast(k_oop)->is_subtype_of(f_oop))
+  if (!k_oop->is_subtype_of(f_oop))
     ReportJNIFatalError(thr, fatal_wrong_static_field);
 
   /* check for proper field type */
@@ -513,7 +513,7 @@
   assert(klass != NULL, "klass argument must have a value");
 
   if (!klass->is_instance_klass() ||
-      !InstanceKlass::cast(klass)->is_subclass_of(SystemDictionary::Throwable_klass())) {
+      !klass->is_subclass_of(SystemDictionary::Throwable_klass())) {
     ReportJNIFatalError(thr, fatal_class_not_a_throwable_class);
   }
 }