尚硅谷宋红康JVM 第1章:JVM与Java体系结构

具体视频和资料请关注尚硅谷官方公众号获取
课程主要分为4部分(目前只出到第一部分)
在这里插入图片描述
课程大纲
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第1张图片

尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第2张图片

尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第3张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第4张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第5张图片

尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第6张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第7张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第8张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第9张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第10张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第11张图片

尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第12张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第13张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第14张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第15张图片

package com.atguigu.java;

/**
 * @author shkstart
 * @create 2020 下午 12:11
 */
public class StackStruTest {
    public static void main(String[] args) {
        int i = 2 + 3;
    }
}

执行 javap -v StackStruTest.class

Classfile /D:/BaiduNetdiskDownload/尚硅谷_宋红康_JVM从入门到精通/代码/JVMDemo/out/production/chapter01/com/atguigu/java/StackStruTest.class
  Last modified 2020-7-31; size 440 bytes
  MD5 checksum 0099e80382db5ed25c2a29aa25e14956
  Compiled from "StackStruTest.java"
public class com.atguigu.java.StackStruTest
  minor version: 0
  major version: 52
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #3.#19         // java/lang/Object."":()V
   #2 = Class              #20            // com/atguigu/java/StackStruTest
   #3 = Class              #21            // java/lang/Object
   #4 = Utf8               
   #5 = Utf8               ()V
   #6 = Utf8               Code
   #7 = Utf8               LineNumberTable
   #8 = Utf8               LocalVariableTable
   #9 = Utf8               this
  #10 = Utf8               Lcom/atguigu/java/StackStruTest;
  #11 = Utf8               main
  #12 = Utf8               ([Ljava/lang/String;)V
  #13 = Utf8               args
  #14 = Utf8               [Ljava/lang/String;
  #15 = Utf8               i
  #16 = Utf8               I
  #17 = Utf8               SourceFile
  #18 = Utf8               StackStruTest.java
  #19 = NameAndType        #4:#5          // "":()V
  #20 = Utf8               com/atguigu/java/StackStruTest
  #21 = Utf8               java/lang/Object
{
  public com.atguigu.java.StackStruTest();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."":()V
         4: return
      LineNumberTable:
        line 7: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/atguigu/java/StackStruTest;

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=1, locals=2, args_size=1
         0: iconst_5
         1: istore_1
         2: return
      LineNumberTable:
        line 9: 0
        line 10: 2
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       3     0  args   [Ljava/lang/String;
            2       1     1     i   I
}
SourceFile: "StackStruTest.java"

修改代码后

package com.atguigu.java;

/**
 * @author shkstart
 * @create 2020 下午 12:11
 */
public class StackStruTest {
    public static void main(String[] args) {
        int i = 2;
        int j = 3;
        int k = i + j;
    }
}

再次执行javap -v StackStruTest.class

Classfile /D:/BaiduNetdiskDownload/尚硅谷_宋红康_JVM从入门到精通/代码/JVMDemo/out/production/chapter01/com/atguigu/java/StackStruTest.class
  Last modified 2020-7-31; size 482 bytes
  MD5 checksum 1989f156fbbc17191ea2ed9e03011bf7
  Compiled from "StackStruTest.java"
public class com.atguigu.java.StackStruTest
  minor version: 0
  major version: 52
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #3.#21         // java/lang/Object."":()V
   #2 = Class              #22            // com/atguigu/java/StackStruTest
   #3 = Class              #23            // java/lang/Object
   #4 = Utf8               
   #5 = Utf8               ()V
   #6 = Utf8               Code
   #7 = Utf8               LineNumberTable
   #8 = Utf8               LocalVariableTable
   #9 = Utf8               this
  #10 = Utf8               Lcom/atguigu/java/StackStruTest;
  #11 = Utf8               main
  #12 = Utf8               ([Ljava/lang/String;)V
  #13 = Utf8               args
  #14 = Utf8               [Ljava/lang/String;
  #15 = Utf8               i
  #16 = Utf8               I
  #17 = Utf8               j
  #18 = Utf8               k
  #19 = Utf8               SourceFile
  #20 = Utf8               StackStruTest.java
  #21 = NameAndType        #4:#5          // "":()V
  #22 = Utf8               com/atguigu/java/StackStruTest
  #23 = Utf8               java/lang/Object
{
  public com.atguigu.java.StackStruTest();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."":()V
         4: return
      LineNumberTable:
        line 7: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/atguigu/java/StackStruTest;

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=4, args_size=1
         0: iconst_2
         1: istore_1
         2: iconst_3
         3: istore_2
         4: iload_1
         5: iload_2
         6: iadd
         7: istore_3
         8: return
      LineNumberTable:
        line 9: 0
        line 10: 2
        line 11: 4
        line 12: 8
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       9     0  args   [Ljava/lang/String;
            2       7     1     i   I
            4       5     2     j   I
            8       1     3     k   I
}
SourceFile: "StackStruTest.java"

为什么不将架构更换为基于寄存器的架构呢?
基于栈的架构在实现上更简单,其次在非资源受限的场景中也是可以用的。
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第16张图片
尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第17张图片

package com.atguigu.java;

/**
 * @author shkstart
 * @create 2020 下午 12:11
 */
public class StackStruTest {
    public static void main(String[] args) {
        //int i = 2 + 3;
        int i = 2;
        int j = 3;
        int k = i + j;

        try {
            Thread.sleep(6000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        System.out.println("hello");
    }
}

尚硅谷宋红康JVM 第1章:JVM与Java体系结构_第18张图片
5296 StackStruTest 在打印出hello后就会发现该进程已经没有了,此时jvm就已经退出了

你可能感兴趣的:(java基础,java)