< prev index next >

src/hotspot/share/oops/constantPool.cpp

Print this page
@@ -50,10 +50,11 @@
  #include "memory/resourceArea.hpp"
  #include "memory/universe.hpp"
  #include "oops/array.hpp"
  #include "oops/constantPool.inline.hpp"
  #include "oops/cpCache.inline.hpp"
+ #include "oops/flatArrayKlass.hpp"
  #include "oops/instanceKlass.hpp"
  #include "oops/klass.inline.hpp"
  #include "oops/objArrayKlass.hpp"
  #include "oops/objArrayOop.inline.hpp"
  #include "oops/oop.inline.hpp"

@@ -258,11 +259,11 @@
        break;
  #ifndef PRODUCT
      case JVM_CONSTANT_Class:
      case JVM_CONSTANT_UnresolvedClass:
      case JVM_CONSTANT_UnresolvedClassInError:
-       // All of these should have been reverted back to ClassIndex before calling
+       // All of these should have been reverted back to Unresolved before calling
        // this function.
        ShouldNotReachHere();
  #endif
      }
    }

@@ -549,10 +550,16 @@
                   k->external_name());
      }
    }
  }
  
+ void check_is_inline_type(Klass* k, TRAPS) {
+   if (!k->is_inline_klass()) {
+     THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
+   }
+ }
+ 
  Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int cp_index,
                                     TRAPS) {
    JavaThread* javaThread = THREAD;
  
    // A resolved constantPool entry will contain a Klass*, otherwise a Symbol*.

@@ -587,27 +594,47 @@
    }
  
    HandleMark hm(THREAD);
    Handle mirror_handle;
    Symbol* name = this_cp->symbol_at(name_index);
+   bool inline_type_signature = false;
    Handle loader (THREAD, this_cp->pool_holder()->class_loader());
    Handle protection_domain (THREAD, this_cp->pool_holder()->protection_domain());
  
    Klass* k;
    {
      // Turn off the single stepping while doing class resolution
      JvmtiHideSingleStepping jhss(javaThread);
      k = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD);
    } //  JvmtiHideSingleStepping jhss(javaThread);
+   if (inline_type_signature) {
+     name->decrement_refcount();
+   }
  
    if (!HAS_PENDING_EXCEPTION) {
      // preserve the resolved klass from unloading
      mirror_handle = Handle(THREAD, k->java_mirror());
      // Do access check for klasses
      verify_constant_pool_resolve(this_cp, k, THREAD);
    }
  
+   if (!HAS_PENDING_EXCEPTION && inline_type_signature) {
+     check_is_inline_type(k, THREAD);
+   }
+ 
+   if (!HAS_PENDING_EXCEPTION) {
+     Klass* bottom_klass = nullptr;
+     if (k->is_objArray_klass()) {
+       bottom_klass = ObjArrayKlass::cast(k)->bottom_klass();
+       assert(bottom_klass != nullptr, "Should be set");
+       assert(bottom_klass->is_instance_klass() || bottom_klass->is_typeArray_klass(), "Sanity check");
+     } else if (k->is_flatArray_klass()) {
+       bottom_klass = FlatArrayKlass::cast(k)->element_klass();
+       assert(bottom_klass != nullptr, "Should be set");
+     }
+   }
+ 
    // Failed to resolve class. We must record the errors so that subsequent attempts
    // to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
    if (HAS_PENDING_EXCEPTION) {
      save_and_throw_exception(this_cp, cp_index, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_NULL);
      // If CHECK_NULL above doesn't return the exception, that means that
< prev index next >