JDK-8150543 : Mismatched access detection is inaccurate
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-02-24
  • Updated: 2020-09-01
  • Resolved: 2016-02-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b110Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Mismatched access detection is too coarse, e.g. Unsafe.getBoolean() from boolean[] instance is considered mismatched. 

http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/file/tip/src/share/vm/opto/library_call.cpp#l2532:
bool mismatched = false;
  if (alias_type->element() != NULL || alias_type->field() != NULL) {
    BasicType bt;
    if (alias_type->element() != NULL) {
      const Type* element = alias_type->element();
      bt = element->isa_narrowoop() ? T_OBJECT : element->array_element_basic_type();
    } else {
      bt = alias_type->field()->type()->basic_type();
    }
    if (bt == T_ARRAY) {
      // accessing an array field with getObject is not a mismatch
      bt = T_OBJECT;
    }
    if (bt != type) {
      mismatched = true;
    }
  }

$ p alias_type->_adr_type
byte[int:>=0]:exact+any *

$ adr_type->dump()
stable:bool[int:2]<ciTypeArray length=2 type=<ciTypeArrayKlass name=[Z ident=1036 address=0x0000000105037750> ident=1051 SCAVENGABLE address=0x00000001009dd030>[0] *