In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
JVM virtual machine what is the magic number of Class files, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
I. the definition of magic number
The word magic number has different meanings in different fields. In the computer field, magic number has two meanings: one refers to the magic number used to determine the type of file, and the other refers to the magic number in program code, also known as magic value.
In most cases, we identify the type of a file by its extension. For example, when we see a file of type .txt, we know that it is a plain text file. However, the extension can be modified, when the extension of a file has been modified, how to identify the type of a file? This uses the "magic number" we mentioned.
The so-called magic number and magic string are numeric constants or strings that appear in the code but are not explained, also known as magic values. If you use magic numbers in a program, you probably won't know what it means in a few months or years.
For many types of files, the content of the first few bytes is fixed (either intentionally filled, or so it is). The content of these bytes is also called magic number, because the file type can be determined according to the contents of these bytes. With these magic numbers, we can easily distinguish between different files. The magic numbers of common files are as follows:
JPEG (jpg), header: FFD8FF
PNG (png), header: 89504E47
GIF (gif), header: 47494638
TIFF (tif), header: 49492A00
Windows Bitmap (bmp), header: 424D
CAD (dwg), header: 41433130
Adobe Photoshop (psd), header: 38425053
Rich Text Format (rtf), header: 7B5C727466
XML (xml), header: 3C3F786D6C
HTML (html), header: 68746D6C3E
Email [thorough only] (eml), header: 44656C69766572792D646174653A
Outlook Express (dbx), header: CFAD12FEC5FD746F
Outlook (pst), header: 2142444E
MS Word/Excel (xls.or.doc), header: D0CF11E0
MS Access (mdb), header: 5374616E64617264204A
WordPerfect (wpd), header: FF575043
Postscript (eps.or.ps), header: 252150532D41646F6265
Adobe Acrobat (pdf), header: 255044462D312E
Quicken (qdf), header: AC9EBD8F
Windows Password (pwl), header: E3828596
ZIP Archive (zip), header: 504B0304
RAR Archive (rar), header: 52617221
Wave (wav), header: 57415645
AVI (avi), header: 41564920
Real Audio (ram), header: 2E7261FD
Real Media (rm), header: 2E524D46
MPEG (mpg), header: 000001BA
MPEG (mpg), header: 000001B3
Quicktime (mov), header: 6D6F6F76
Windows Media (asf), header: 3026B2758E66CF11
MIDI (mid), header: 4D546864
Second, the number of demons in Class files
In order to make it easier for the virtual machine to identify whether a file is of type class, SUN stipulates that each class file must start with a word (four bytes), which is a magic number. Magic number is made up of four bytes of unsigned numbers, the Java .class file, the first four bytes are 0xCAFEBABE. This magic value was determined when Java was still called the "Oak" language (around 1991). It also has an interesting history. According to Patrick Naughton, an original key member of the Java development team, "We have been looking for something fun and easy to remember. We chose 0xCAFEBABE because it symbolizes the popular Baristas coffee of the famous coffee brand Peet's Coffee." The following figure is a compiled class file, and you can see that the file begins with cafebabe.
III. Magic number and the version of the Class file
The next four bytes of the magic number store the version number of the Class file: the fifth and sixth bytes are minor version numbers (Minor Version), and the seventh and eighth bytes are major version numbers (Major Version).
The version number of Java starts at 45, and each major release of JDK after JDK 1.1adds up to one (JDK 1.0 to 1.1uses the version number of 45.0 to 45.3). The higher version of JDK is compatible with previous versions of Class files, but cannot run later versions of Class files, because the Java Virtual Machine Specification explicitly requires in the Class document verification section that even if the file format has not changed. The virtual machine must also refuse to execute Class files that exceed its version number.
For example, JDK1.1 can support Class files with version 45.045.65535, cannot execute Class files with version 46.0 or above, and JDK1.2 can support Class files with version 45.046.65535. At present, the latest version of JDK is 13, and the maximum number of major versions of Class files that can be generated is 57.0.
The version number in the figure above is 34, and the corresponding decimal number is 52, so the corresponding JDK version is 1.8.
Between JDK 1.1 and 13, the default and supported versions of Class files output by mainstream JDK version compilers:
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.