< prev index next >

src/hotspot/share/cds/cdsHeapVerifier.cpp

Print this page
@@ -91,10 +91,22 @@
  //     its value is deterministic and is always the same string literal.
  // [C] A non-final static string that is assigned a string literal during class
  //     initialization; this string is never changed during -Xshare:dump.
  // [D] Simple caches whose value doesn't matter.
  // [E] Other cases (see comments in-line below).
+ //
+ // LIMITATION:
+ //
+ // CDSHeapVerifier can only check for problems with object identity. In the example above,
+ // if the Bar type has identity, the program's correctness requires that the identity
+ // of Foo.bar and Bar.bar to be equal. This requirement can be checked by CDSHeapVerifier.
+ //
+ // However, if Bar does not have identity (e.g., it's a value class, or is a primitive type),
+ // the program's correctness no longer requires that the identity of Foo.bar and Bar.bar
+ // to be equal (since they don't have an identity anymore). While the program's
+ // correctness may still have certain assumptions about Foo.bar and Bar.bar (such as the
+ // internal fields of these two values), such assumptions cannot be checked by CDSHeapVerifier.
  
  CDSHeapVerifier::CDSHeapVerifier() : _archived_objs(0), _problems(0)
  {
  # define ADD_EXCL(...) { static const char* e[] = {__VA_ARGS__, nullptr}; add_exclusion(e); }
  

@@ -291,10 +303,18 @@
              return;
            }
          }
        }
  
+       if (!field_type->is_identity_class()) {
+         // See comment of LIMITATION above
+         // Any concrete value class will have a field ".null_reset" which holds an
+         // all-zero instance of the value class so it will not change between
+         // dump time and runtime.
+         return;
+       }
+ 
        if (fd->is_final() && java_lang_String::is_instance(static_obj_field) && fd->has_initial_value()) {
          // This field looks like like this in the Java source:
          //    static final SOME_STRING = "a string literal";
          // This string literal has been stored in the shared string table, so it's OK
          // for the archived objects to refer to it.
< prev index next >