📄 appa.htm
字号:
ifle=158 branch1 branch2 Stack: ..., INT ->...</TT></BLOCKQUOTE><H5>Comparison with Null</H5><BLOCKQUOTE><TT>ifnull=198 branch1 branch2 Stack:..., OBJ -> ...<BR>ifnonnull=199 branch1 branch2 Stack: ..., OBJ -> ...</TT></BLOCKQUOTE><H5>Compare Two Integers</H5><BLOCKQUOTE><TT>if_icmpeq=159 branch1 branch2 Stack:..., INT1, INT2 -> ...<BR>if_icmpne=160 branch1 branch2 Stack: ..., INT1, INT2-> ...<BR>if_icmplt=161 branch1 branch2 Stack: ..., INT1, INT2-> ...<BR>if_icmpge=162 branch1 branch2 Stack: ..., INT1, INT2-> ...<BR>if_icmpgt=163 branch1 branch2 Stack: ..., INT1, INT2-> ...<BR>if_icmple=164 branch1 branch2 Stack: ..., INT1, INT2-> ...</TT></BLOCKQUOTE><H5>Compare Two Long Integers</H5><BLOCKQUOTE><TT>lcmp=148 Stack: ..., L1_1, L1_2, L2_1,L2_2 -> ..., INT (One of [-1, 0, 1])</TT></BLOCKQUOTE><H5>Compare Two Floats </H5><P>l->-1 on NaN, g->1 on NaN.<BLOCKQUOTE><TT>fcmpl=149 Stack: ..., FLOAT1,FLOAT2 -> ..., INT (One of [-1, 0, 1])<BR>fcmpg=150 Stack: ..., FLOAT1, FLOAT2 -> ..., INT(One of [-1, 0, 1])</TT></BLOCKQUOTE><H5>Compare Two Doubles </H5><P>l->-1 on NaN, g->1 on NaN.<BLOCKQUOTE><TT>dcmpl=151 Stack: ..., D1_1,D1_2, D2_1, D2_2 -> ..., INT (One of [-1, 0, 1])<BR>dcmpg=152 Stack: ..., D1_1, D1_2, D2_1, D2_2 ->..., INT (One of [-1, 0, 1])</TT></BLOCKQUOTE><H5>Compare Two Objects</H5><BLOCKQUOTE><TT>if_acmpeq=165 branch1 branch2 Stack:..., OBJ1, OBJ2 -> ...<BR>if_acmpne=166 branch1 branch2 Stack: ..., OBJ1, OBJ2-> ...</TT></BLOCKQUOTE><H5>Unconditional Branching</H5><P>16-bit and 32-bit branching<BLOCKQUOTE><TT>goto=167 branch1 branch2 Stack:... -> ...<BR>goto_w=200 branch1 branch2 branch3 branch4 Stack: ...-> ...</TT></BLOCKQUOTE><H5>Jump Subroutine </H5><P>16-bit and 32-bit jumps<BLOCKQUOTE><TT>jsr=168 branch1 branch2 Stack:... -> ..., returnAddress<BR>jsr_w=201 branch1 branch2 branch3 branch4 Stack:... -> ..., returnAddress</TT></BLOCKQUOTE><H5>Return from Subroutine </H5><P>The return address is retrieved from a local variable, not thestack.<BLOCKQUOTE><TT>ret=169 vindex Stack:... -> ... (returnAddress <- vars[vindex])<BR>ret_w=209 vindex1 vindex2 Stack: ... -> ... (returnAddress<- vars[vindex])</TT></BLOCKQUOTE><H5>Returning Primitives </H5><P>The current stack frame is destroyed. The top primitive is pushedonto the caller's operand stack.<BLOCKQUOTE><TT>ireturn=172 Stack: ..., INT-> [destroyed]<BR>lreturn=173 Stack: ..., LONG1, LONG2 -> [destroyed]<BR>freturn=174 Stack: ..., FLOAT -> [destroyed]<BR>dreturn=175 Stack: ..., DOUBLE1, DOUBLE2 -> [destroyed]<BR>areturn=176 Stack: ..., OBJ -> [destroyed]<BR>return=177 Stack: ... -> [destroyed]</TT></BLOCKQUOTE><H5>Calling the Breakpoint Handler</H5><BLOCKQUOTE><TT>breakpoint=202 Stack: ...,-> ...</TT></BLOCKQUOTE><H4>Manipulating Object Fields</H4><P>Construct a 16-bit index into the constant pool to retrieve theclass and field name, then resolve these names to determine thefield offset and width. Use the object reference on the stackas the target. The value will be 32 or 64 bits, depending on thefield information in the constant pool.<BLOCKQUOTE><TT>Getstatic=178 index1 index2 Stack:..., -> ..., VAL<BR>Putstatic=179 index1 index2 Stack:..., VAL -> ...<BR>Getfield=180 index1 index2 Stack:..., OBJ -> ..., VAL<BR>Putfield=181 index1 index2 Stack:..., OBJ, VAL -> ...</TT></BLOCKQUOTE><H4>Method Invocation</H4><P>There are four types of method invocation:<UL><LI><TT>invokevirtual=182</TT>-Normalmethod dispatch in Java. Use the index bytes to create a 16-bitindex into the constant table of the current class. Extract themethod name and signature. Search the method table of the stackobject to determine the method address. Use the method signatureto remove the method arguments from the operand stack and transferthem to the new method's local variables.<LI><TT>invokenonvirtual=183</TT>-Usedwhen a method is called with the super keyword. Use the indexbytes to create a 16-bit index into the constant pool of the currentclass. Extract the method name and signature. Search the namedclass's method table to determine the method address. Extractthe object and arguments and place them in the new method's localvariables.<LI><TT>invokestatic=184</TT>-Usedto call static methods. Create a 16-bit index into the currentclass's constant pool. Extract the method and search the namedclass's method table for the address. Transfer the arguments asbefore. There is no object to pass.<LI><TT>invokeinterface=185</TT>-Invokean interface function. Again, a 16-bit index is created to findthe method name and signature. This time, however, the numberof arguments is determined from the bytecodes, not the signature.<BR><BR><TT>virtual index1 index2 Stack:..., OBJ, [arg1, [arg2, ...]] -> ...<BR>nonvirtual index1 index2 Stack: ..., OBJ, [arg1, [arg2, ...]] -> ...<BR>static index1 index2 Stack:..., [arg1, [arg2, ...]] -> ...<BR>interface index1 index2 nargs resv Stack: ..., OBJ, [arg1, [arg2,...]] -> ...</TT></UL><H4>Miscellaneous Operations</H4><P>These instructions don't fall under any other heading; they dealwith generic object operations, such as creation and casting.<H5>Throw Exception</H5><BLOCKQUOTE><TT>athrow=191 Stack: ..., OBJ-> [undefined]</TT></BLOCKQUOTE><H5>Create a New Object</H5><BLOCKQUOTE><TT>new=187 index1 index2 Stack:... -> ..., OBJ</TT></BLOCKQUOTE><H5>Check a Cast Operation</H5><BLOCKQUOTE><TT>checkcast=192 index1 index2 Stack:..., OBJ -> ..., OBJ</TT></BLOCKQUOTE><H5>Instanceof</H5><BLOCKQUOTE><TT>instanceof=193 index1 index2 Stack:..., OBJ -> ... INT (1 or 0)</TT></BLOCKQUOTE><H4>Monitors</H4><P>Monitor instructions are used for synchronization.<H5>Enter a Monitored Region of Code</H5><BLOCKQUOTE><TT>monitorenter=194 Stack: ...,OBJ -> ...</TT></BLOCKQUOTE><H5>Exit a Monitored Region of Code</H5><BLOCKQUOTE><TT>monitorexit=195 Stack: ...,OBJ -> ...</TT></BLOCKQUOTE><H3><A NAME="TestClassBytecodes">Test Class Bytecodes</A></H3><P>Sun supplies a tool, <TT>javap</TT>,that enables you to disassemble and view the bytecodes of a class.If the -c option is passed to <TT>javap</TT>,a listing of bytecodes is produced. These are the test class'sbytecodes:<BLOCKQUOTE><TT>Compiled from test.java<BR>public class test extends java.lang.Object {<BR> public static int st_one;<BR> public test();<BR> public test(int);<BR> public native boolean getData(int []);<BR> public int do_countdown();<BR> public int do_countdown(int);<BR><BR>Method test()<BR> 0 aload_0<BR> 1 invokenonvirtual #9 <Method java.lang.Object.<init>()V><BR> 4 bipush 100<BR> 6 putstatic #7 <Field test.st_one I><BR> 9 return<BR><BR>Method test(int)<BR> 0 aload_0<BR> 1 invokenonvirtual #9 <Method java.lang.Object.<init>()V><BR> 4 iload_1<BR> 5 putstatic #7 <Field test.st_one I><BR> 8 return<BR><BR>Method int do_countdown()<BR> 0 getstatic #7 <Field test.st_one I><BR> 3 istore_1<BR> 4 getstatic #6 <Field java.lang.System.outLjava/io/PrintStream;><BR> 7 ldc #1 <String "Performing countdown:"><BR> 9 invokevirtual #10 <Method java.io.PrintStream.println(Ljava/lang/String;)V><BR> 12 goto 22<BR> 15 getstatic #6 <Field java.lang.System.out Ljava/io/PrintStream;><BR> 18 iload_1<BR> 19 invokevirtual #8 <Method java.io.PrintStream.println(I)V><BR> 22 iload_1<BR> 23 iinc 1 -1<BR> 26 ifne 15<BR> 29 getstatic #7 <Field test.st_one I><BR> 32 ireturn<BR><BR>Method int do_countdown(int)<BR> 0 iload_1<BR> 1 istore_2<BR> 2 getstatic #6 <Field java.lang.System.outLjava/io/PrintStream;><BR> 5 ldc #1 <String "Performing countdown:"><BR> 7 invokevirtual #10 <Method java.io.PrintStream.println(Ljava/lang/String;)V><BR> 10 goto 20<BR> 13 getstatic #6 <Field java.lang.System.out Ljava/io/PrintStream;><BR> 16 iload_1<BR> 17 invokevirtual #8 <Method java.io.PrintStream.println(I)V><BR> 20 iload_1<BR> 21 iinc 1 -1<BR> 24 ifne 13<BR> 27 iload_2<BR> 28 ireturn<BR>}</TT></BLOCKQUOTE><P>The left-hand column displays the offset of the instruction. <TT>Javap</TT>automatically converts jump displacements to actual offsets. Inaddition, it looks up constant pool references in order to outputthe corresponding strings.<H2><A NAME="GarbageCollection"><FONT SIZE=5 COLOR=#FF0000>GarbageCollection</FONT></A></H2><P>Java uses a multitiered security mechanism. The bytecode verifierprovides the lowest layer of security. Above the verifier, thesecurity manager is the next sentry. In addition to these twoexplicit checks, there are a number of language features thatprovide security as well. Chief among these is the garbage collector.<P>Failing to free memory blocks or file handles is a common bugin most modern programs. The problem quickly escalates until thesystem crashes in some unforeseen manner. Java, like Smalltalkbefore it, uses implicit garbage collection to solve the problem.The virtual machine spec does not mandate a particular type ofgarbage collection; it requires only that some type be used.<P>In Sun's runtime, a mark and sweep algorithm is used. This enablesthe garbage collector to run incrementally in the background.<P><HR WIDTH="100%"></P></P></CENTER><P><HR WIDTH="100%"></P><!-- reference library footer #1--></CENTER><IMG SRC="/images/rule.gif" WIDTH="460" HEIGHT="5" VSPACE="5"ALT="Ruler image"><br><FONT SIZE="-1">Contact <a href="mailto:reference@developer.com">reference@developer.com</a> with questions or comments.<br><a href="/legal/">Copyright 1998</a> <a href="http://www.earthweb.com" target="_top">EarthWeb Inc.</a>, All rights reserved.<BR>PLEASE READ THE <a href="/reference/usage.html">ACCEPTABLE USAGE STATEMENT</a>.<BR>Copyright 1998 Macmillan Computer Publishing. All rights reserved.</FONT></BLOCKQUOTE><!--outer table--><TD VALIGN="TOP"><!--right side ads --><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCAD1.REF" alt="Click here for more info"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCAD1.REF" alt="Click here for more info" height="88" width="88" border="0"></a><P><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCAD2.REF" alt="Click here for more info"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCAD2.REF" alt="Click here for more info" height="88" width="88" border="0"></a><P></td></tr></table></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -