⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appa.htm

📁 JAVA Developing Professional JavaApplets
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<HTML><HEAD><TITLE>developer.com - Reference</TITLE><META NAME="Author" CONTENT="developer.com"><META NAME="Keywords" CONTENT="javascript, ActiveX, VRML, Push, channel,push channel, applet, directory, news, community, developer, internet,intranet, java, java applet, J++, javabeans, java products, tools, javatools, JDK, java development kit, java development environment, JIT,JavaPlan, enterprise tools, JVM, Java Virtual Machine, Java resources, API,browser, java documentation, CDF, Common Desktop Format, RDF, ResourceDescription Framework, Netcaster, Netcast, Castanet, meta-language, metadata,solaris, Solaris, SUN, CGI, Perl, Oracle, database, network, Netscape API,Apache, apache, SSL, mSQL, Netscape, Fasttrack, FastTrack,industry standard, ActiveX bridge, web, internet, site, sitedesign, microsoft, active server pages, asp, iis, nt, win95, 95, html, cgi,frontpage, business, corporate, vbscript, javascript, activex, isapi,database, access, sql, server, www, 3.0, 3.01, 3.02, 3.03, 3.04, 4.0,4.0b2, 4.01, 4.03, 4.04, connection, online, commerce, publisher,publishing, publish, webmaster, dynamic html, dhtml, windows 98, netscape,netscape software, shareware, magazines, jobs, japan, free, freeware, freestuff"><META NAME="description" CONTENT="Developer.com is the leading onlineservice for developers. It includes Gamelan, the official directory for Java, as wellas news, information, tutorials, and directories for other Internet technologiesincluding ActiveX, JavaScript, perl, VRML, Java Beans, push technologies, andother Internet and intranet technologies. Developer.com is also the home ofDeveloper Direct, the Professional Developer's Store, where developers canpurchase and download thousands of Web, authoring and other developmentproducts at some of today's lowest prices."><META NAME="distribution" CONTENT="global"><META NAME="resource-type" CONTENT="document"><META NAME="language" CONTENT="en"></HEAD><BODY BACKGROUND="/images/curve_r-wide.gif" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#DD0000" VLINK="#999999" ALINK="#FF0000"><TABLE><TR><TD VALIGN=TOP WIDTH=120><A HREF="/" ><IMG SRC="/images/masthead_r.gif" WIDTH="100" HEIGHT="78" BORDER="0"ALT="Developer.com Logo"></a></TD><TD><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCBAN.REF/DT=null"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCBAN.REF/DT=null" HEIGHT="60" WIDTH="468" ALT="Click here to support our advertisers"><BR><CENTER>Click here to support our advertisers</CENTER></a></TD></TR></TABLE><!--outer table--><TABLE><!--outer table--><TR><!--outer table--><TD VALIGN="TOP"><!--navbar info --><table><tr><td><A HREF="http://www.developerdirect.com/" ><IMG SRC="/images/button_s.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>SHOPPING</b></font></a></td></tr><tr><td><A HREF="/community/jobs/c_jobs.html"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>JOB BANK</B></font></a></td></tr><tr><td><A HREF="http://www.classifieds2000.com/cgi-cls/display.exe?Developer+computer+searchcomputercategories"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>CLASSIFIEDS</B></font></a></td></tr><tr><td><A HREF="/directories/directories.html"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>DIRECTORIES</B></font></a></td></tr><tr><td><A HREF="/reference/"><IMG SRC="/images/button_r.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>REFERENCE</B></font></a><br><a href="/reference/r_library.html"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000">Online Library</a></font></td></tr><tr><td><A HREF="/classroom/"><IMG SRC="/images/button_r.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>LEARNING CENTER</B></font></a></td></tr><tr><td><A HREF="/journal/"><IMG SRC="/images/button_n.gif" width="15" height="11" BORDER="0"><B><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000">JOURNAL</font></B></a></td></tr><tr><td><A HREF="/news/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>NEWS CENTRAL</b></font></a></td></tr><tr><td><A HREF="/downloads/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>DOWNLOADS</b></font></a></td></tr><tr><td><A HREF="/community/" ><IMG SRC="/images/button_c.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><B>COMMUNITY</B></font></a></td></tr><tr><td><A HREF="/calendar/"><IMG SRC="/images/button_d.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>CALENDAR</b></font></a></td></tr><tr><td><A HREF="/about/"><IMG SRC="/images/button_a.gif" width="15" height="11" BORDER="0"><FONT FACE="Arial, Helvetica" SIZE="-1" color="#000000"><b>ABOUT US</b></a></font></td></tr></table><table><tr><td><form action="/subscribe/list.cgi" method=post ><img src="/images/rule.gif" width="100" height="2"><br><B><FONT FACE="Arial, Helvetica" SIZE="-1">Journal:</b></font><br><input name='email' value='your e-mail' size="11"><input type='hidden'  name='state' value='Subscribe'></td></tr><tr><td><input type='submit' value='Subscribe'><br><font size="-1">Get the weekly email highlights from the most popular journal for developers!<br><a href="http://www.developer.com/subscribe.html">Current issue</a><img src="/images/rule.gif" width="100" height="2"><input type='hidden' name='name' value='New Subscriber'></FORM></td></tr></table><!--/navbar--><font size="-1"><A HREF="http://www.developer.com">developer.com</a><BR><A HREF="http://www.developerdirect.com">developerdirect.com</a><BR><A HREF="http://www.htmlgoodies.com">htmlgoodies.com</a><BR><A HREF="http://www.javagoodies.com">javagoodies.com</a><br><A HREF="http://www.jars.com">jars.com</a><BR><a href="http://www.intranetjournal.com">intranetjournal.com</a><br><a href="http://www.javascripts.com">javascripts.com</a><br></font><!--outer table--></TD><!--outer table--><TD VALIGN="TOP"><BLOCKQUOTE><P><img src="/images/header_r.gif" width="440" height="50"><P><MAP NAME ="header_r2.gif.map"><AREA SHAPE ="RECT"      HREF ="/reference/author.html"      COORDS ="361,0,440,29"><AREA SHAPE ="RECT"      HREF ="/reference/basic.html"      COORDS ="254,0,360,29"><AREA SHAPE ="RECT"      HREF ="/reference/help.html"      COORDS ="183,0,251,29"><AREA SHAPE ="RECT"      HREF ="/reference/cool.html"      COORDS ="100,0,181,29"><AREA SHAPE ="RECT"      HREF ="/reference/mybook.html"      COORDS ="0,0,100,29"></MAP><MAP NAME ="header_r1.gif.map"><AREA SHAPE ="RECT"      HREF ="/reference/personalize.html"      COORDS ="339,0,439,29"></MAP><p><font face="Arial,Helvetica" size="-1" color="#006666"><A HREF="/reference/r_library.html"><B>All Categories</A> :</B><b><A HREF="/reference/r_java.html">Java</A></b></font><p>   <META NAME="GENERATOR" CONTENT="Mozilla/3.0b5aGold (WinNT; I) [Netscape]"><H1><FONT COLOR=#FF0000>Appendix A </FONT></H1><H1><B><FONT SIZE=5 COLOR=#FF0000>Inside the Java Virtual Machine</FONT></B></H1><P><HR WIDTH="100%"></P><P><H3 ALIGN=CENTER><FONT COLOR="#000000"><FONT SIZE=+2>CONTENTS<A NAME="CONTENTS"></A></FONT></FONT></H3><UL><LI><A HREF="#TheClassFile" >The Class File</A><UL><LI><A HREF="#Layout" >Layout</A></UL><LI><A HREF="#TheVirtualMachine" >The Virtual Machine</A><UL><LI><A HREF="#Registers" >Registers</A><LI><A HREF="#OperandStack" >Operand Stack</A></UL><LI><A HREF="#PrimitiveTypes" >Primitive Types</A><LI><A HREF="#LocalVariables" >Local Variables</A><UL><LI><A HREF="#TheVerifier" >The Verifier</A><LI><A HREF="#ExceptionHandling" >Exception Handling</A><LI><A HREF="#Bytecodes" >Bytecodes</A><LI><A HREF="#TestClassBytecodes" >Test Class Bytecodes</A></UL><LI><A HREF="#GarbageCollection" >Garbage Collection</A></UL><HR><P>Looking at a virtual machine from the outside in is probably thebest way to understand its workings. Incremental learning resultswhen you move from the known to the unknown, so this section startswith the item you are most familiar with: the class file.<H2><A NAME="TheClassFile"><FONT SIZE=5 COLOR=#FF0000>The ClassFile</FONT></A></H2><P>The class file is similar to standard language object modules.When a C language file is compiled, the output is an object module.Multiple object modules are linked together to form an executableprogram. In Java, the class file replaces the object module andthe Java virtual machine replaces the executable program.<P>You'll find all the information needed to execute a class containedwithin the class file, as well as extra information that aidsdebugging and source file tracking. Remember that Java has no&quot;header&quot; include files, so the class file format alsohas to fully convey class layout and members. Parsing a classfile yields a wealth of class information, not just its runtimearchitecture.<H3><A NAME="Layout">Layout</A></H3><P>The overall layout uses an outer structure and a series of substructuresthat contain an ever-increasing amount of detail. The outer layeris described by the following structure:<BLOCKQUOTE><TT>ClassFile<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;u4 magic;<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 minor_version;<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 major_version;<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 constant_pool_count;<BR>&nbsp;&nbsp;&nbsp;&nbsp;cp_info constant_pool[constant_pool_count- 1];<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 access_flags;<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 this_class;<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 super_class;<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 interfaces_count;<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 interfaces[interfaces_count];<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 fields_count;<BR>&nbsp;&nbsp;&nbsp;&nbsp;field_info fields[fields_count];<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 methods_count;<BR>&nbsp;&nbsp;&nbsp;&nbsp;method_info methods[methods_count];<BR>&nbsp;&nbsp;&nbsp;&nbsp;u2 attributes_count;<BR>&nbsp;&nbsp;&nbsp;&nbsp;attribute_info attributes[attribute_count];<BR>}</TT></BLOCKQUOTE><P>In addition to the generic class information (this_class, super_class,version, and so forth), there are three major substructures: constant_pool,fields, and methods. Attributes are considered minor substructuresbecause they recur throughout the class file at various levels.Fields and methods contain their own attributes. Some individualattributes also contain their own private attribute arrays.<P>The u2 and u4 types represent unsigned 2-byte and 4-byte quantities.<P>This simple class will be used throughout this appendix as thebasis for class file exploration.<BLOCKQUOTE><TT>public class test<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;public static int st_one;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;public test()<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;st_one = 100;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;public test(int v)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;st_one = v;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;public native boolean getData(int data[]);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;public int do_countdown()<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int x = st_one;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Performingcountdown:&quot;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ( x- !=0 )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(x);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return st_one;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;public int do_countdown(int x)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int save = x;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Performingcountdown:&quot;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ( x- !=0 )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(x);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return save;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}</TT></BLOCKQUOTE><P>This class doesn't actually do very much, but it does providea basis for class file exploration. Once compiled, the outer layerof the resulting class file is as follows:<BLOCKQUOTE><TT>file name: test.class<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;magic: cafebabe<BR>&nbsp;&nbsp;&nbsp;&nbsp;version: 45.3<BR>&nbsp;&nbsp;constants: Valid indexes: 1 - 39<BR>&nbsp;&nbsp;&nbsp;&nbsp; access: PUBLIC<BR> this class: Class: test<BR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -