📄 jcvm07instr.html
字号:
<UL><LI CLASS="Bullet2"><A NAME="pgfId-48412"></A>If T is a class type, then T must be Object.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet2"><A NAME="pgfId-48413"></A>If T is an array type, namely the type TC[], an array of components of type TC, then one of the following must be true:</LI><P CLASS="Linebreak"></P></UL></UL><P CLASS="ParaIndent2"><A NAME="pgfId-48414"></A>TC and SC are the same primitive type (<A HREF="JCVM03structVM.html#91374" CLASS="XRef">Section 3.1, Data Types and Values</A>).</P><P CLASS="ParaIndent2"><A NAME="pgfId-48415"></A>TC and SC are reference types<A NAME="fnote4"></A><A HREF="#pgfId-53447" CLASS="footnote"><SUP>[4]</SUP></A> (<A HREF="JCVM03structVM.html#91374" CLASS="XRef">Section 3.1, Data Types and Values</A>) with type SC assignable to TC, by these rules.</P><UL><UL><LI CLASS="Bullet2"><A NAME="pgfId-53010"></A>If T is an interface type, T must be one of the interfaces implemented by arrays.</LI><P CLASS="Linebreak"></P></UL></UL><P CLASS="Paragraph"><A NAME="pgfId-53014"></A>Runtime Exception</P><P CLASS="Paragraph"><A NAME="pgfId-26511"></A>If objectref cannot be cast to the resolved class, array, or interface type, the checkcast instruction throws a ClassCastException.</P><P CLASS="Paragraph"><A NAME="pgfId-7272"></A>Notes</P><P CLASS="Paragraph"><A NAME="pgfId-7273"></A>The checkcast instruction is fundamentally very similar to the instanceof instruction. It differs in its treatment of null, its behavior when its test fails (checkcast throws an exception, instanceof pushes a result code), and its effect on the operand stack.</P><P CLASS="Paragraph"><A NAME="pgfId-1003337"></A>In some circumstances, the checkcast instruction may throw a SecurityException if the current context (<A HREF="JCVM03structVM.html#33311" CLASS="XRef">Section 3.4, Contexts</A>) is not the owning context (<A HREF="JCVM03structVM.html#33311" CLASS="XRef">Section 3.4, Contexts</A>) of the object referenced by objectref. The exact circumstances when the exception will be thrown are specified in Chapter 6 of the <EM CLASS="Emphasis">Runtime Environment Specification, Java Card Platform, Version 2.2.2</EM>.</P><P CLASS="Paragraph"><A NAME="pgfId-7274"></A>If a virtual machine does not support the int data type, the value of atype may not be 13 (array type = T_INT).</P><H3 CLASS="Head2"><A NAME="pgfId-7275"></A>7.5.17 <A NAME="marker-54575"></A>dup</H3><P CLASS="Paragraph"><A NAME="pgfId-7276"></A>Duplicate top operand stack word</P><P CLASS="Paragraph"><A NAME="pgfId-7277"></A>Format</P><BR><TABLE CLASS="Titled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 BORDER="1" DIR="LTR"><CAPTION></CAPTION><TBODY><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-18702"></A><I CLASS="Variable">dup</I></P></TD></TR></TBODY></TABLE><BR><P CLASS="Paragraph"><A NAME="pgfId-7279"></A>Forms</P><P CLASS="Paragraph"><A NAME="pgfId-7280"></A>dup = 61 (0x3d)</P><P CLASS="Paragraph"><A NAME="pgfId-7281"></A>Stack</P><P CLASS="Paragraph"><A NAME="pgfId-7282"></A>..., word -><BR>..., word, word</P><P CLASS="Paragraph"><A NAME="pgfId-7283"></A>Description</P><P CLASS="Paragraph"><A NAME="pgfId-7284"></A>The top word on the operand stack is duplicated and pushed onto the operand stack.</P><P CLASS="Paragraph"><A NAME="pgfId-7285"></A>The dup instruction must not be used unless word contains a 16-bit data type.</P><P CLASS="Paragraph"><A NAME="pgfId-7286"></A>Notes</P><P CLASS="Paragraph"><A NAME="pgfId-1001940"></A>Except for restrictions preserving the integrity of 32-bit data types, the dup instruction operates on an untyped word, ignoring the type of data it contains.</P><H3 CLASS="Head2"><A NAME="pgfId-1001942"></A>7.5.18 <A NAME="marker-1001941"></A>dup_x</H3><P CLASS="Paragraph"><A NAME="pgfId-1001943"></A>Duplicate top operand stack words and insert below</P><P CLASS="Paragraph"><A NAME="pgfId-7290"></A>Format</P><BR><TABLE CLASS="Titled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 BORDER="1" DIR="LTR"><CAPTION></CAPTION><TBODY><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-18704"></A><I CLASS="Variable">dup_x</I></P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-18706"></A><I CLASS="Variable">mn</I></P></TD></TR></TBODY></TABLE><BR><P CLASS="Paragraph"><A NAME="pgfId-7293"></A>Forms</P><P CLASS="Paragraph"><A NAME="pgfId-7294"></A>dup_x = 63 (0x3f)</P><P CLASS="Paragraph"><A NAME="pgfId-7295"></A>Stack</P><P CLASS="Paragraph"><A NAME="pgfId-7296"></A>..., wordN, ..., wordM, ..., word1 -><BR>..., wordM, ..., word1, wordN, ..., wordM, ..., word1</P><P CLASS="Paragraph"><A NAME="pgfId-7297"></A>Description</P><P CLASS="Paragraph"><A NAME="pgfId-7298"></A>The unsigned byte mn is used to construct two parameter values. The high nibble, (mn & 0xf0) >> 4, is used as the value m. The low nibble, (mn & 0xf), is used as the value n. Permissible values for m are 1 through 4. Permissible values for n are 0 and m through m+4.</P><P CLASS="Paragraph"><A NAME="pgfId-7299"></A>For positive values of n, the top m words on the operand stack are duplicated and the copied words are inserted n words down in the operand stack. When n equals 0, the top m words are copied and placed on top of the stack.</P><P CLASS="Paragraph"><A NAME="pgfId-7300"></A>The dup_x instruction must not be used unless the ranges of words 1 through m and words m+1 through n each contain either a 16-bit data type, two 16-bit data types, a 32-bit data type, a 16-bit data type and a 32-bit data type (in either order), or two 32-bit data types.</P><P CLASS="Paragraph"><A NAME="pgfId-7301"></A>Notes</P><P CLASS="Paragraph"><A NAME="pgfId-7302"></A>Except for restrictions preserving the integrity of 32-bit data types, the dup_x instruction operates on untyped words, ignoring the types of data they contain.</P><P CLASS="Paragraph"><A NAME="pgfId-7303"></A>If a virtual machine does not support the int data type, the permissible values for m are 1 or 2, and permissible values for n are 0 and m through m+2.</P><H3 CLASS="Head2"><A NAME="pgfId-7304"></A>7.5.19 <A NAME="marker-54577"></A>dup2</H3><P CLASS="Paragraph"><A NAME="pgfId-7305"></A>Duplicate top two operand stack words</P><P CLASS="Paragraph"><A NAME="pgfId-7306"></A>Format</P><BR><TABLE CLASS="Titled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 BORDER="1" DIR="LTR"><CAPTION></CAPTION><TBODY><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-18709"></A><I CLASS="Variable">dup2</I></P></TD></TR></TBODY></TABLE><BR><P CLASS="Paragraph"><A NAME="pgfId-7308"></A>Forms</P><P CLASS="Paragraph"><A NAME="pgfId-7309"></A>dup2 = 62 (0x3e)</P><P CLASS="Paragraph"><A NAME="pgfId-7310"></A>Stack</P><P CLASS="Paragraph"><A NAME="pgfId-7311"></A>..., word2, word1 -><BR>..., word2, word1, word2, word1</P><P CLASS="Paragraph"><A NAME="pgfId-7312"></A>Description</P><P CLASS="Paragraph"><A NAME="pgfId-7313"></A>The top two words on the operand stack are duplicated and pushed onto the operand stack, in the original order.</P><P CLASS="Paragraph"><A NAME="pgfId-7314"></A>The dup2 instruction must not be used unless each of word1 and word2 is a word that contains a 16-bit data type or both together are the two words of a single 32-bit datum.</P><P CLASS="Paragraph"><A NAME="pgfId-7315"></A>Notes</P><P CLASS="Paragraph"><A NAME="pgfId-7316"></A>Except for restrictions preserving the integrity of 32-bit data types, the dup2 instruction operates on untyped words, ignoring the types of data they contain.</P><H3 CLASS="Head2"><A NAME="pgfId-7317"></A>7.5.20 <A NAME="marker-54578"></A>getfield_<t></H3><P CLASS="Paragraph"><A NAME="pgfId-7318"></A>Fetch field from object</P><P CLASS="Paragraph"><A NAME="pgfId-7319"></A>Format</P><BR><TABLE CLASS="Titled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 BORDER="1" DIR="LTR"><CAPTION></CAPTION><TBODY><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-18712"></A><I CLASS="Variable">getfield_<t></I></P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-18714"></A><I CLASS="Variable">index</I></P></TD></TR></TBODY></TABLE><BR><P CLASS="Paragraph"><A NAME="pgfId-7322"></A>Forms</P><P CLASS="Paragraph"><A NAME="pgfId-7323"></A>getfield_a = 131 (0x83)<BR>getfield_b = 132 (0x84)<BR>getfield_s = 133 (0x85)<BR>getfield_i = 134 (0x86)</P><P CLASS="Paragraph"><A NAME="pgfId-7324"></A>Stack</P><P CLASS="Paragraph"><A NAME="pgfId-7325"></A>..., objectref -><BR>..., value</P><P CLASS="Paragraph"><A NAME="pgfId-7326"></A>OR</P><P CLASS="Paragraph"><A NAME="pgfId-7327"></A>..., objectref -><BR>..., value.word1, value.word2</P><P CLASS="Paragraph"><A NAME="pgfId-7328"></A>Description</P><P CLASS="Paragraph"><A NAME="pgfId-1003357"></A>The objectref, which must be of type reference, is popped from the operand stack. The unsigned index is used as an index into the constant pool of the current package (<A HREF="JCVM03structVM.html#13656" CLASS="XRef">Section 3.5, Frames</A>). The constant pool item at the index must be of type CONSTANT_InstanceFieldref (<A HREF="JCVM06cap.html#15653" CLASS="XRef">Section 6.7.2, CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, and CONSTANT_SuperMethodref</A>), a reference to a class and a field token.</P><P CLASS="Paragraph"><A NAME="pgfId-1003364"></A>The class of objectref must not be an array. If the field is protected, and it is a member of a superclass of the current class, and the field is not declared in the same package as the current class, then the class of objectref must be either the current class or a subclass of the current class.</P><P CLASS="Paragraph"><A NAME="pgfId-7330"></A>The item must resolve to a field with a type that matches t, as follows:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-7331"></A>a field must be of type reference</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1-"><A NAME="pgfId-1001991"></A>b field must be of type byte or type boolean</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1-"><A NAME="pgfId-1001992"></A>s field must be of type short</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1-"><A NAME="pgfId-1001993"></A>i field must be of type int</LI><P CLASS="Linebreak"></P></UL><P CLASS="Paragraph"><A NAME="pgfId-7335"></A>The width of a field in a class instance is determined by the field type specified in the instruction. The item is resolved, determining the field offset<A NAME="fnote5"></A><A HREF="#pgfId-53110" CLASS="footnote"><SUP>[5]</SUP></A>. The value at that offset into the class instance referenced by objectref is fetched. If the value is of type byte or type boolean, it is sign-extended to a short. The value is pushed onto the operand stack.</P><P CLASS="Paragraph"><A NAME="pgfId-7336"></A>Runtime Exception</P><P CLASS="Paragraph"><A NAME="pgfId-26694"></A>If objectref is null, the getfield_<t> instruction throws a NullPointerException.</P><P CLASS="Paragraph"><A NAME="pgfId-26695"></A>Notes</P><P CLASS="Paragraph"><A NAME="pgfId-26696"></A>In some circumstances, the getfield_<t> instruction may throw a SecurityException if the current context (<A HREF="JCVM03structVM.html#33311" CLASS="XRef">Section 3.4, Contexts</A>) is not the owning context (<A HREF="JCVM03structVM.html#33311" CLASS="XRef">Section 3.4, Contexts</A>) of the object referenced by objectref. The exact circumstances when the exception will be thrown are specified in Chapter 6 of the <EM CLASS="Emphasis">Runtime Environment Specification, Java Card Platform, Version 2.2.2</EM>.</P><P CLASS="Paragraph"><A NAME="pgfId-26697"></A>If a virtual machine does not support the int data type, the getfield_i instruction will not be available.</P><H3 CLASS="Head2"><A NAME="pgfId-7340"></A>7.5.21 <A NAME="marker-54579"></A>getfield_<t>_this</H3><P CLASS="Paragraph"><A NAME="pgfId-7341"></A>Fetch field from current object</P><P CLASS="Paragraph"><A NAME="pgfId-7342"></A>Format</P><BR><TABLE CLASS="Titled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 BORDER="1"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -