What classes are absolutely necessary to run the Java virtual machine?

What is the smallest subset of classes that a Java VM can run with?

I suppose things like Object, String, and primitives are absolutely necessary as they are tightly coupled in many parts of the virtual machine.

I wonder how great the dependencies are between the JVM and the JDK.

The main question I'm interested in is:

If I decided to distribute the JVM with a different programming language and various standard libraries, how most of the "Java" classes do I have to carry to make the JVM happy?

+6
java language-agnostic class jvm
source share
4 answers

The best way to find out is to try and see; for example use java -verbose. to run a minimal program in different languages ​​hosted on the JVM.

But the answer is likely to be:

  • JVM specification, and
  • programming language.

I should also indicate that the answer (s) you get will not be of practical use (... if you do not plan to create an abbreviated JRE. And if so, read the following below.)

Do you know that all classes are strictly necessary, or does the VM also preload classes that are expected to be used in all cases by applications?

The JVM does not preload on this basis. Rather, it loads the closure of the dependencies your code depends on. Depending on which classes your application uses, this may result in loading classes that are not actually used. Sun engineers have done a great job to try to reduce this effect over the years, but undoubtedly this still happens to some extent.

FOLLOW UP

Reading between the lines, it seems that the goal is to create an abbreviated JVM package to support runtime requirements in some other language. If so, consider the following points:

  • There are licensing requirements for what you can do with Java with respect to creating shortened versions. In particular, Java, JVM, and JRE are trademarks, and Oracle may appear after you if you use them in the context of the abbreviated JRE. (I'm not saying that you cannot do this, but you need to check the legal aspects for yourself.)

  • There are certain support issues. For example, you need to keep track of any relevant security issues and Java / JVM patches and create new versions of your underlying platform as recommended.

  • If you intend to somehow apply applications in your new language to invoke Java libraries, then using the shortened JRE can be a serious back pain for some users. Especially if you pack your things so that they use your cut JRE.

  • There are tools in the JRE / JDK that may be useful to you / your users. Tools like profilers, debuggers, JAR commands, etc. Your JRE will need to include all the classes necessary to run them.

Finally, downloading 100 MB is not a significant issue for VAST MAJORITY users. And if so, you can make some money to support your project by selling installer DVDs.

Focus on what you are really trying to do here ... and leave the installer optimization when you have something like product quality for optimization.

+3
source share

If you run the command:

 java -verbose 

It will show you every class that it loads in order to start the virtual machine. If you add -verbose when starting a java program, you will get a complete list of what this program should run. But this does not include any additional classes that may be required as they work.

Why do you need to know which classes are needed?

+1
source share

You are trying to split a 7000 class application to find out which ones are needed. If you did this, could you guarantee that the JVM will not let you down at some random point in the future? Even worse, if for some reason it explodes, your finger will probably be the first to point at you until you can prove that it has nothing to do with deleting classes.

If you use a mobile device and you need to save capacity, I suggest you use JME. However, if you use a desktop where 200 MB costs less than one penny, is it really worth it? If it explodes, it will cost you more than a penny, I suspect it will.

Analogy, you go along the main road, and you see what could be a penny on the other hand. Do you cross the road through heavy traffic to get it? I suggest you keep going.

EDIT: if you want to cut the Java version, you can try the built-in version. http://www.oracle.com/technetwork/java/embedded/downloads/index.html

It has a grade of 32 MB and 70 MB.

0
source share

IANAL, but you might run into a threat from Oracle if you separate the java.* Classes, because the Sun / Oracle patent patent for JDK patents requires you to implement full java.* Interfaces and that you do it compliant with the standard. (I think this is part of what the Google suit relies on.)

In addition, I think that the developers of the Jigsaw project have a non-trivial time deciding what is included in the basic JDK installation and what belongs to the module. I remember reading a blog post (I can’t find it now) about some problems breaking the circular dependencies between things that should be in modules (XML, IIRC) and the base installation.

0
source share

All Articles