classpath

package
v0.0.0-...-a6a931b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Classpath

type Classpath struct {
	// contains filtered or unexported fields
}

Classpath * 三个 Entry 变量分别代表: 1. bootClasspath : 启动类路径 2. extClasspath : 扩展类路径 3. userClasspath : 用户类路径

func Parse

func Parse(jreOption, cpOption string) *Classpath

Parse /** jreOption : 启动类路径选项 cpOption : 用户类路径选项

func (*Classpath) ReadClass

func (self *Classpath) ReadClass(className string) ([]byte, Entry, error)

func (*Classpath) String

func (self *Classpath) String() string

type CompositeEntry

type CompositeEntry []Entry

CompositeEntry * CompositeEntry由更小的Entry组成,正好可以表示 成[]Entry。在Go语言中,数组属于比较低层的数据结构,很少直接 使用。大部分情况下,使用更便利的slice类型。

func (CompositeEntry) String

func (self CompositeEntry) String() string

type DirEntry

type DirEntry struct {
	// contains filtered or unexported fields
}

DirEntry * 目录形式的类路径结构 成员变量说明: absDir:存放类的绝对路径

func (*DirEntry) String

func (self *DirEntry) String() string

type Entry

type Entry interface {

	// String
	/**
	toString方法
	*/
	String() string
	// contains filtered or unexported methods
}

Entry * 在加载主类之前,jvm首先会加载它的超类,如果没有明确的继承关系,那么其父类便是:java.lang.Object。 执行main方法之前还需要加载java.lang.String类以及java.lang.String[]. 于是虚拟机面临这样一个问题:虚拟机如何寻找需要加载的类的。

Java虚拟机规范给了足够的自由:从何处加载class文件并没有作硬性的规定。可以来自: 1. 文件系统中的zip或者jar文件 2. 网络、数据库 3. 运行期间生成的class文件

Java虚拟机规范并没有规定虚拟机去哪里加载类,于是实现方式由虚拟机实现者自定。通常的实现是:根据类路径来搜索类。通常分为三种类: 1. 启动类路径 默认对应jre/lib 2. 扩展类路径 默认对应jre/lib/ext 3. 用户类路径 默认当前目录

类路径接口表示: 将类路径对应的类读取到内存中。

type ZipEntry

type ZipEntry struct {
	// contains filtered or unexported fields
}

ZipEntry *

ZipEntry : ZIP或JAR文件形式的类路径
absPath: 存放ZIP或JAR文件的绝对路径

func (*ZipEntry) String

func (self *ZipEntry) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL