Mercurial > hg > truffle
comparison src/share/vm/ci/ciField.cpp @ 18036:00cf2b6f51b9 hs25.20-b23
8050978: Fix bad field access check in C1 and C2
Summary: JCK8 test vm/constantpool/accessControl/accessControl004/accessControl00402m3/accessControl00402m3.html fails with -Xbatch -Xcomp due to bad field access check in C1 and C2. Fix: In ciField::ciField(), just before the canonical holder is stored into the _holder variable (and which is used by ciField::will_link()) perform an additional access check with the holder declared in the class file. If this check fails, store the declared holder instead and ciField::will_link() will bail out compilation for this field later on. Then, the interpreter will throw an PrivilegedAccessException at runtime.
Reviewed-by: kvn, vlivanov
Contributed-by: andreas.schoesser@sap.com
author | goetz |
---|---|
date | Fri, 18 Jul 2014 09:04:01 +0200 |
parents | b2e698d2276c |
children | 52b4284cb496 |
comparison
equal
deleted
inserted
replaced
18035:90b2ae0b131d | 18036:00cf2b6f51b9 |
---|---|
136 _offset = -1; | 136 _offset = -1; |
137 _is_constant = false; | 137 _is_constant = false; |
138 return; | 138 return; |
139 } | 139 } |
140 | 140 |
141 // Access check based on declared_holder. canonical_holder should not be used | |
142 // to check access because it can erroneously succeed. If this check fails, | |
143 // propagate the declared holder to will_link() which in turn will bail out | |
144 // compilation for this field access. | |
145 if (!Reflection::verify_field_access(klass->get_Klass(), declared_holder->get_Klass(), canonical_holder, field_desc.access_flags(), true)) { | |
146 _holder = declared_holder; | |
147 _offset = -1; | |
148 _is_constant = false; | |
149 return; | |
150 } | |
151 | |
141 assert(canonical_holder == field_desc.field_holder(), "just checking"); | 152 assert(canonical_holder == field_desc.field_holder(), "just checking"); |
142 initialize_from(&field_desc); | 153 initialize_from(&field_desc); |
143 } | 154 } |
144 | 155 |
145 ciField::ciField(fieldDescriptor *fd): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) { | 156 ciField::ciField(fieldDescriptor *fd): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) { |