`

JVM学习笔记-类型信息(Type Information)

 
阅读更多

 

For each type it loads, a Java Virtual Machine must store the following kinds of information in the method area:

 对每个装载的类型,虚拟机都会在方法区中存储以下类型信息:

  • The fully qualified name of the type
  • 这个类型的全限定名
  • The fully qualified name of the type’s direct superclass (unless the type is an interface or class java.lang.Object, neither of which have a superclass)
  • 这个类型的直接超类的全限定名(除非这个类是java.lang.Object,它没有超类)。
  • Whether or not the type is a class or an interface
  • 这个类型是类类型还是接口类型
  • The typeís modifiers ( some subset of` public, abstract, final)
  • 这个类型的访问修饰符(public, abstract或final的某个子集)。
  • An ordered list of the fully qualified names of any direct superinterfaces
  • 任何直接超接口的全限定名的有序列表

Inside the Java class file and Java Virtual Machine, type names are always stored as fully qualified names. In Java source code, a fully qualified name is the name of a typeís package, plus a dot, plus the typeís simple name. For example, the fully qualified name of class Object in package java.lang is java.lang.Object. In class files, the dots are replaced by slashes, as in java/lang/Object. In the method area, fully qualified names can be represented in whatever form and data structures a designer chooses.

在Java class文件和虚拟机中,类型名总是以全限定名出现。在Java源代码中,全限定名由类所属包的名称加一个“.”,再加上类名组成。例如,类Object的所属包为java.lang,那么它的全限定名应该是java.lang.Object,但在class文件里,所有的“.” 都被斜杠“/”代替,这样就成为java/lang/Object。至于全限定名在方法区中的表示,则因不同的设计者有不同的选择而不同,可以用任何形式和数据结构来表示。

In addition to the basic type information listed above, the virtual machine must also store for each loaded type:

除了上面列出的基本类型信息外,虚拟机还得为每个被装载的类型存储以下信息:

  • The constant pool for the type
  • 该类型的常量池
  • Field information
  • 字段信息
  • Method information
  • 方法信息
  • All class (static) variables declared in the type, except constants
  • 除了常量以外的所有类(静态)变量
  • A reference to class ClassLoader
  • 一个到类CLassLoader的引用
  • A reference to class Class
  • 一个到Class类的引用
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics