Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which low level tasks can be accomplished on the JVM, but not expressed in java?

Tags:

java

bytecode

Which useful (for performance or otherwise) constructions are valid bytecode, but not expressable in Java?

like image 616
mike g Avatar asked Mar 09 '10 03:03

mike g


People also ask

What are the various main tasks performed by the JVM to run the Java program?

It performs three major functions viz. Loading, Linking, and Initialization. JVM Method Area stores class structures like metadata, the constant runtime pool, and the code for methods. All the Objects, their related instance variables, and arrays are stored in the heap.

What is JVM What are tasks perform by it?

The JVM has two primary functions: to allow Java programs to run on any device or operating system (known as the "Write once, run anywhere" principle), and to manage and optimize program memory.

What are the 3 components of JVM?

The JVM consists of three distinct components: Class Loader. Runtime Memory/Data Area. Execution Engine.

Which is not a part of JVM?

As javac is a compiler for JVM, it is not a part of it.


3 Answers

  1. You can throw any object, not just exception.
  2. You can overload on return type.
  3. You can throw any exception without declaring it in throws.
like image 134
Jevgeni Kabanov Avatar answered Nov 15 '22 17:11

Jevgeni Kabanov


JVM bytecode is a stack-oriented programming language, so most of the stack management instructions don't make sense in Java, e.g. dup, swap, etc. Arbitrary goto, of course, is also not expressible in Java.

Something like JSR 292 proposes support for dynamically typed languages, which I don't think Java is planning to become.

I think something needs to be addressed here, though: your question seems to be at least partially motivated by the issue of performance. In practice, bytecodes are JIT-compiled to assembly. Whether or not there's a super magical bytecode instruction is really quite moot.

like image 43
polygenelubricants Avatar answered Nov 15 '22 19:11

polygenelubricants


I have read that the bytecode method signatures support multiple dispatch on return types, whereas Java only allows for methods of the same name to dispatch on parameter types.

like image 37
Thilo Avatar answered Nov 15 '22 17:11

Thilo