author | coleenp |
Fri, 26 Sep 2014 12:50:30 -0400 | |
changeset 26927 | b9bd979b7d75 |
parent 24334 | 36096f7271f4 |
child 33593 | 60764a78fa5c |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
2 |
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/resolutionErrors.hpp" |
|
27 |
#include "memory/resourceArea.hpp" |
|
28 |
#include "oops/oop.inline.hpp" |
|
29 |
#include "runtime/handles.inline.hpp" |
|
30 |
#include "runtime/safepoint.hpp" |
|
31 |
#include "utilities/hashtable.inline.hpp" |
|
1 | 32 |
|
33 |
// add new entry to the table |
|
34 |
void ResolutionErrorTable::add_entry(int index, unsigned int hash, |
|
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
35 |
constantPoolHandle pool, int cp_index, |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
36 |
Symbol* error, Symbol* message) |
1 | 37 |
{ |
38 |
assert_locked_or_safepoint(SystemDictionary_lock); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
39 |
assert(!pool.is_null() && error != NULL, "adding NULL obj"); |
1 | 40 |
|
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
41 |
ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error, message); |
1 | 42 |
add_entry(index, entry); |
43 |
} |
|
44 |
||
45 |
// find entry in the table |
|
46 |
ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash, |
|
47 |
constantPoolHandle pool, int cp_index) |
|
48 |
{ |
|
49 |
assert_locked_or_safepoint(SystemDictionary_lock); |
|
50 |
||
51 |
for (ResolutionErrorEntry *error_probe = bucket(index); |
|
52 |
error_probe != NULL; |
|
53 |
error_probe = error_probe->next()) { |
|
54 |
if (error_probe->hash() == hash && error_probe->pool() == pool()) { |
|
55 |
return error_probe;; |
|
56 |
} |
|
57 |
} |
|
58 |
return NULL; |
|
59 |
} |
|
60 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
61 |
void ResolutionErrorEntry::set_error(Symbol* e) { |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
62 |
assert(e != NULL, "must set a value"); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
63 |
_error = e; |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
64 |
_error->increment_refcount(); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
65 |
} |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
66 |
|
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
67 |
void ResolutionErrorEntry::set_message(Symbol* c) { |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
68 |
assert(c != NULL, "must set a value"); |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
69 |
_message = c; |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
70 |
_message->increment_refcount(); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
71 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
72 |
|
1 | 73 |
// create new error entry |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
74 |
ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool, |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
75 |
int cp_index, Symbol* error, |
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
76 |
Symbol* message) |
1 | 77 |
{ |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
78 |
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool); |
1 | 79 |
entry->set_cp_index(cp_index); |
80 |
entry->set_error(error); |
|
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
81 |
entry->set_message(message); |
1 | 82 |
|
83 |
return entry; |
|
84 |
} |
|
85 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
86 |
void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
87 |
// decrement error refcount |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
88 |
assert(entry->error() != NULL, "error should be set"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
89 |
entry->error()->decrement_refcount(); |
24334
36096f7271f4
8023697: failed class resolution reports different class name in detail message for the first and subsequent times
coleenp
parents:
13728
diff
changeset
|
90 |
entry->message()->decrement_refcount(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
91 |
Hashtable<ConstantPool*, mtClass>::free_entry(entry); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
92 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
93 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
94 |
|
1 | 95 |
// create resolution error table |
96 |
ResolutionErrorTable::ResolutionErrorTable(int table_size) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
97 |
: Hashtable<ConstantPool*, mtClass>(table_size, sizeof(ResolutionErrorEntry)) { |
1 | 98 |
} |
99 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
100 |
// RedefineClasses support - remove matching entry of a |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
101 |
// constant pool that is going away |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
102 |
void ResolutionErrorTable::delete_entry(ConstantPool* c) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
103 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
1 | 104 |
for (int i = 0; i < table_size(); i++) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
105 |
for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
106 |
ResolutionErrorEntry* entry = *p; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
107 |
assert(entry->pool() != NULL, "resolution error table is corrupt"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
108 |
if (entry->pool() == c) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
109 |
*p = entry->next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
110 |
free_entry(entry); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
111 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
112 |
p = entry->next_addr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
113 |
} |
1 | 114 |
} |
115 |
} |
|
116 |
} |
|
117 |
||
118 |
||
119 |
// Remove unloaded entries from the table |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
120 |
void ResolutionErrorTable::purge_resolution_errors() { |
5402
c51fd0c1d005
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
1
diff
changeset
|
121 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
1 | 122 |
for (int i = 0; i < table_size(); i++) { |
123 |
for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) { |
|
124 |
ResolutionErrorEntry* entry = *p; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
125 |
assert(entry->pool() != (ConstantPool*)NULL, "resolution error table is corrupt"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
126 |
ConstantPool* pool = entry->pool(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
127 |
assert(pool->pool_holder() != NULL, "Constant pool without a class?"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
128 |
ClassLoaderData* loader_data = |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
129 |
pool->pool_holder()->class_loader_data(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
130 |
if (!loader_data->is_unloading()) { |
1 | 131 |
p = entry->next_addr(); |
132 |
} else { |
|
133 |
*p = entry->next(); |
|
134 |
free_entry(entry); |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
} |