1 /* |
1 /* |
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
30 #include "runtime/safepoint.hpp" |
30 #include "runtime/safepoint.hpp" |
31 #include "utilities/hashtable.inline.hpp" |
31 #include "utilities/hashtable.inline.hpp" |
32 |
32 |
33 // add new entry to the table |
33 // add new entry to the table |
34 void ResolutionErrorTable::add_entry(int index, unsigned int hash, |
34 void ResolutionErrorTable::add_entry(int index, unsigned int hash, |
35 constantPoolHandle pool, int cp_index, Symbol* error) |
35 constantPoolHandle pool, int cp_index, |
|
36 Symbol* error, Symbol* message) |
36 { |
37 { |
37 assert_locked_or_safepoint(SystemDictionary_lock); |
38 assert_locked_or_safepoint(SystemDictionary_lock); |
38 assert(!pool.is_null() && error != NULL, "adding NULL obj"); |
39 assert(!pool.is_null() && error != NULL, "adding NULL obj"); |
39 |
40 |
40 ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error); |
41 ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error, message); |
41 add_entry(index, entry); |
42 add_entry(index, entry); |
42 } |
43 } |
43 |
44 |
44 // find entry in the table |
45 // find entry in the table |
45 ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash, |
46 ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash, |
56 } |
57 } |
57 return NULL; |
58 return NULL; |
58 } |
59 } |
59 |
60 |
60 void ResolutionErrorEntry::set_error(Symbol* e) { |
61 void ResolutionErrorEntry::set_error(Symbol* e) { |
61 assert(e == NULL || _error == NULL, "cannot reset error"); |
62 assert(e != NULL, "must set a value"); |
62 _error = e; |
63 _error = e; |
63 if (_error != NULL) _error->increment_refcount(); |
64 _error->increment_refcount(); |
|
65 } |
|
66 |
|
67 void ResolutionErrorEntry::set_message(Symbol* c) { |
|
68 assert(c != NULL, "must set a value"); |
|
69 _message = c; |
|
70 _message->increment_refcount(); |
64 } |
71 } |
65 |
72 |
66 // create new error entry |
73 // create new error entry |
67 ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool, |
74 ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool, |
68 int cp_index, Symbol* error) |
75 int cp_index, Symbol* error, |
|
76 Symbol* message) |
69 { |
77 { |
70 ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool); |
78 ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool); |
71 entry->set_cp_index(cp_index); |
79 entry->set_cp_index(cp_index); |
72 NOT_PRODUCT(entry->set_error(NULL);) |
|
73 entry->set_error(error); |
80 entry->set_error(error); |
|
81 entry->set_message(message); |
74 |
82 |
75 return entry; |
83 return entry; |
76 } |
84 } |
77 |
85 |
78 void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) { |
86 void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) { |
79 // decrement error refcount |
87 // decrement error refcount |
80 assert(entry->error() != NULL, "error should be set"); |
88 assert(entry->error() != NULL, "error should be set"); |
81 entry->error()->decrement_refcount(); |
89 entry->error()->decrement_refcount(); |
|
90 entry->message()->decrement_refcount(); |
82 Hashtable<ConstantPool*, mtClass>::free_entry(entry); |
91 Hashtable<ConstantPool*, mtClass>::free_entry(entry); |
83 } |
92 } |
84 |
93 |
85 |
94 |
86 // create resolution error table |
95 // create resolution error table |