关于java如何执行字节码有一个很好的参考?

时间:2021-08-28 16:53:43

I'm interested in how java organizes memory and executes code (like what gets put in the stack or the heap), from the start of main, to assigning variables, calling functions, passing parameters, returning values, instantiating objects, etc. Has anyone found a good, beginner-friendly article/reference on it? Preferably online, of course, but any suggestions or answers will be greatly appreciated. Thanks.

我感兴趣的是java如何组织内存并执行代码(比如放在堆栈或堆中的内容),从main的开头,分配变量,调用函数,传递参数,返回值,实例化对象等。有人发现了一篇好的,适合初学者的文章/参考文章吗?当然,最好是在线,但任何建议或答案将不胜感激。谢谢。

3 个解决方案

#1


3  

The canonical reference is the JVM spec. However, different JVMs can implement the spec in different ways. You can also check out the open source Java platform implementation, OpenJDK.

规范参考是JVM规范。但是,不同的JVM可以以不同的方式实现规范。您还可以查看开源Java平台实现OpenJDK。

#2


2  

Sun has a pretty good article on Java memory management on the web as a PDF: memorymanagement_whitepaper

Sun在网络上有一篇关于Java内存管理的文章,作为PDF:memorymanagement_whitepaper

#3


0  

I don't know exactly how they execute their bytecode, but I found this link describing java's bytecode. I am not sure if it helps, but at least it's something to start on.

我不确切知道他们如何执行他们的字节码,但我发现这个链接描述了java的字节码。我不确定它是否有帮助,但至少它是开始的东西。

Quote:

This article gives you an understanding of Java bytecode that will enable you to be a better programmer. Like a C or C++ compiler translates source code into assembler code, Java compilers translate Java source code into bytecode. Java programmers should take the time to understand what the bytecode is, how it works, and most importantly, what bytecode is being generated by the Java compiler. In some cases, the bytecode generated is not what you expect.

本文将帮助您了解Java字节码,使您成为更好的程序员。就像C或C ++编译器将源代码转换为汇编代码一样,Java编译器将Java源代码转换为字节码。 Java程序员应该花时间了解字节码是什么,它是如何工作的,最重要的是,Java编译器生成什么字节码。在某些情况下,生成的字节码不是您所期望的。

#1


3  

The canonical reference is the JVM spec. However, different JVMs can implement the spec in different ways. You can also check out the open source Java platform implementation, OpenJDK.

规范参考是JVM规范。但是,不同的JVM可以以不同的方式实现规范。您还可以查看开源Java平台实现OpenJDK。

#2


2  

Sun has a pretty good article on Java memory management on the web as a PDF: memorymanagement_whitepaper

Sun在网络上有一篇关于Java内存管理的文章,作为PDF:memorymanagement_whitepaper

#3


0  

I don't know exactly how they execute their bytecode, but I found this link describing java's bytecode. I am not sure if it helps, but at least it's something to start on.

我不确切知道他们如何执行他们的字节码,但我发现这个链接描述了java的字节码。我不确定它是否有帮助,但至少它是开始的东西。

Quote:

This article gives you an understanding of Java bytecode that will enable you to be a better programmer. Like a C or C++ compiler translates source code into assembler code, Java compilers translate Java source code into bytecode. Java programmers should take the time to understand what the bytecode is, how it works, and most importantly, what bytecode is being generated by the Java compiler. In some cases, the bytecode generated is not what you expect.

本文将帮助您了解Java字节码,使您成为更好的程序员。就像C或C ++编译器将源代码转换为汇编代码一样,Java编译器将Java源代码转换为字节码。 Java程序员应该花时间了解字节码是什么,它是如何工作的,最重要的是,Java编译器生成什么字节码。在某些情况下,生成的字节码不是您所期望的。