Home | History | Annotate | Download | only in opcodes
      1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      2 
      3 <html>
      4 
      5 <head>
      6 <title>check-cast</title>
      7 <link rel=stylesheet href="opcode.css">
      8 </head>
      9 
     10 <body>
     11 
     12 <h1>check-cast</h1>
     13 
     14 <h2>Purpose</h2>
     15 
     16 <p>
     17 Throw if the reference in the given register cannot be cast to the indicated
     18 type. The type must be a reference type (not a primitive type). 
     19 </p>
     20 
     21 <h2>Details</h2>
     22 
     23 <table class="instruc">
     24 <thead>
     25 <tr>
     26   <th>Op &amp; Format</th>
     27   <th>Mnemonic / Syntax</th>
     28   <th>Arguments</th>
     29 </tr>
     30 </thead>
     31 <tbody>
     32 <tr>
     33   <td>1f 21c</td>
     34   <td>check-cast vAA, type@BBBB</td>
     35   <td><code>A:</code> reference-bearing register (8 bits)<br/>
     36     <code>B:</code> type index (16 bits)</td>
     37 </tr>
     38 </tbody>
     39 </table>
     40 
     41 <h2>Constraints</h2>
     42 
     43 <ul>
     44   <li>
     45     A must be a valid register index in the current stack frame.
     46   </li>
     47   <li>
     48     Register vA must contain a reference value.
     49   </li>
     50   <li>
     51     B must be a valid index into the type pool.
     52   </li>
     53   <li>
     54     Type pool entry B must contain a valid type descriptor for a reference type.
     55   </li>
     56 </ul> 
     57     
     58 <h2>Behavior</h2>
     59 
     60 <ul>
     61   <li>
     62     An attempt is made to get a reference to the class C the name of which is
     63     contained in type pool entry B.
     64   </li>
     65   <li>
     66     If C has not been loaded and resolved before, it is being loaded and
     67     resolved. All exceptions that are possible during class loading can occur at
     68     this point.
     69   </li>
     70   <li>
     71     The run-time type of the object reference vA is compared against C.
     72     <ul>
     73       <li>
     74         If vA is null, the instruction succeeds (without further effects).
     75       </li>
     76       <li>
     77         If vA is assignment compatible with C according to the usual rules of
     78         the Java programming language, the instruction succeeds (without further
     79         effects).
     80       </li>
     81     </ul>
     82   </li>
     83 </ul>
     84 
     85 <h2>Exceptions</h2>
     86 
     87 <ul>
     88   <li>
     89     ClassCastException is thrown if vA is either not null or not assignment
     90     compatible with C.
     91   </li>
     92 </ul>
     93 
     94 </body>
     95 </html>
     96