Will Jvm make compiled byte code into executable f

2019-07-17 02:19发布

I read the following articles:

http://searchcio-midmarket.techtarget.com/definition/just-in-time-compiler

http://javarevisited.blogspot.in/2011/12/jre-jvm-jdk-jit-in-java-programming.html

I am now really interested in knowing what will happen when I run a class. JIT compiles the byte code again and then ???

Will this compiled code be converted into an .exe by the JVM?

3条回答
成全新的幸福
2楼-- · 2019-07-17 02:45

No, the code is NOT "compiled" into an "exe"

the program is stored in memory as byte code, but the code segment currently running is preparatively compiled to physical machine code in order to run faster.

I'll go out on limb and say that JIT is a type of interpreter, designed to improve the speed of commonly used branches of code (at least that was my interpretation 10 years ago)

JIT compilers represent a hybrid approach, with translation occurring continuously, as with interpreters, but with caching of translated code to minimize performance degradation. It also offers other advantages over statically compiled code at development time, such as handling of late-bound data types and the ability to enforce security guarantees.

查看更多
虎瘦雄心在
3楼-- · 2019-07-17 02:46

Like the others said: JIT does not mean the code is compiled to a binary executable (.exe). However, an interesting application that you may consider is Excelsior JET.

I haven't read too much about it and haven't used it, so I don't know exactly how it works... yet. But according to its webpage, it's an AOT (Ahead-Of-Time) compiler. This means that it will compile your .class files to a system-dependent binary file.

You should give it a try, see how it performs. According to the website, you get a free license if your project is non-comercial in nature.

查看更多
一夜七次
4楼-- · 2019-07-17 02:46

Java Compiler compiles plain-text Java code into JVM bytecode. http://en.wikipedia.org/wiki/Java_bytecode

JVM has a HotSpot optimizer that evaluates the code for "Hot Spots" (basically, code that will be used the most) and pays special attention to those spots when using CPU cache. It may also flag those spots for the JVM to recompile to a native language (like Assembly) and this is called JIT.

JVM is essentially a virtual machine that runs a JVM bytecode interpreter.

There is never a direct .exe. It is a Windows/C/C++ thing, mostly.

查看更多
登录 后发表回答