JVM读书笔记1

java体系结构:

1、JAVA编程语言

2、java class文件格式

3、JAVA API

4、JAVA JVM


JVM:execution engine + class loader


 两种class loader :

1、primordial class loader ( part of jvm)

2、class loader object 

classes can by default only see other classes that were loaded by the same class loader.This is how Java architecture enables you to create multiplename-spaces inside asingle Java application.


不能将程序正确性依赖于:

1、finalization

2、threadprioritization

因为各个JVM实现者对于两者的具体实现有所区别


JAVA的安全模型:沙盒模型(sandbox model)

阻止以下行为:

1、读写本地硬盘

2、与applet来源地之外的地址进行网络连接

3、创建新进程

4、装载新的动态库直接调用本地方法


sandbox模型的核心成分:

1、class loader architecture

2、class file verifier

3、JVM自带的safety features

4、java api的security manager


一个class loader 必须被给予一个限制和禁止的包列表:

1、限制的;如果primordial class loader找不到 则抛出安全异常(说明申请的类在信任的源中找不到,则必然是cracker伪造的并且希望class loader通过其他途径获得的,一旦获得,那么这个类对于其所属的包的类有访问权限,产生危害)

2、禁止的:如果class loader申请这个包中的类,直接抛出安全异常


class file verifier:

phase1:checkinternal structure(语法,长度等)装载时(loading)

phase2:check symbolic references 执行时 属于dynamic linking的一部分

dynamic linking:

When onetype refers to another type, the virtual machine requests the referenced typefrom the same class loader that loaded the referencing type.


JVM's safety features before class verifier phase 2:

type-safe reference casting

       structured memory access

       automatic garbage collection

       array bounds checking

       checking references for null


security manager:

检查哪些potentially unsafe的行为,通常是一个list

two actions are not in the list but unsafe:

              allocating memory until it runs out

              firing off threads until everything slows to a crawl

当违反时 会导致 denial of service.


在class file中所有指令都是一个字节,只有2个例外指令(在操作符与操作数之间有padding

) 这样使得class file compact and small


编译器对于class file不做优化 这个任务被交给JVM


JVM:runtime instance vs. abstract

runtime instance:

eachjava application runs inside a runtime instance of some concrete implementationof the abstract specification of the JVM.

abstract:

subsystem:classloader(loading,linking,initizlizing),execute engine

       memory area

       data type

       instruction


JVM的经典图示:


Each JVM instancehas a method area and a heap

method area:存放class data 注意 只要是关于类的信息都在这里(并不是方法区)

类名,超类名,class还是interface,访问符,实现的接口列表,常量池,field信息,method信息,static属性,static方法,指向类class loader的引用,指向类class的引用


常量池(constant pool)指的是在编译期被确定,并被保存在已编译的.class文件中的一些数据。它包括了关于类、方法、接口等中的常量,也包括字符串常量。


heap:存放object


Java stack:a method 对应a stack frame

JVM没有寄存器,使用java stack来存放intermediate data value(中间数据)


java stack图示:



CLASSPATH is used for primordial class loader to load trusted classes.(原来classpath环境变量的作用是这个)


final static的类属性供所有类使用

static(non-final)的类属性供声明其的类使用


Garbage collector:

1.             reclaimthe memory used by objects that are nolonger referenced by the runningapplication.

2.             Moveobjects to reduce heap fragmentation.


Every class inherits from Objectthree "wait methods" (overloaded forms of a method named wait())and two "notify methods" (notify() and notifyAll()).


array的实现图示:



Other than PC,java has no registers.The jvmis stack-based rather thanregister-based.


Execution engine:

A runtime instance of an execution engineis a thread


class file 大致格式:




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值