Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the compilation techniques related to Java

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the compilation technology related to Java, which is very detailed and has a certain reference value. Friends who are interested must read it!

JIT compiler

The traditional Java virtual machine is very stupid. After translating a bytecode instruction into machine code, the machine code is executed immediately. After executing the machine code, the machine code is lost, and then the next bytecode instruction is translated and goes on. Even if the bytecode instructions that have been executed before are executed next time, they still have to be re-translated into machine code before they can be executed, so the efficiency is certainly not good.

Virtual machines that use JIT compiler (Just-In-Time compiler) technology are smarter and will first translate the parts that are often executed into memory for the first time, and then when they are executed here again, they will no longer have to translate and just take the machine code out of memory to execute. In this way, as long as you have enough memory and the technology of the JIT compiler is good enough, your Java bytecode execution speed can be close to that of a purely compiled program.

Compilers of other programming languages

Any file can be executed by a Java virtual machine as long as it conforms to the Java bytecode format. There are many ways to create a Java bytecode, and you don't have to write a program in the Java language in order to compile into Java bytecode. Java is both a language and a platform, and you can use the Java platform (that is, the Java virtual machine) instead of using the Java language (that is, the Java compiler). As long as a language provides a compiler that can compile the source code of the language into Java bytecode format, it can be executed on the Java platform.

As far as I know, the following languages already provide compilers (in English alphabetical order) that are compatible with the Java platform: Aardappel,Ada,Agora 98, BAMBOO, the BasicMagic, the BistroGradup, the Bistropjack, the C, the, the? Sather,Scheme,SELF,Simkin,Small Talk,Tcl,WebL,Yassl,Yoix,Yoyo .

Native compiler

If you don't care whether Java programs can be cross-platform or not, and you want Java programs to be compiled into machine code instead of Java bytecode, just like CumberCure +, you can use the Java native compiler (native compiler). At present, there are many such products can be used.

There are two types of Java native compilers, one can compile Java source code into machine code, and the other can compile Java bytecode into machine code.

Decompiler and obfuscator

Java bytecode is easily decompiled (de-compilation) because of its simple file format, complete information, and instructions that are the simplest stack-based architecture. Decompilation is the opposite of compilation. For Java, decompilation is the process of converting Java bytecode into Java source code.

To prevent your painstaking development of Java bytecode from being decompiled into source code by others, you can convert your Java bytecode into more confusing Java bytecode through an obfuscator, with the same effect, but confused Java bytecode is less likely to be decompiled. You usually have to pay a price for this, because confused programs usually run slower. And the obfuscator can only increase the difficulty of decompilation, there is no guarantee that your program will not be decompiled successfully. After all, as virtue rises one foot, vice rises ten, if someone is willing to spend a lot of time and energy decompiling your Java bytecode, you can't stop it at all.

Group translation and anti-group translation

Assembly language (assembly) is a language that is very close to machine code. The tool that converts assembly language to machine code is called assembler, and the tool that converts machine code into assembly language in turn is called dissembler.

For Java virtual machines, Java bytecode is like its machine code. Is there a language that is very close to Java bytecode? In other words, does Java have an assembly language? Basically, Sun does not define the standard assembly language for Java, but some people define their own Java assembly language and provide a group translator (or even anti-group translator) for Java. For example, Jasmin and javaa are Java group interpreters.

Preprocessor

The pre-processor (pre-processor), also known as the pre-compiler (pre-compiler) or pre-translator (pre-translator), aims to convert the part of the source code that does not conform to the language specification into a form that conforms to the language specification. For example, we may use custom syntax in addition to the Java language in the Java source code. These custom grammars cannot be processed by the Java compiler, so we must first convert part of the custom syntax into Java through a preprocessor, which can then be processed by the Java compiler.

At present, many Java pre-processors, such as iContract and SQLJ, are used to extend the Java language.

Optimal tool software

Generally speaking, there are two kinds of optimization:

1. Reducing the size of files can save storage space and speed up network transmission.

two。 Make the execution faster.

For Java, there is a third optimization:

3. Make the program structure chaotic, not easily decompiled. That is, the obfuscation mentioned earlier.

These three purposes often crowd out each other: structural chaos usually slows down the program and becomes larger; smaller volume usually slows down and the structure becomes neat; and faster, it usually makes the volume larger and the structure neat.

These are all the contents of this article entitled "what are the compilation techniques related to Java?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report