Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
0 votes
1 answer
254 views

Java: Is there a performance difference between variable assignment vs. inline usage?

Is there any performance detriment to assigning variables vs using them inline. I'm guessing this WOULD be worse if a method was returning primitive and I was 'boxing' it (e.g. method returning int, ...
user avatar
  • 287
-1 votes
2 answers
184 views

How to access version of a Java application programmatically when running from an IDE?

As far as I understand, the best practice for programmatic access to the version of a Java application is to: Specify version via build system (e.g. in Gradle). Include the version string as a ...
user avatar
  • 113
0 votes
1 answer
70 views

Interactive and Batch traffic in one service [closed]

I am designing a workflow, and am trying to avoid parallel deployments of the same service. Thus I am looking to have one service that handles both interactive and batch traffic. My main concern is ...
user avatar
  • 109
1 vote
4 answers
602 views

Does the JVM compile bytecode into machine code and run it or does it just run bytecode directly?

Java source code is compiled into bytecode for the JVM. But, how does JVM convert bytecode into machine code? Does it re-compile bytecode into machine code and then run it? Or does it simply just run ...
user avatar
  • 139
0 votes
2 answers
918 views

Why are some languages called platform dependent if I can always share the source code?

I was reading about erlang when I read that it is platform-independent, using BEAM as the VM, now I understand that a VM compiles the byte code to machine code and this makes that language machine-...
user avatar
  • 129
49 votes
4 answers
8k views

Why are there multiple different implementations of JVM?

While going over a java book I came across this phrase: Different JVMs can run threads in profoundly different ways. While it's completely understandable to me that code can behave differently ...
user avatar
  • 607
8 votes
1 answer
232 views

To show the difference between system VMs and JVMs

I am trying to draw diagrams that show the difference between system virtual machines and Java virtual machines. The first two images looks correct to me. But I don't know how to draw the third. ...
user avatar
0 votes
1 answer
135 views

Do I have do use HashTables/Maps/Hashmaps in this algorithm?

I am doing the Ransom Note algorithm in Hackerrank. The thing is I am not using maps and all the tests pass except for three which execution time takes a lot more. (Kotlin language) I have two ...
user avatar
1 vote
1 answer
440 views

Are JVM thread dumps a security concern?

When building parallelized applications using Java, a developer sometimes finds himself with a thread being blocked indefinitely because of a four-year-old bug in the spring-bean-web-rest-foo-bar-...
user avatar
2 votes
3 answers
2k views

Can Java applications run on phones (at least android) AND Windows?

Hi all I love stackoverflow so helpful. Afaik IOS has some security measures that dont let other apps (such as jvm) execute code from your app. Not sure how much this is true. But anyway, I heard ...
user avatar
-2 votes
2 answers
588 views

Converting Java code run by dependency to native code

Is it, at least theoretically, possible to convert a Java application into native code that can be run by something else written in Java? One example of this could be a Minecraft Spigot server. You ...
user avatar
  • 3
4 votes
5 answers
954 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 ...
user avatar
  • 13.2k
-2 votes
1 answer
201 views

How's .NET multi-platform approach different than Java's back in the days? [closed]

TL;DR How is the new .NET approach to being a multi platform framework better than what Java did long ago? What are the key differences in the implementation? What are the advantages and ...
user avatar
  • 107
55 votes
4 answers
8k 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 ...
user avatar
  • 4,761
3 votes
3 answers
3k 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 ?...
user avatar
  • 141
37 votes
8 answers
12k 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 ...
user avatar
7 votes
1 answer
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, ...
user avatar
  • 1,836
5 votes
4 answers
977 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 ...
user avatar
  • 1,529
1 vote
0 answers
79 views

How is memory modeled in projects like Apache Spark or Druid?

In the past couple of months I've worked with both Apache Spark and Druid for some projects. As I've gone through the process of learning how to use these tools, I've spent some time reading through ...
user avatar
  • 151
4 votes
2 answers
713 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 ...
user avatar
-3 votes
3 answers
1k views

Beginner: Can Java source code be executed by Java Virtual Machine? Or not directly?

Im in my first week of college majoring in computer science. Can java source code be directly executed by JVM?
user avatar
1 vote
1 answer
2k views

What did James Gosling mean when told that C# is Java with no reliability, productivity and security? [closed]

Gosling said that "[C# is] sort of Java with reliability, productivity and security deleted." (from Wikipedia)
user avatar
  • 149
2 votes
2 answers
2k views

How do Virtual Machines allocate memory?

If I want to allocate a struct in C, #include<stdio.h> typedef struct container { int i; } Container; int main() { Container *ptr_to_container; ptr_to_container = (Container *) ...
user avatar
  • 131
-1 votes
1 answer
87 views

JVM run-configuration launcher for production?

Does anyone know if there is such a thing as a run-configuration launcher for the JVM for "production"? Where you can set environment variables and arguments, just like in an IDE ?
user avatar
  • 267
3 votes
1 answer
232 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:...
user avatar
12 votes
2 answers
5k 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 ...
user avatar
  • 267
130 votes
2 answers
69k 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 ...
user avatar
  • 4,640
1 vote
1 answer
282 views

Send signal to a scala process

I have a cron job running that is a Scala application. I want another job, that runs forever, to do something when this one finishes. It seems to me some kind of signal (Unix/Linux signal?) has to be ...
user avatar
9 votes
8 answers
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 ...
user avatar
4 votes
2 answers
5k 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 ...
user avatar
4 votes
1 answer
567 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 ...
user avatar
  • 143
5 votes
2 answers
725 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 ...
user avatar
  • 4,640
2 votes
1 answer
2k views

Changing the Garbage Collector on your JVM [closed]

My understanding is that the JVM specification only defines the behavior of a garbage collector, but does not provide implementation details. This means it is up to the JVM implementation to build the ...
user avatar
  • 4,640
5 votes
1 answer
3k 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 ...
user avatar
  • 4,640
33 votes
5 answers
13k 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 ...
user avatar
  • 1,027
0 votes
1 answer
999 views

How is ServletContext created?

When the webapp gets loaded the container will create the ServletContext. There is only one ServletContext per webapp per JVM. The ServletContext object is contained within the ServletConfig object ...
user avatar
  • 1
3 votes
1 answer
2k 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 ...
user avatar
2 votes
1 answer
385 views

Is the JVM "heap" inside the JVM software, or inside the physical computer?

I wanted to as this question about VMs in general, but focused it to JVM implementations only so this doesn't get closed as too broad. The JVM has a concept of a "heap". If my understanding is ...
user avatar
  • 20.7k
1 vote
1 answer
1k views

JVM memory and zero-copy (de)serialization

I am trying to understand the JVM memory model. In particular, I would like to understand whether it would be feasible to have zero-copy (de)serialization libraries, such as Cap'n Proto or FlatBuffers....
user avatar
  • 5,305
11 votes
2 answers
18k 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) ...
user avatar
  • 20.7k
15 votes
3 answers
33k 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 ...
user avatar
  • 629
3 votes
3 answers
1k 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 ...
user avatar
  • 157
3 votes
4 answers
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 ...
user avatar
  • 41
0 votes
1 answer
391 views

Should we push for more JavaScript on the JVM, alongside Java and Scala? Or, if not, why? [closed]

With JavaScript becoming one of the most widely used languages around, I began asking myself why people do not find ways to use it extensively on the JVM. As a programmer who spends half day writing ...
user avatar
12 votes
1 answer
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 ...
user avatar
  • 290
1 vote
2 answers
655 views

Is it possible to implement a native compiler for a 'managed language' such as Java?

In most cases, it is possible to create both a native compiler and an interpreter for a programming language. The compiler would simply convert the source code to machine code, and the interpreter ...
user avatar
  • 20.7k
6 votes
6 answers
11k 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 ...
user avatar
  • 181
3 votes
5 answers
1k 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 ...
user avatar
  • 20.7k
3 votes
2 answers
370 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 ...
user avatar
  • 1,747
6 votes
1 answer
274 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 ...
user avatar
  • 1,163