Mon, 06 Aug 2012 15:54:45 -0400
7116786: RFE: Detailed information on VerifyErrors
Summary: Provide additional detail in VerifyError messages
Reviewed-by: sspitsyn, acorn
duke@435 | 1 | /* |
trims@2708 | 2 | * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP |
stefank@2314 | 26 | #define SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "classfile/dictionary.hpp" |
stefank@2314 | 29 | #include "classfile/placeholders.hpp" |
stefank@2314 | 30 | #include "utilities/hashtable.hpp" |
stefank@2314 | 31 | |
duke@435 | 32 | class LoaderConstraintEntry; |
duke@435 | 33 | |
zgu@3900 | 34 | class LoaderConstraintTable : public Hashtable<klassOop, mtClass> { |
duke@435 | 35 | friend class VMStructs; |
duke@435 | 36 | private: |
duke@435 | 37 | |
duke@435 | 38 | enum Constants { |
duke@435 | 39 | _loader_constraint_size = 107, // number of entries in constraint table |
duke@435 | 40 | _nof_buckets = 1009 // number of buckets in hash table |
duke@435 | 41 | }; |
duke@435 | 42 | |
coleenp@2497 | 43 | LoaderConstraintEntry** find_loader_constraint(Symbol* name, |
duke@435 | 44 | Handle loader); |
duke@435 | 45 | |
duke@435 | 46 | public: |
duke@435 | 47 | |
duke@435 | 48 | LoaderConstraintTable(int nof_buckets); |
duke@435 | 49 | |
coleenp@2497 | 50 | LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name, |
duke@435 | 51 | klassOop klass, int num_loaders, |
duke@435 | 52 | int max_loaders); |
coleenp@2497 | 53 | void free_entry(LoaderConstraintEntry *entry); |
duke@435 | 54 | |
duke@435 | 55 | LoaderConstraintEntry* bucket(int i) { |
zgu@3900 | 56 | return (LoaderConstraintEntry*)Hashtable<klassOop, mtClass>::bucket(i); |
duke@435 | 57 | } |
duke@435 | 58 | |
duke@435 | 59 | LoaderConstraintEntry** bucket_addr(int i) { |
zgu@3900 | 60 | return (LoaderConstraintEntry**)Hashtable<klassOop, mtClass>::bucket_addr(i); |
duke@435 | 61 | } |
duke@435 | 62 | |
duke@435 | 63 | // GC support |
duke@435 | 64 | void oops_do(OopClosure* f); |
duke@435 | 65 | |
duke@435 | 66 | // Check class loader constraints |
coleenp@2497 | 67 | bool add_entry(Symbol* name, klassOop klass1, Handle loader1, |
duke@435 | 68 | klassOop klass2, Handle loader2); |
duke@435 | 69 | |
jrose@1100 | 70 | // Note: The main entry point for this module is via SystemDictionary. |
coleenp@2497 | 71 | // SystemDictionary::check_signature_loaders(Symbol* signature, |
jrose@1100 | 72 | // Handle loader1, Handle loader2, |
jrose@1100 | 73 | // bool is_method, TRAPS) |
duke@435 | 74 | |
coleenp@2497 | 75 | klassOop find_constrained_klass(Symbol* name, Handle loader); |
duke@435 | 76 | |
duke@435 | 77 | // Class loader constraints |
duke@435 | 78 | |
duke@435 | 79 | void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree); |
duke@435 | 80 | void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader, |
duke@435 | 81 | klassOop klass); |
duke@435 | 82 | void merge_loader_constraints(LoaderConstraintEntry** pp1, |
duke@435 | 83 | LoaderConstraintEntry** pp2, klassOop klass); |
duke@435 | 84 | |
duke@435 | 85 | bool check_or_update(instanceKlassHandle k, Handle loader, |
coleenp@2497 | 86 | Symbol* name); |
duke@435 | 87 | |
duke@435 | 88 | |
duke@435 | 89 | void purge_loader_constraints(BoolObjectClosure* is_alive); |
duke@435 | 90 | |
tonyp@1693 | 91 | void verify(Dictionary* dictionary, PlaceholderTable* placeholders); |
duke@435 | 92 | #ifndef PRODUCT |
duke@435 | 93 | void print(); |
duke@435 | 94 | #endif |
duke@435 | 95 | }; |
duke@435 | 96 | |
zgu@3900 | 97 | class LoaderConstraintEntry : public HashtableEntry<klassOop, mtClass> { |
duke@435 | 98 | friend class VMStructs; |
duke@435 | 99 | private: |
coleenp@2497 | 100 | Symbol* _name; // class name |
duke@435 | 101 | int _num_loaders; |
duke@435 | 102 | int _max_loaders; |
duke@435 | 103 | oop* _loaders; // initiating loaders |
duke@435 | 104 | |
duke@435 | 105 | public: |
duke@435 | 106 | |
coleenp@2497 | 107 | klassOop klass() { return literal(); } |
coleenp@2497 | 108 | klassOop* klass_addr() { return literal_addr(); } |
duke@435 | 109 | void set_klass(klassOop k) { set_literal(k); } |
duke@435 | 110 | |
duke@435 | 111 | LoaderConstraintEntry* next() { |
zgu@3900 | 112 | return (LoaderConstraintEntry*)HashtableEntry<klassOop, mtClass>::next(); |
duke@435 | 113 | } |
duke@435 | 114 | |
duke@435 | 115 | LoaderConstraintEntry** next_addr() { |
zgu@3900 | 116 | return (LoaderConstraintEntry**)HashtableEntry<klassOop, mtClass>::next_addr(); |
duke@435 | 117 | } |
duke@435 | 118 | void set_next(LoaderConstraintEntry* next) { |
zgu@3900 | 119 | HashtableEntry<klassOop, mtClass>::set_next(next); |
duke@435 | 120 | } |
duke@435 | 121 | |
coleenp@2497 | 122 | Symbol* name() { return _name; } |
coleenp@2497 | 123 | void set_name(Symbol* name) { |
coleenp@2497 | 124 | _name = name; |
coleenp@2497 | 125 | if (name != NULL) name->increment_refcount(); |
coleenp@2497 | 126 | } |
duke@435 | 127 | |
duke@435 | 128 | int num_loaders() { return _num_loaders; } |
duke@435 | 129 | void set_num_loaders(int i) { _num_loaders = i; } |
duke@435 | 130 | |
duke@435 | 131 | int max_loaders() { return _max_loaders; } |
duke@435 | 132 | void set_max_loaders(int i) { _max_loaders = i; } |
duke@435 | 133 | |
duke@435 | 134 | oop* loaders() { return _loaders; } |
duke@435 | 135 | void set_loaders(oop* loaders) { _loaders = loaders; } |
duke@435 | 136 | |
duke@435 | 137 | oop loader(int i) { return _loaders[i]; } |
duke@435 | 138 | oop* loader_addr(int i) { return &_loaders[i]; } |
duke@435 | 139 | void set_loader(int i, oop p) { _loaders[i] = p; } |
duke@435 | 140 | |
duke@435 | 141 | }; |
stefank@2314 | 142 | |
stefank@2314 | 143 | #endif // SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP |