欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Java沙箱(Java SandBox)[4],

来源: javaer 分享于  点击 14804 次 点评:21

Java沙箱(Java SandBox)[4],


原文:

Safety features built into the JVM

Several built-in security mechanisms are operating as Java virtual machine bytecodes. You have likely heard these mechanisms listed as features of the Java programming language that make Java programs robust. They are, not surprisingly, also features of the Java virtual machine. The mechanisms are:

Type-safe reference casting
Structured memory access (no pointer arithmetic)
Automatic garbage collection (can't explicitly free allocated memory)
Array bounds checking
Checking references for null

Whenever you use an object reference, the JVM watches over you. If you attempt to cast a reference to a different type, the JVM makes sure the cast is valid. If you access an array, the JVM ensures the element you are requesting actually exists within the bounds of the array. If you ever try and use a null reference, the JVM throws an exception.

一些内建的安全机制以JVM字节码为依托在起作用。
你可能已经听说过这些让java程序具有健壮性的被列为java语言特征的机制。
不要惊讶,它们同样是JVM的的特征。这些机制是:
1、类型安全引用转换
2、结构化存储器存取(非指针算法)
3、垃圾自动回收(不能显示释放已分配的内存)
4、数组边界检查
5、空引用检查
无论什么时候使用一个对象的引用,java虚拟机都会对其进行监视。如果你企图将一个引用转换成一个不同的类型,java虚拟机会首先确保转换是否合法。如果你访问一个数组,java虚拟机会确保你需要的的元素确实存在于数组的边界之内,如果你试着使用一个空引用,java虚拟机将会抛出异常。

<望广大同行朋友批评指正,不胜感激>

相关文章

    暂无相关文章
相关栏目:

用户点评