< prev index next >
src/hotspot/share/oops/constantPool.cpp
Print this page
@@ -437,10 +437,18 @@
k->external_name());
}
}
}
+void check_value_types_consistency(const constantPoolHandle& this_cp, Klass* resolved_klass, TRAPS) {
+ bool opinion0 = resolved_klass->is_value();
+ bool opinion1 = this_cp->pool_holder()->is_declared_value_type(resolved_klass->name());
+ if (opinion0 != opinion1) {
+ THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
+ }
+}
+
Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which,
bool save_resolution_error, TRAPS) {
assert(THREAD->is_Java_thread(), "must be a Java thread");
// A resolved constantPool entry will contain a Klass*, otherwise a Symbol*.
@@ -480,10 +488,14 @@
mirror_handle = Handle(THREAD, k->java_mirror());
// Do access check for klasses
verify_constant_pool_resolve(this_cp, k, THREAD);
}
+ if (!HAS_PENDING_EXCEPTION) {
+ check_value_types_consistency(this_cp, k, THREAD);
+ }
+
// 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) {
if (save_resolution_error) {
save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_NULL);
< prev index next >