8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
Summary: Remove search in system dictionary and hacks, replace with verifying in CLD::_klasses list.
Reviewed-by: dcubed, acorn
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -520,6 +520,13 @@
}
}
+bool ClassLoaderData::contains_klass(Klass* klass) {
+ for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
+ if (k == klass) return true;
+ }
+ return false;
+}
+
// GC root of class loader data created.
ClassLoaderData* ClassLoaderDataGraph::_head = NULL;
--- a/hotspot/src/share/vm/classfile/classLoaderData.hpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -260,6 +260,7 @@
jobject add_handle(Handle h);
void add_class(Klass* k);
void remove_class(Klass* k);
+ bool contains_klass(Klass* k);
void record_dependency(Klass* to, TRAPS);
void init_dependencies(TRAPS);
--- a/hotspot/src/share/vm/classfile/dictionary.cpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/classfile/dictionary.cpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -707,7 +707,7 @@
loader_data->class_loader() == NULL ||
loader_data->class_loader()->is_instance(),
"checking type of class_loader");
- e->verify(/*check_dictionary*/false);
+ e->verify();
probe->verify_protection_domain_set();
element_count++;
}
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2650,23 +2650,6 @@
constraints()->verify(dictionary(), placeholders());
}
-
-void SystemDictionary::verify_obj_klass_present(Symbol* class_name,
- ClassLoaderData* loader_data) {
- GCMutexLocker mu(SystemDictionary_lock);
- Symbol* name;
-
- Klass* probe = find_class(class_name, loader_data);
- if (probe == NULL) {
- probe = SystemDictionary::find_shared_class(class_name);
- if (probe == NULL) {
- name = find_placeholder(class_name, loader_data);
- }
- }
- guarantee(probe != NULL || name != NULL,
- "Loaded klasses should be in SystemDictionary");
-}
-
// utility function for class load event
void SystemDictionary::post_class_load_event(const Ticks& start_time,
instanceKlassHandle k,
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -375,10 +375,6 @@
static bool is_internal_format(Symbol* class_name);
#endif
- // Verify class is in dictionary
- static void verify_obj_klass_present(Symbol* class_name,
- ClassLoaderData* loader_data);
-
// Initialization
static void initialize(TRAPS);
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/oops/arrayKlass.cpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -214,8 +214,8 @@
// Verification
-void ArrayKlass::verify_on(outputStream* st, bool check_dictionary) {
- Klass::verify_on(st, check_dictionary);
+void ArrayKlass::verify_on(outputStream* st) {
+ Klass::verify_on(st);
if (component_mirror() != NULL) {
guarantee(component_mirror()->klass() != NULL, "should have a class");
--- a/hotspot/src/share/vm/oops/arrayKlass.hpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/oops/arrayKlass.hpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -146,7 +146,7 @@
void oop_print_on(oop obj, outputStream* st);
// Verification
- void verify_on(outputStream* st, bool check_dictionary);
+ void verify_on(outputStream* st);
void oop_verify_on(oop obj, outputStream* st);
};
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -3180,7 +3180,7 @@
virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); }
};
-void InstanceKlass::verify_on(outputStream* st, bool check_dictionary) {
+void InstanceKlass::verify_on(outputStream* st) {
#ifndef PRODUCT
// Avoid redundant verifies, this really should be in product.
if (_verify_count == Universe::verify_count()) return;
@@ -3188,14 +3188,11 @@
#endif
// Verify Klass
- Klass::verify_on(st, check_dictionary);
-
- // Verify that klass is present in SystemDictionary if not already
- // verifying the SystemDictionary.
- if (is_loaded() && !is_anonymous() && check_dictionary) {
- Symbol* h_name = name();
- SystemDictionary::verify_obj_klass_present(h_name, class_loader_data());
- }
+ Klass::verify_on(st);
+
+ // Verify that klass is present in ClassLoaderData
+ guarantee(class_loader_data()->contains_klass(this),
+ "this class isn't found in class loader data");
// Verify vtables
if (is_linked()) {
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Sat Feb 15 13:03:38 2014 -0500
@@ -1087,7 +1087,7 @@
const char* internal_name() const;
// Verification
- void verify_on(outputStream* st, bool check_dictionary);
+ void verify_on(outputStream* st);
void oop_verify_on(oop obj, outputStream* st);
};
--- a/hotspot/src/share/vm/oops/klass.cpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/oops/klass.cpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -638,7 +638,7 @@
// Verification
-void Klass::verify_on(outputStream* st, bool check_dictionary) {
+void Klass::verify_on(outputStream* st) {
// This can be expensive, but it is worth checking that this klass is actually
// in the CLD graph but not in production.
--- a/hotspot/src/share/vm/oops/klass.hpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/oops/klass.hpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -695,8 +695,8 @@
virtual const char* internal_name() const = 0;
// Verification
- virtual void verify_on(outputStream* st, bool check_dictionary);
- void verify(bool check_dictionary = true) { verify_on(tty, check_dictionary); }
+ virtual void verify_on(outputStream* st);
+ void verify() { verify_on(tty); }
#ifndef PRODUCT
bool verify_vtable_index(int index);
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -674,8 +674,8 @@
// Verification
-void ObjArrayKlass::verify_on(outputStream* st, bool check_dictionary) {
- ArrayKlass::verify_on(st, check_dictionary);
+void ObjArrayKlass::verify_on(outputStream* st) {
+ ArrayKlass::verify_on(st);
guarantee(element_klass()->is_klass(), "should be klass");
guarantee(bottom_klass()->is_klass(), "should be klass");
Klass* bk = bottom_klass();
--- a/hotspot/src/share/vm/oops/objArrayKlass.hpp Fri Feb 14 16:17:22 2014 +0100
+++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp Sat Feb 15 13:03:38 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -151,7 +151,7 @@
const char* internal_name() const;
// Verification
- void verify_on(outputStream* st, bool check_dictionary);
+ void verify_on(outputStream* st);
void oop_verify_on(oop obj, outputStream* st);
};