`

What are bytecodes and how does the JVM handle them

阅读更多

    The JVM (Java Virtual Machine) has an instruction set just like a real machine. The name given to this instruction set is Java Bytecode. It is described in the Java Virtual Machine Specification . Other languages are translated into a bytecode before execution, for example ruby and python. Java's bytecode is at a fairly low level while python's is much more high level.

Interpretation and JIT compilation are two different strategies for executing bytecode. Interpretation processes bytecodes one at a time making the changes to the virtual machine state that are encoded in each instruction. JIT compilation translates the bytecode into instructions native to the host platform that carry out equivalent operations.

    Interpretation is generally quick to start but slow during execution, while JIT has more startup overhead but runs quicker afterwards. Modern JVMs use a combination of interpretation and JIT techniques to get the benefit of both. The bytecode is first interpreted while the JIT is translating it in the background. Once the JIT compilation is complete, the JVM switches to using that code instead of the interpreter. Sometimes JIT compilation can produce better results than the ahead-of-time compilation used for C and C++ because it is more dynamic. The JVM can keep track of how often code is called and what they typical paths through the code are and use this information to generate more efficient code while the program is running. The JVM can switch to this new code just like when it initially switches from the interpreter to the JIT code.

Just like there are other languages that compile to native code, like C, C++, Fortran; there are compilers for other languages that output JVM bytecode. One example is the scala language. I believe that groovy and jruby can also convert to java bytecode.

分享到:
评论

相关推荐

    jboss-javassist-javassist-rel_3_25_0_ga-2-g9076bde.zip

    it enables Java programs to define a new class at runtime and to modify a class file when the JVM loads it. Unlike other similar bytecode editors, Javassist provides two levels of API: source level ...

    'FrontEnd Plus' The GUI for the fast JAva Decompiler.

    which are created, by default, in the current directory. For example: jad -o -dtest -sjava *.class (or jad -o -d test -s java *.class, which has the same effect) This command decompiles all ....

    STAN: Towards Describing Bytecodes of Smart Contract.pdf

    以太坊智能合约字节码分析。 In Proc. of the 20th IEEE International Conference on Software Quality, Reliability and Security (QRS), 2020.

    Java反编译软件JAD1

    -a - annotate the output with JVM bytecodes -af - same as -a, but outputs fully qualified names when annotating; -clear - clears all prefixes, including the default ones (can be abbreviated as -cl)...

    java反编译工具jad 1.5.8g(可以反编译jdk1.5,1.6)

    List of the command-line options. <br>Jad accepts the following options: <br> -a - annotate the output with JVM bytecodes (default: off) -af - same as -a, but output fully qualified names ...

    Android代码-javassist

    programs to define a new class at runtime and to modify a class file when the JVM loads it. Unlike other similar bytecode editors, Javassist provides two levels of API: source level and bytecode level...

    javassist.zip

    Java bytecode engineering toolkit,Javassist version 3. Javassist (JAVA programming ... it enables Java programs to define a new class at runtime and to modify a class file when the JVM loads it.

    javassist.7z

    Java bytecode engineering toolkit,Javassist version 3. Javassist (JAVA programming ... it enables Java programs to define a new class at runtime and to modify a class file when the JVM loads it.

    java反编译工具FrontEnd和jad

    -a - annotate the output with JVM bytecodes (default: off) -af - same as -a, but output fully qualified names when annotating -clear - clear all prefixes, including the default ones (can be ...

    jad.exe+readme.txt

    -a - annotate the output with JVM bytecodes -af - same as -a, but output fully qualified names when annotating; -clear - clear all prefixes, including the default ones (can be abbreviated as -cl) ...

    monty:Monty ByteCodes文件的解释器

    "Monty"是一个开源项目,其核心是一个用于解释Monty ByteCodes的库,这是一种特定的字节码格式,类似于Java虚拟机(JVM)或Python的PVM中的字节码。这个项目用C语言编写,提供了高效且灵活的字节码解析能力。在深入...

    数独游戏 j2me 源代码

    4332002 bytecodes executed 6674 thread switches 1680 classes in the system (including system classes) 20240 dynamic objects allocated (676168 bytes) 24 garbage collections (556936 bytes collected) //...

    jlox_in_bytecodes:Jlox编译器以字节码实现

    jlox_in_bytecodes Jlox编译器以字节码实现我会在这里写一些笔记。字节码块

    Python Power - The Comprehensive Guide (2008).pdf

    What Is Python? ................................................................................................................1 A Brief History of Python ...............................................

    JAVA习题集(含答案).docx

    Java的Bytecodes是编译后的Java源代码所生成的中间代码,可以在Java虚拟机(JVM)上运行。最大优点是实现了“Write Once, Run Anywhere”(一次编写,到处运行)的跨平台特性。 5. **机器语言、高级语言和Java字节...

    Java内部培训课件.pdf

    这一特性源于Java的编译和解释机制:Java源代码首先被编译成与平台无关的字节码(Bytecodes),然后在Java虚拟机(JVM)上进行解释执行。 Java语言的设计理念强调了简单性、面向对象、分布性和安全性。它摒弃了C++...

    江苏省计算机软件项目Java开发员基础知识试题(模拟题)及答案.doc

    Java编译器将源代码编译成字节码(bytecodes),这是一种独立于具体硬件平台的中间表示,可以在任何支持JVM的系统上运行。 【Java开发工具】 Java开发工具主要包括Javac编译器,它用于将源代码编译成字节码;JDK...

    江苏省计算机软件项目Java开发员基础知识试题模拟题及答案.pdf

    Java编译器将源代码编译成字节码(Bytecodes),这是一种独立于平台的中间格式,使得Java程序可以在任何支持Java虚拟机(JVM)的系统上运行。 【Java开发工具】 Java开发涉及的常用命令包括: 1. `javac`:这是Java...

    \编译原理\编译原理课程讲义\java图.

    - **Java Virtual Machine (JVM)**:运行Java程序的核心组件,它为Java应用程序提供了一个统一的运行环境,无论底层硬件平台如何,都可以运行相同的字节码。 #### 四、字节码的移动 字节码文件可以很容易地在网络...

Global site tag (gtag.js) - Google Analytics