JVM Notes - 2

原创 2005年05月30日 21:47:00

The Java Class File
First the java programmer should know is that the class file is precisely defined
binary file(8-biy bytes). Every bit in it should be meaningful and can be validated
by the JVM.

The following is the item which defined in the class file sequencely:
1. Magic :
The identifier of the java class file which is the constant(0xCAFEBABE),
The derivation of this number is funny, it is the reference to a waiter in the Peet's
Coffee.

2. minor version and major_version.
As the java technology is growing fast, every time a new version comes, the format
of the class file may change, that there is such tag kept in the class file to
identify whether the class file is compatible for the JVM that user uses.
Eg.
0003    3 minor_version
002D    45 major_version

3. constant_pool_count
Eg.
0011    17 constant_pool_count
Indicates how many constant exist in the class file, it is also the total length
of constant_pool array. Note the zeroeth element does not appear in the class file
([:?:] where does it appear), JVM will expect to find element 1 to 16.

4. constant_pool
Every constants pool starts with a one-byte tag which indicates the type of constant.

Eg.
07    7 tag
000C    12 name_index

when the JVM encounter the 7, it will get know that the current entry(not byte) is the
CONTANT_Class_info, base on the JVM spec

java.sun.com/download/latest/java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#1221

CONSTANT_Class_info {
    u1 tag;//a single unsigned byte
    u2 name_index;//2 unsigned byte, it should be a valid index of the constant_pool table
                  //it is the symbolic reference to a class or interface.
}
From the point 3. the range is 1 to 16. Let's jump to constant_pool[12]
Eg.
01     1  tag
0010     16  length
6A6176612F6C616E672F4F626A656374  "java/lang/Object" bytes[length]
It is a Utf-8 entry
CONSTANT_Utf8_info {
     u1 tag;
     u2 length;
     u1 bytes[length];
}
From all those, JVM will know the super class is the object as it does not
explicitly specify any super calss. This procedure is to resolve the symbolic.

Actually, constant_pool contains:
1. class/interface info
2. field info
3. method info
And those ensure that the constant_pool will play an important role in the dynamic linking.


5. access_flag
The access_flag is followed by constant_pool. which can be the following possible values
ACC_PUBLIC     0x0001
ACC_FINAL      0x0010
ACC_SUPER      0x0020
ACC_INTERFACE  0x0200
ACC_ABSTRACT   0x0400
such flag is two byte, as you seen in the above definition, every flag is two byte then
how can the class tell the JVM it is the public final class? good question, see the
following example you will know about these :
public final = (ACC_PUBLIC | ACC_FINAL) = 00011;
: ), quite smart.

6. this class
this_class should be next to access flag .
0002  2 this_class

the detail of contant_pool[2]:
07    7 tag
000D  13 name_index
then jump to constant_pool[13]
01  1  tag
0003  3  length
416374  "Act"  bytes[length]
It indicates this_class is the Act class
7. supper class
this class should be next to supper class.
0001  1 super_class

the detail of contant_pool[1]:
07    7 tag
000C    12 name_index
then jump to constant_pool[12]
01     1  tag
0010    16  length
6A6176612F6C616E672F4F626A656374  "java/lang/Object" bytes[length]
It indicates the super_class is the Object.

8. interface count and interfaces
the interface count is the length of the interfaces array, which indicates
how many interface such class is implemented, the item of interfaces array
is the reference to constant_pool.

9. fields count and fields
similar with above

10. methods_count ad methods
eg.
0009   access_flags
0006  6 name_index
0010  16 descriptor_index

take a look at constant_pool[6]
01      1   tag
000D    13   length
646F4D617468466F7265766572  "doMathForever"  bytes[length]
it indicates the method name
take a look at constant_pool[16]
01      1 tag
0003  3 length
282956  "()V" bytes[length]
it indicates the method has no argument and no return values.

also it defines the stak(max) size and local variable size.

11. attribute_count and attributes
attribute is something like the exceptions, innerclasses and so forth.

eclipse初次打开JVM terminated.Exit Code=2

eclipse初次打开JVM terminated.Exit Code=2
  • q10123
  • q10123
  • 2015年05月08日 20:01
  • 1667

Eclipse 启动报错:jvm terminated exit code =2

问题描述: Eclipse 打开报错:jvm terminated exit code =2   C:\ProgramData\Oracle\Java\javapath     ...
  • qq524425141
  • qq524425141
  • 2016年04月07日 17:38
  • 1839

eclipse报jvm terminated.exitcode=2异常解决办法

eclipse报jvm terminated.exitcode=2异常解决办法 转载自:http://www.educity.cn/wenda/467202.html 原理其实很简单,是由于我安转...
  • qiantujava
  • qiantujava
  • 2015年10月22日 09:26
  • 2461

Eclipse启动报错:JVM terminated. Exit code=2

最初的时候Eclipse是安装在C盘,JDK也是,Workspace也放在C盘,最近由于C盘空间不够用了,所以把它们全部转移到了D盘,启动的时候就报错了:JVM terminated. Exit co...
  • testcs_dn
  • testcs_dn
  • 2017年01月07日 09:12
  • 1711

java调用notes API 发送邮件

最近需要调用Notes java API来发送邮件.主要参考了以下两个博客: 1   http://www.blogjava.net/jiangmin/articles/76137.html这个博客完...
  • lihe2008125
  • lihe2008125
  • 2010年02月22日 17:37
  • 2259

Notes客户端命令参数选项

C:/Notes/Notes.exe =C:/Notes/MyNotes.ini根据mynotes.ini启动clientC:/Notes/Notes.exe dbName.nsf当notes cli...
  • snowdot23
  • snowdot23
  • 2004年08月20日 14:30
  • 1135

Lotus Notes 8 客户端可以更换界面风格主题 !

  
  • shichuanbao
  • shichuanbao
  • 2008年02月14日 17:29
  • 3769

Notes ID忘记密码处理

當使用者忘記Notes ID的密碼時,如何回復密碼 1. 先取得使用者目前正在使用的ID. 2. 開啟Notes Administrator,執行摘取回復密碼。 3. 輸入管理者的ID 密碼 4. 選...
  • u012402276
  • u012402276
  • 2015年09月25日 11:32
  • 272

Notes 8/8.5 超慢解决之道的最佳实践

如果您使用的Lotus Notes客户端为8.0/8.5,  如果感觉非常慢,通过任务管理器看到lotus的进程占用的内存非常大。哦,这的确令人感到非常懊悔!那就快来试试这些吧!在使用notes 8....
  • MingleLui
  • MingleLui
  • 2010年04月09日 23:15
  • 2018

如何在 Notes 标准配置中重新创建工作空间和清除缓存?

Technote (troubleshooting) 问题 如何在 Notes 标准配置中重新创建工作空间和清除缓存? 解决问题 1. 使用DOS提示符,切换到Notes程...
  • Gavid0124
  • Gavid0124
  • 2014年12月01日 16:36
  • 945
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:JVM Notes - 2
举报原因:
原因补充:

(最多只允许输入30个字)