jvm

How is the Object class implemented (methods like hashCode and internal fields)?

北城余情 提交于 2021-01-21 07:19:13
问题 I am curious how is the Object class implemented. For example a method hashCode() or wait() How is the internal state represented. For instance, an instrinsic lock or the data structure for storing threads that called object's wait(). In order to find these out, I have downloaded a source of OpenJDK and started to dig in. First thing, I came across was \openjdksrc\jdk\src\share\native\java\lang\Object.c file, containing, among others: static JNINativeMethod methods[] = { {"hashCode", "()I",

How is the Object class implemented (methods like hashCode and internal fields)?

纵饮孤独 提交于 2021-01-21 07:18:12
问题 I am curious how is the Object class implemented. For example a method hashCode() or wait() How is the internal state represented. For instance, an instrinsic lock or the data structure for storing threads that called object's wait(). In order to find these out, I have downloaded a source of OpenJDK and started to dig in. First thing, I came across was \openjdksrc\jdk\src\share\native\java\lang\Object.c file, containing, among others: static JNINativeMethod methods[] = { {"hashCode", "()I",

Confusion about the size of references in the JVM spec

核能气质少年 提交于 2021-01-20 07:51:44
问题 The JVM spec states that references only take up one local variable slot( jvms12 2.6.1). Additionally it states that double and long , take up two local variable slots because they are 64-bit. Does this mean that all JVM compliant implementations must use 32-bit addressing? How do 64-bit JVMs handle this? Do they use 64 bit local variable slots, or do they use 2 slots for references? 回答1: Does this mean that all JVM compliant implementations must use 32-bit addressing? How do 64-bit JVMs

Confusion about the size of references in the JVM spec

三世轮回 提交于 2021-01-20 07:51:11
问题 The JVM spec states that references only take up one local variable slot( jvms12 2.6.1). Additionally it states that double and long , take up two local variable slots because they are 64-bit. Does this mean that all JVM compliant implementations must use 32-bit addressing? How do 64-bit JVMs handle this? Do they use 64 bit local variable slots, or do they use 2 slots for references? 回答1: Does this mean that all JVM compliant implementations must use 32-bit addressing? How do 64-bit JVMs

Confusion about the size of references in the JVM spec

末鹿安然 提交于 2021-01-20 07:49:34
问题 The JVM spec states that references only take up one local variable slot( jvms12 2.6.1). Additionally it states that double and long , take up two local variable slots because they are 64-bit. Does this mean that all JVM compliant implementations must use 32-bit addressing? How do 64-bit JVMs handle this? Do they use 64 bit local variable slots, or do they use 2 slots for references? 回答1: Does this mean that all JVM compliant implementations must use 32-bit addressing? How do 64-bit JVMs

Kotlin Init Block in Super class firing with null properties when inheriting from it

点点圈 提交于 2021-01-19 03:07:47
问题 open class Super { open var name : String = "Name1" init { println("INIT block fired with : $name") name = name.toUpperCase() println(name) } } class SubClass(newName : String) : Super() { override var name : String = "Mr. $newName" } fun main(args: Array<String>) { var obj = SubClass("John") println(obj.name) } The above Kotlin code results in the following TypeCastException : INIT block fired with : null Exception in thread "main" kotlin.TypeCastException: null cannot be cast to non-null

Kotlin Init Block in Super class firing with null properties when inheriting from it

有些话、适合烂在心里 提交于 2021-01-19 03:06:59
问题 open class Super { open var name : String = "Name1" init { println("INIT block fired with : $name") name = name.toUpperCase() println(name) } } class SubClass(newName : String) : Super() { override var name : String = "Mr. $newName" } fun main(args: Array<String>) { var obj = SubClass("John") println(obj.name) } The above Kotlin code results in the following TypeCastException : INIT block fired with : null Exception in thread "main" kotlin.TypeCastException: null cannot be cast to non-null

JVM垃圾回收算法

本小妞迷上赌 提交于 2021-01-08 20:00:12
垃圾回收算法有:标记清除算法,标记整理算法,复制算法,分代收集算法。 1.标记-清除算法:先利用可达性分析算法,标记出存活的对象。标记完之后,再扫描整个空间中未被标记的对象进行回收。 缺点:效率低,会造成大量碎片。 2.标记-整理算法:在标记-清除算法的基础上,让所有存活的对象向左移动,并更新对应的指针。适用于对象存活率高的,比如老年代。 3.复制算法:复制算法将空间分为两部分,每次使用其中的一部分。当一块内存用完了,就将这一块所有存活对象复制到另一块,将已使用的块清除。不会产生碎片,但会浪费一定的内存空间。在堆中的年轻代使用该算法,因为年轻代多为生命周期较短的对象。年轻代将内存分为一个Eden, 两个Suvivor, 一个Survivor0,一个Survivor1。首先使用Eden, 当Eden内存占满时将存活对象复制到Survivor0,同时清空Eden。当Suvivor0内存也满时,就复制Eden和Suvivor0的存活对象到suvivor1,然后清空Eden和Suvivor0。然后互换Suvivor0和Suvivor1的角色,保持Suvivor1为空。当Suvivor1放不下Suvivor0和Eden的存活对象时,则需要老年代的空间担保。 4.分代收集算法:根据新生代,老年代的特点采用不同的算法。新生代对象的存活周期较短,所以采用复制算法。老年代对象存活周期较长

Cassandra start error with ThreadPriorityPolicy=42

橙三吉。 提交于 2021-01-03 04:34:09
问题 When I am trying to start Cassandra it shows me error like this I already did changes in the conf file also in env.sh, the file also. No options of similar type error is working for this. intx ThreadPriorityPolicy=42 is outside the allowed range [ 0 ... 1 ] Improperly specified VM option 'ThreadPriorityPolicy=42' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Other Information java version "9.0.4" Java(TM) SE Runtime Environment

Cassandra start error with ThreadPriorityPolicy=42

谁说胖子不能爱 提交于 2021-01-03 04:30:50
问题 When I am trying to start Cassandra it shows me error like this I already did changes in the conf file also in env.sh, the file also. No options of similar type error is working for this. intx ThreadPriorityPolicy=42 is outside the allowed range [ 0 ... 1 ] Improperly specified VM option 'ThreadPriorityPolicy=42' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Other Information java version "9.0.4" Java(TM) SE Runtime Environment