You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each class was compiled to be used with a specific version of Java. It was quite complex back in old versions of Java, but today everything is pretty straightforward - JVM can run classes of its version and classes with *older* versions. In other words, JVMs are **backwards compatible**
47
+
Each class was compiled to be used with a specific version of Java. It was quite complex back in old versions of Java, but today everything is pretty straightforward - JVM can run classes of its version and classes with <em>older</em> versions. In other words, JVMs are <b>backwards compatible</b>
48
48
49
49
To store version of the Java that compiled the file, Major and Minor fields exist
As you already know from "Class File Format" document, Java classes have a relatively complex structure. And the best way to study it - compile something and see these beatiful files in the wild!
2
+
As you already know from [Class File Format](Class%20File%20Format.md) document, Java classes have a relatively complex structure. And the best way to study it - compile something and see these beatiful files in the wild!
3
3
4
4
For such a purpose, you can use `javac` and `javad` command line tools - official compiler and disassembler, that are included into every Java Development Kit.
5
5
@@ -11,21 +11,21 @@ For the beginning, let's compile a simple class.
Okay, hold on. We have compiled the simplest class we could have, right? Where all of this code came from?
75
+
76
+
Well, if you are familiar with Java, you surely know, that Java compilers actually add something to your code. Things like default constructor, implicit inheritance from `java.lang.Object`...
77
+
78
+
Long story short, that's how our class *actually* looks after compilation:
And the major and minor versions of the JDK that compiled the file. Looking up the version of the Java in the special [table](/doc/Reference/Java%20major%20versions.md), we gain a resulting version of Java - **15**!
0 commit comments