Live data from Hacker News

Java JDK 1.0 (1996)

github.com

1–10 of 50 posts

Re: Java JDK 1.0 (1996)

#4
I came across this post [1] in which the author discovers an undocumented feature in the JVM.

"Although the first stable release of Java used bytecode version 45.3, the JVM will actually accept classfiles with versions starting at 45.0. Furthermore, there’s an undocumented feature in the JVM where it parses Code attributes slightly differently when the version is 45.0 - 45.2.

In a normal classfile, the stack, locals, and code length fields of the Code attribute have lengths of 2, 2, and 4 bytes respectively, but in a pre-45.3 classfile, the JVM expects them to be 1, 1, and 2 bytes instead. Normally, this means that a pre-45.3 classfile produced by ASM will just crash when run on the JVM because the JVM encounters garbage data while parsing and rejects it.

However, if you are very careful, it is possible to construct a classfile that is valid when parsed with the 2,2,4 widths, and also valid when parsed with 1,1,2, but parses as different code in each case. This means that it is possible to craft a classfile that executes one piece of code when run on the actual JVM and displays a completely different set of fake code when viewed with reverse engineering tools"

TL;DR JVM contained an undocumented feature in the JVM where it parses Code attributes slightly differently when the version is 45.0 - 45.2. The stack, locals, and code length typically has 2,2,4 bytes rspectively; in pre-45.3 classfiles, the JVM expects them to be 1,1,2 bytes instead.

[1] https://blog.polybdenum.com/2021/05/05/how-i-hacked-google-a...

[2] https://github.com/openjdk/jdk/commit/eedc99c9ab2647f0233e48...

Re: Java JDK 1.0 (1996)

#6
was expecting the actual vm source code, which I believe is written in C and is an engineering marvel. This looks like just the end user install package

Re: Java JDK 1.0 (1996)

#7
Note that this is under a proprietary license (see toplevel COPYRIGHT code). Given the rather messy history around the Java API, it might be legally problematic to look at this code.

Re: Java JDK 1.0 (1996)

#8
post #4

I came across this post [1] in which the author discovers an undocumented feature in the JVM. "Although the first stable release of Java used bytecode version 45.3, the JVM will actually accept classfiles with versions starting at 45.0. Furthermore, there’s an undocumented feature in the JVM where it parses Code attributes slightly differently when the version is 45.0 - 45.2. In a normal classfile, the stack, locals,…

It's discussed here: https://news.ycombinator.com/item?id=27064800

Re: Java JDK 1.0 (1996)

#9
post #6

was expecting the actual vm source code, which I believe is written in C and is an engineering marvel. This looks like just the end user install package

Interesting! Well is the sourcecode for the Java JVM not open and available?
Post reply on HN