author | hseigel |
Tue, 22 Jul 2014 16:16:51 +0400 | |
changeset 27022 | 2db6fe33afc2 |
parent 13728 | 882756847a04 |
child 30616 | fde3a4fee412 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
27022 | 2 |
* Copyright (c) 2003, 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:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
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:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/symbolTable.hpp" |
|
27 |
#include "classfile/verificationType.hpp" |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
28 |
#include "classfile/verifier.hpp" |
1 | 29 |
|
30 |
VerificationType VerificationType::from_tag(u1 tag) { |
|
31 |
switch (tag) { |
|
32 |
case ITEM_Top: return bogus_type(); |
|
33 |
case ITEM_Integer: return integer_type(); |
|
34 |
case ITEM_Float: return float_type(); |
|
35 |
case ITEM_Double: return double_type(); |
|
36 |
case ITEM_Long: return long_type(); |
|
37 |
case ITEM_Null: return null_type(); |
|
38 |
default: |
|
39 |
ShouldNotReachHere(); |
|
40 |
return bogus_type(); |
|
41 |
} |
|
42 |
} |
|
43 |
||
44 |
bool VerificationType::is_reference_assignable_from( |
|
27022 | 45 |
const VerificationType& from, ClassVerifier* context, |
46 |
bool from_field_is_protected, TRAPS) const { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
47 |
instanceKlassHandle klass = context->current_class(); |
1 | 48 |
if (from.is_null()) { |
49 |
// null is assignable to any reference |
|
50 |
return true; |
|
51 |
} else if (is_null()) { |
|
52 |
return false; |
|
53 |
} else if (name() == from.name()) { |
|
54 |
return true; |
|
55 |
} else if (is_object()) { |
|
56 |
// We need check the class hierarchy to check assignability |
|
57 |
if (name() == vmSymbols::java_lang_Object()) { |
|
58 |
// any object or array is assignable to java.lang.Object |
|
59 |
return true; |
|
60 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13476
diff
changeset
|
61 |
Klass* obj = SystemDictionary::resolve_or_fail( |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
62 |
name(), Handle(THREAD, klass->class_loader()), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
63 |
Handle(THREAD, klass->protection_domain()), true, CHECK_false); |
6473 | 64 |
KlassHandle this_class(THREAD, obj); |
65 |
||
27022 | 66 |
if (this_class->is_interface() && (!from_field_is_protected || |
67 |
from.name() != vmSymbols::java_lang_Object())) { |
|
68 |
// If we are not trying to access a protected field or method in |
|
69 |
// java.lang.Object then we treat interfaces as java.lang.Object, |
|
70 |
// including java.lang.Cloneable and java.io.Serializable. |
|
1 | 71 |
return true; |
72 |
} else if (from.is_object()) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13476
diff
changeset
|
73 |
Klass* from_class = SystemDictionary::resolve_or_fail( |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
74 |
from.name(), Handle(THREAD, klass->class_loader()), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
75 |
Handle(THREAD, klass->protection_domain()), true, CHECK_false); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13476
diff
changeset
|
76 |
return InstanceKlass::cast(from_class)->is_subclass_of(this_class()); |
1 | 77 |
} |
78 |
} else if (is_array() && from.is_array()) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
79 |
VerificationType comp_this = get_component(context, CHECK_false); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
80 |
VerificationType comp_from = from.get_component(context, CHECK_false); |
6172 | 81 |
if (!comp_this.is_bogus() && !comp_from.is_bogus()) { |
27022 | 82 |
return comp_this.is_assignable_from(comp_from, context, |
83 |
from_field_is_protected, CHECK_false); |
|
6172 | 84 |
} |
1 | 85 |
} |
86 |
return false; |
|
87 |
} |
|
88 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
89 |
VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS) const { |
1 | 90 |
assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array"); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
91 |
Symbol* component; |
1 | 92 |
switch (name()->byte_at(1)) { |
93 |
case 'Z': return VerificationType(Boolean); |
|
94 |
case 'B': return VerificationType(Byte); |
|
95 |
case 'C': return VerificationType(Char); |
|
96 |
case 'S': return VerificationType(Short); |
|
97 |
case 'I': return VerificationType(Integer); |
|
98 |
case 'J': return VerificationType(Long); |
|
99 |
case 'F': return VerificationType(Float); |
|
100 |
case 'D': return VerificationType(Double); |
|
101 |
case '[': |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
102 |
component = context->create_temporary_symbol( |
1 | 103 |
name(), 1, name()->utf8_length(), |
104 |
CHECK_(VerificationType::bogus_type())); |
|
105 |
return VerificationType::reference_type(component); |
|
106 |
case 'L': |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
107 |
component = context->create_temporary_symbol( |
1 | 108 |
name(), 2, name()->utf8_length() - 1, |
109 |
CHECK_(VerificationType::bogus_type())); |
|
110 |
return VerificationType::reference_type(component); |
|
111 |
default: |
|
6172 | 112 |
// Met an invalid type signature, e.g. [X |
1 | 113 |
return VerificationType::bogus_type(); |
114 |
} |
|
115 |
} |
|
116 |
||
117 |
void VerificationType::print_on(outputStream* st) const { |
|
118 |
switch (_u._data) { |
|
13476 | 119 |
case Bogus: st->print("top"); break; |
120 |
case Category1: st->print("category1"); break; |
|
121 |
case Category2: st->print("category2"); break; |
|
122 |
case Category2_2nd: st->print("category2_2nd"); break; |
|
123 |
case Boolean: st->print("boolean"); break; |
|
124 |
case Byte: st->print("byte"); break; |
|
125 |
case Short: st->print("short"); break; |
|
126 |
case Char: st->print("char"); break; |
|
127 |
case Integer: st->print("integer"); break; |
|
128 |
case Float: st->print("float"); break; |
|
129 |
case Long: st->print("long"); break; |
|
130 |
case Double: st->print("double"); break; |
|
131 |
case Long_2nd: st->print("long_2nd"); break; |
|
132 |
case Double_2nd: st->print("double_2nd"); break; |
|
133 |
case Null: st->print("null"); break; |
|
134 |
case ReferenceQuery: st->print("reference type"); break; |
|
135 |
case Category1Query: st->print("category1 type"); break; |
|
136 |
case Category2Query: st->print("category2 type"); break; |
|
137 |
case Category2_2ndQuery: st->print("category2_2nd type"); break; |
|
1 | 138 |
default: |
139 |
if (is_uninitialized_this()) { |
|
13476 | 140 |
st->print("uninitializedThis"); |
1 | 141 |
} else if (is_uninitialized()) { |
13476 | 142 |
st->print("uninitialized %d", bci()); |
1 | 143 |
} else { |
13476 | 144 |
name()->print_value_on(st); |
1 | 145 |
} |
146 |
} |
|
147 |
} |