Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/reflection.cpp @ 13430:9a60f4ac6a37
8027458: VM anonymous classes: wrong context for protected access checks
Summary: Use the anonymous class's host class for protected access checks
Reviewed-by: acorn, coleenp, lfoltan
author | hseigel |
---|---|
date | Wed, 04 Dec 2013 08:10:31 -0500 |
parents | cdf20166ec45 |
children | 63a4eb8bcd23 2373a1f4987c |
comparison
equal
deleted
inserted
replaced
13416:e84d2afb2fb0 | 13430:9a60f4ac6a37 |
---|---|
535 (current_class == field_class) || | 535 (current_class == field_class) || |
536 access.is_public()) { | 536 access.is_public()) { |
537 return true; | 537 return true; |
538 } | 538 } |
539 | 539 |
540 Klass* host_class = current_class; | |
541 while (host_class->oop_is_instance() && | |
542 InstanceKlass::cast(host_class)->is_anonymous()) { | |
543 Klass* next_host_class = InstanceKlass::cast(host_class)->host_klass(); | |
544 if (next_host_class == NULL) break; | |
545 host_class = next_host_class; | |
546 } | |
547 if (host_class == field_class) { | |
548 return true; | |
549 } | |
550 | |
540 if (access.is_protected()) { | 551 if (access.is_protected()) { |
541 if (!protected_restriction) { | 552 if (!protected_restriction) { |
542 // See if current_class is a subclass of field_class | 553 // See if current_class (or outermost host class) is a subclass of field_class |
543 if (current_class->is_subclass_of(field_class)) { | 554 if (host_class->is_subclass_of(field_class)) { |
544 if (access.is_static() || // static fields are ok, see 6622385 | 555 if (access.is_static() || // static fields are ok, see 6622385 |
545 current_class == resolved_class || | 556 current_class == resolved_class || |
546 field_class == resolved_class || | 557 field_class == resolved_class || |
547 current_class->is_subclass_of(resolved_class) || | 558 host_class->is_subclass_of(resolved_class) || |
548 resolved_class->is_subclass_of(current_class)) { | 559 resolved_class->is_subclass_of(host_class)) { |
549 return true; | 560 return true; |
550 } | 561 } |
551 } | 562 } |
552 } | 563 } |
553 } | 564 } |