Questions tagged [jvm]

A Java virtual machine (JVM) is a virtual machine that can execute Java bytecode. It is the code execution component of the Java platform.

Filter by
Sorted by
Tagged with
67
votes
2answers
33k views

What is a “shaded” Java dependency?

JVM developer here. Lately I've seen banter on IRC chat rooms and even in my own office about so-called "shaded" Java libraries. The context of the use will be something like: "Such and so provides ...
53
votes
4answers
7k views

Are the development benefits of using Docker negated when using Java compared to other languages closer to Unix binaries?

I had a friend who said: Docker is amazing. You can use it to replicate production and all its quirks on your local machine. Then you can deploy that instance straight through all the staging ...
36
votes
8answers
11k views

What is the use of converting source code to Java bytecode?

If one needs different JVMs for different architectures I can't figure out what is the logic behind introducing this concept. In other languages we need different compilers for different machines, but ...
35
votes
4answers
9k views

What limitations does the JVM impose on tail-call optimization

Clojure does not perform tail call optimization on its own: when you have a tail recursive function and you want to have it optimized, you have to use the special form recur. Similarly, if you have ...
28
votes
5answers
11k views

If Scala runs on the JVM, how can Scala do things that Java seemingly cannot? [duplicate]

I just learned about Scala yesterday, and I'd like to learn more about it. One thing that came to mind, however, from reading the Scala website is that if Scala runs on the JVM, then how is it ...
27
votes
2answers
6k views

Is it *ever* okay to catch StackOverflowError in Java?

I used to think that it's not, but yesterday I had to do it. It's an application that uses Akka (an actor system implementation for the JVM) to process asynchronous jobs. One of the actors performs ...
18
votes
5answers
3k views

What makes JVM so much versatile to support so many JVM languages?

JVM supports so many languages other than Java like Groovy,Clojure,Scala etc which are functional languages unlike Java(I am referring to Java before Version 8 where Lambda's are not supported) that ...
17
votes
2answers
4k views

Java and JVM license

Does Java license allow other companies to create their own versions of Java language or just implement it accurately? Same question about JVM. I heard about Sun suing Microsoft for changing their ....
16
votes
1answer
3k views

How can Java be improved so that it no longer needs to perform type erasure?

The official Java tutorial on generics explains type erasure and why it was added to the compiler: When a generic type is instantiated, the compiler translates those types by a technique called ...
15
votes
4answers
8k views

Approaching Java/JVM internals [closed]

I've programmed in Java for about 8 years and I know the language quite well as a developer, but my goal is to deepen my knowledge of the internals. I've taken undergraduate courses in PL design, but ...
14
votes
3answers
27k views

When I create an object, is fresh memory allocated to both instance fields and methods or only to instance fields

I have a following class class Student{ int rollNumber; int marks; public void setResult(int rollNumber, int marks){ this.rollNumber=rollNumber; this.marks=marks; } public void ...
12
votes
4answers
6k views

How does the Java Virtual Machine execute code written in other languages?

Since Java 1.6 the JVM can run a myriad of programming languages on top of instead of just Java. I conceptually understand how Java is run on the Java VM, but not how other languages can run on it as ...
12
votes
1answer
8k views

Pattern matching in Clojure vs Scala

What are the key differences between pattern matching in these two languages? I am not referring to syntax, but capability, implementation details, range of use cases and necessity. Scala ...
11
votes
5answers
1k views

How is the JVM and Java's WORA different from other high level languages?

In the Java world, we often talk about the JVM, and when Java was new it had the supposedly killer feature of "Write Once, Run Anywhere." From the way people talk and write, this seems different from ...
10
votes
2answers
16k views

How does the JVM handle an exception thrown by the main method?

I understand exceptions, throwing them, handling them, and propagating them to a method lower in the call stack (i.e. throws). What I don't understand is this: public static void main(String[] args) ...
10
votes
3answers
2k views

How safe it is to do minor JVM upgrades?

I have been working on the JVM for years and I have very rarely experienced a JVM crash ... that is until approx 6 months ago. Since that I have experienced approximately 5 JVM crashes resulting ...
9
votes
8answers
2k views

What stops C from being compiled/interpreted/JIT'ed?

Java is often praised for its amazing portability, which I presume is because of the JVM. My question is what stops C from being being compiled/interpreted/JIT'ed.., if so, C can also be write once ...
9
votes
5answers
4k views

Is there a clear leader amongst JVM-based languages? [closed]

What is the current status of these projects, and has any one (or two) emerged as a clear leader? To demonstrate my motives for asking this question, cast your mind back several years. Prototype and ...
8
votes
3answers
5k views

Jython and JRuby vs. Groovy (and Java) [closed]

I am very interested in Python for programming on the JVM, and I've worked in Java and Ruby (not JRuby) a lot, and to a certain extent in Groovy. What are the limits to the Java-Jython and Java-JRuby ...
8
votes
2answers
2k views

Does current JIT optimize generated machine codes for branch prediction based on runtime statistics?

Some JVMs would compile Java byte code into native machine code. We know that there are lots of optimizations we could apply for that. Recently, I also learn that a branch operation may block the CPU ...
7
votes
5answers
674 views

Modern languages and the JVM [duplicate]

Many modern programming languages (Scala, Erlang, Clojure, etc.) are targeting the JVM. What are the main reasons behind that decision? JVM's maturity? Portability? Because JVM simply exists, and the ...
7
votes
2answers
3k views

How isolated are static variables?

If I have a public class SomeClass { public static final HashMap hashmap = new HashMap(); } and then I have five different classes with main(String[] args) methods, that I will run. when they ...
7
votes
3answers
570 views

How do I get feedback about whether escape analysis had any affect on my code or not?

One problem I have with compiler optimization is, that I actually never know what the compiler (or in this particular case the Jit) does with my code. So is there any possibility for me to know ...
7
votes
1answer
2k views

What the fastest way to pass large data between JVMs?

I have 2 JVMs on the same machine that I want to pass about 1Mb of (serializable) data between ideally in under 5 ms. Under load, using HTTP to localhost takes about 70ms average. I tried hazelcast, ...
6
votes
6answers
10k views

Is Java Bytecode interpreted? [closed]

The definition of interpretation (correct me if I'm wrong) is parsing code like so: 1- Translate currently parsed line to some intermediate language. 2- Run the translated line. 3- Move to the next ...
6
votes
4answers
3k views

What is the difference between instantiating and loading a class in Java?

In Java world, there are some scenarios where I see developers used to load the class rather than instantiation. What is the difference between instantiating and loading a class?
6
votes
1answer
273 views

What would be the market life of a JVM based software framework? [closed]

I saw how Struts 1 lasted from 2000 to 2013. I hear that people are moving from Struts 2 to Spring. But for a project that may need to be maintained for a decade or two, would it be advisable to opt ...
5
votes
4answers
814 views

How does Java improve over C++ in the area of portability?

I was reading through a Java book by author Herbert Schildt and he writes how the advantage of Java over C++ in portabilaty is that while C++ can be run anywhere, it still requires each program to be ...
5
votes
9answers
664 views

Is there any evidence that one of the current alternate JVM languages might catch on? [closed]

There's been a lot of enthusiasm about JRuby, Jython, Groovy, and now Scala and Clojure as the language to be the successor to Java on the JVM. But currently only Groovy and Scala are in the TIOBE ...
5
votes
2answers
653 views

Does sun.misc.Unsafe give access to the system or just the JVM?

Please note: Although this question involves microcontrollers, it is at its core, a Java question, and so I believe it can be answered by any battle-weary Java guru. I stumbled accross this blog ...
5
votes
2answers
499 views

How are Scala Traits implemented in the JVM?

I have been reading about traits in Scala. They are pretty amazing. I am curious how they extend a class without actually resulting in multiple inheritance. I know that the JVM doesn't support ...
4
votes
5answers
685 views

What prevents Java from achieving C-level portability?

Wherein portability is defined generally as the percentage of platforms a language or technology can run on, C/C++ are often cited as being more portable than Java, because a Java application depends ...
4
votes
5answers
1k views

Java heap space

In Java/JVM, why do we call the memory place where Java creates objects as "Heap"? Does it use the Heap Data Structure to create/remove/maintain the objects? As I read in the documentation of Heap ...
4
votes
3answers
348 views

Java Compiler and VM Compatibility

A co-worker and I recently had a discussion about Java versions and the JVM. I use Java 7 but we use Java 6 for our client (while he says that some are still on 5). My immediate thought was, why can't ...
4
votes
1answer
5k views

How to create own programming language based on JVM? [closed]

I am curious about how to create a programming language based on JVM so I have tried to get some info online, but the information I got are quite fragmented. What I found are mostly information ...
4
votes
2answers
569 views

Java Design Philosophy

I was reading through design philosophy of java and this line struck me: "The VM checks whether the signature of the Java code is valid and would refuse to interpret if any change of the code is ...
4
votes
1answer
2k views

Cross-compiling Java app to run directly on ARM

Please note: although I am using ARM SAM3X8E in this example, I'm just using that as a concrete example, and the answer to this question could easily be given using any other MCU such as AVR, etc. I ...
3
votes
5answers
995 views

What exactly is the Garbage Collector in Java?

I think I generally know what the Garbage Collector in Java does, but It's praised a lot, so I thought maybe I'm missing something about it's functionality. What I know is, that the GC takes care of ...
3
votes
3answers
947 views

Uses for System.gc() in Java [closed]

In Java, there is a method called System.gc(), which calls the garbage collector (or rather, "suggests" to the JVM to run the GC). Are there valid reasons to call this method? I'm thinking that it ...
3
votes
2answers
3k views

Difference between PyPy and JVM

From my understanding the default Python interpreter(CPython) compiles source code into bytecode and then interprets the bytecode into machine code. PyPy on the other hand makes use of JIT to optimize ...
3
votes
4answers
2k views

Is it possible to have a single code base for a desktop GUI and a web application?

The required user interface is fairly simple; basically, two tables that "interact with each other", e.g. certain rows in one table get highlighted when a row in the other is clicked, plus maybe a ...
3
votes
2answers
307 views

What is the advantage of a programmers VM apart from portability [duplicate]

I can understand the benefits of Java running on a JVM. Portability. Nice simple reason. But I have always been puzzled as to why Microsoft brought out their own version of a JVM - .NET. C# is ...
3
votes
4answers
2k views

Static methods on a web context

What happens when concurrent requests call the same static Java method running on an application server? Say that a method run takes 2 seconds and receives 100 calls in a given second. The method ...
3
votes
2answers
842 views

How to devise instruction set of a stack based machine?

Stack based virtual machines like CLR and JVM has different set of instructions. Is there any theory behind devising the instruction set while creating a virtual machine? e.g. there are JVM ...
3
votes
2answers
2k views

Converting ANTLR AST to Java bytecode using ASM

I am currently trying to write my own compiler, targeting the JVM. I have completed the parsing step using Java classes generated by ANTLR, and have an AST of the source code to work from (An ANTLR "...
3
votes
1answer
404 views

Why is the Java bytecode instruction set not orthogonal?

Section 2.11.1 of the JVM 8 Specification includes the words: In other words, the instruction set is intentionally not orthogonal. From my perspective, that implies that the Java bytecode ...
3
votes
1answer
1k views

Does the JVM's Garbage Collector clean the entire JVM HotSpot memory (C-Heap, Java Heap and Permanent Generation space) or just Java Heap?

I know that the JVM has some JVM HotSpot memory which is further divided into three areas: Java Heap Permanent Generation Space Native Heap (C-Heap) I know that Java has automatic garbage collection ...
3
votes
1answer
172 views

What is richochet frames based hotspot jvm?

In order to implement JSR 292, a.k.a. invoke dynamic, something called richochet frames is introduced into the hotspot vm. I'd like to know more about it, such as invoke dynamic itself, how richochet ...
3
votes
1answer
208 views

what happens at Java interpreter level when IncompatibleClassChangeError is thrown?

I am a noob at JVM internals. Can someone explain what happens at Java interpreter level when IncompatibleClassChangeError is thrown? I am facing an issue similar to the one described here: https:...
2
votes
3answers
2k views

Different types of heap in java

I was faced with this question recently for the different types of heap memory available in Java. I couldn't find much information online. Are there different types of heap memory available in Java ?...