Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do Java class file versions start from 45?

Tags:

java

jvm

According to the JVM specification:

Oracle's Java Virtual Machine implementation in JDK release 1.0.2 supports class file format versions 45.0 through 45.3 inclusive. JDK releases 1.1.* support class file format versions in the range 45.0 through 45.65535 inclusive. For k ≥ 2, JDK release 1.k supports class file format versions in the range 45.0 through 44+k.0 inclusive.

https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html

I'm wondering, why did they start versioning from 45 and not, say, from 1 or 0?

like image 954
Ivan Babanin Avatar asked Oct 19 '19 19:10

Ivan Babanin


People also ask

What version of Java is 55?

Java 11 uses major version 55.

What version is Java 60?

Java™ SE Development Kit 8, Update 60 (JDK 8u60) The full version string for this update release is 1.8.

How do I fix Java Lang UnsupportedClassVersionError in Java?

UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JDK during runtime. How can i make above change? Project -> Properties -> Java Compiler Enable project specific settings. Then select Compiler Compliance Level to 1.7, 1.6 or 1.5, build and test your app.

How many .class files are created in Java?

As we know that a single Java programming language source file (or we can say . java file) may contain one class or more than one class. So if a . java file has more than one class then each class will compile into a separate class files.

What is the first version of Java class files?

However, the first stable version of Java was JDK 1.0.2, which was released in 1996 as Java 1. The first version of Java class files is major version 45 and minor version 3 and are valid for JDK 1 & 1.1. I don’t know why versions start with 45 and a short research on Google gave me no answer. However, we have to accept this.

How to find the version of a class in Java?

javapThere is simple program which can get you the Java version details. Run the below program by passing the class file name as the arguments, this would return you the major version details. view source print? System.out.println (filename + " is not a valid java file!");

What does major version 57 mean in Java?

According to the table in the OP, major version 57 means the class file was compiled to JDK 13 bytecode level Java Virtual Machine Specification, Chapter 4. The class File Format

What version of JVM do I have a class file?

The class File Format The latest published version of the JVM spec can be found here. If you have a class file at build/com/foo/Hello.class, you can check what java version it is compiled at using the command: According to the table in the OP, major version 57 means the class file was compiled to JDK 13 bytecode level


1 Answers

Why do Java class file versions start from 45?

There were versions of Java before the first publicly released version (Java 1.0.2).

Java originally started life as the Oak programming language in 1991. It was renamed as Java in 1994 and the first public release was in 1996.

It is safe to assume that classfile versions less than 45 were used for earlier (pre-release) versions of Java and probably Oak. In the early days, it is likely that the developers made numerous changes to the bytecode instruction set and other aspects of the classfile format. That would have required "bumping" the classfile version number on a regular basis.

The above is largely conjecture. There is very little publicly available information on Oak and pre-1.0 Java. However, the text of the Oak specification from 1993 indicates that they were already compiling Oak source code to bytecodes that were stored in ".class" files, one per class.

like image 171
Stephen C Avatar answered Nov 04 '22 15:11

Stephen C