JavaRush /Java Blog /Random EN /In theory about bytecode, JVM and microcontrollers | Java...
Gro
Level 19
Минск

In theory about bytecode, JVM and microcontrollers | Java code for MK

Published in the Random EN group
Draft article. Ultimately, I will write several wiki-like articles, according to the following scheme:

Topic: Where and how Java works
- About the structure of Java
- About hardware
- How this software works on hardware

The article was about the problems that I encountered. Having studied the information, I supplemented it with answers.
It's a mixture of the topics above.

Hello!

Preface. (Offtopic)
I had and still have a growing desire to construct some kind of completely physical unit.
A unit based on one simple idea that completely absorbed me.
An idea that set the direction for my development for the next ten years.
In theory, the design of a device is already half-ready, implementing a tiny bit of the capabilities of that planned colossus.

Right now, when finalizing the semi-finished design, having immersed myself in the components in more detail, I was faced with the need to control servomotors and, accordingly, program some “brains”.

This is where a series of questions come in, which can be summarized in “Is it possible, and how, to force the MK to execute java code?”




Body. Details about the questions.
We remember that the java code that we write is converted into byte code, which, in turn, is interpreted by the JVM into machine code, code consisting of commands understood by hardware. Everyone understands the reason for this particular situation - portability/portability coupled with greater speed (compared to simply interpreted languages).

After I found out this, I had questions that remained unanswered, popped up and were supplemented with new ones now.
1. Is it possible, using standard JVM tools, to completely convert all byte code into machine code at once / Compile it?
if false.Are there third-party tools? At least somehow?

2. Does the JVM support microcontrollers/controllers? (I don’t know much about iron “brains”; if anyone knows, please tell me).
if true. Are there any differences/special features from working on our usual PCs?




Updated! 09.04
About 1. It is not possible to run the code to machine speed using a standard tool (meaning JVM), at least that’s what the wiki tells us , but from there it became clear that there is a third-party tool - GCJ . It is an alternative to the JVM and has such a nice bonus in its arsenal. I couldn’t find exact information about the platforms (hardware) for which compilation is supported - “many”.
The difference between byte-code and native-code:
1) native starts up faster
2) There are no guarantees that native will work faster
3) As I believe, native will not carry the OS and JVM, which significantly affects the amount required for operation of the ROM program .

Perhaps this solution can act as an alternative to the ME version .
(Hefty question, because:
1) It is not known whether GCJ supports such low-performance hardware platforms.
2) There is no information about the performance of this code.

Updated. 11.04
About 2. Any version of the Java language, be it ME, SE or Embedded, works in tandem with the JRE, being interpreted. Except for the case above and the two future ones described below.
Firstly, there were attempts to squeeze the OS out of the chain, replacing it with their own, exclusively Java-oriented tool. About what it is, here .
Secondly, it turned out that there are Java-oriented processors, their feature is a built-in coprocessor that interprets byte-code in hardware (! not in software) and sends it for execution.
Read more about Jazelle .
It's rich here .


Offtopic
The idea in question is “feedback”, a specifically implemented type in the future prototype - pressure/pressure resistance.
Take this opportunity to. Reading people of levels 15-25, let's create a small community for communication/tete-a-tete. For alone there is no guts at all, and even more - complete horror.

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION