1 /* |
1 /* |
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 1999-2009 Sun Microsystems, Inc. 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. |
84 // field. |
84 // field. |
85 if (field_type == T_OBJECT || field_type == T_ARRAY) { |
85 if (field_type == T_OBJECT || field_type == T_ARRAY) { |
86 bool ignore; |
86 bool ignore; |
87 // This is not really a class reference; the index always refers to the |
87 // This is not really a class reference; the index always refers to the |
88 // field's type signature, as a symbol. Linkage checks do not apply. |
88 // field's type signature, as a symbol. Linkage checks do not apply. |
89 _type = ciEnv::current(thread)->get_klass_by_index(klass, sig_index, ignore); |
89 _type = ciEnv::current(thread)->get_klass_by_index(cpool, sig_index, ignore, klass); |
90 } else { |
90 } else { |
91 _type = ciType::make(field_type); |
91 _type = ciType::make(field_type); |
92 } |
92 } |
93 |
93 |
94 _name = (ciSymbol*)ciEnv::current(thread)->get_object(name()); |
94 _name = (ciSymbol*)ciEnv::current(thread)->get_object(name()); |
98 // Note: we actually create a ciInstanceKlass for this klass, |
98 // Note: we actually create a ciInstanceKlass for this klass, |
99 // even though we may not need to. |
99 // even though we may not need to. |
100 int holder_index = cpool->klass_ref_index_at(index); |
100 int holder_index = cpool->klass_ref_index_at(index); |
101 bool holder_is_accessible; |
101 bool holder_is_accessible; |
102 ciInstanceKlass* declared_holder = |
102 ciInstanceKlass* declared_holder = |
103 ciEnv::current(thread)->get_klass_by_index(klass, holder_index, |
103 ciEnv::current(thread)->get_klass_by_index(cpool, holder_index, |
104 holder_is_accessible) |
104 holder_is_accessible, |
105 ->as_instance_klass(); |
105 klass)->as_instance_klass(); |
106 |
106 |
107 // The declared holder of this field may not have been loaded. |
107 // The declared holder of this field may not have been loaded. |
108 // Bail out with partial field information. |
108 // Bail out with partial field information. |
109 if (!holder_is_accessible) { |
109 if (!holder_is_accessible) { |
110 // _cp_index and _type have already been set. |
110 // _cp_index and _type have already been set. |
166 _flags = ciFlags(fd->access_flags()); |
166 _flags = ciFlags(fd->access_flags()); |
167 _offset = fd->offset(); |
167 _offset = fd->offset(); |
168 _holder = CURRENT_ENV->get_object(fd->field_holder())->as_instance_klass(); |
168 _holder = CURRENT_ENV->get_object(fd->field_holder())->as_instance_klass(); |
169 |
169 |
170 // Check to see if the field is constant. |
170 // Check to see if the field is constant. |
171 if (_holder->is_initialized() && |
171 if (_holder->is_initialized() && this->is_final()) { |
172 this->is_final() && this->is_static()) { |
172 if (!this->is_static()) { |
|
173 // A field can be constant if it's a final static field or if it's |
|
174 // a final non-static field of a trusted class ({java,sun}.dyn). |
|
175 if (_holder->is_in_package("java/dyn") || _holder->is_in_package("sun/dyn")) { |
|
176 _is_constant = true; |
|
177 return; |
|
178 } |
|
179 _is_constant = false; |
|
180 return; |
|
181 } |
|
182 |
173 // This field just may be constant. The only cases where it will |
183 // This field just may be constant. The only cases where it will |
174 // not be constant are: |
184 // not be constant are: |
175 // |
185 // |
176 // 1. The field holds a non-perm-space oop. The field is, strictly |
186 // 1. The field holds a non-perm-space oop. The field is, strictly |
177 // speaking, constant but we cannot embed non-perm-space oops into |
187 // speaking, constant but we cannot embed non-perm-space oops into |