News for hackers. Stuff that matters.
Re:Simple Open-Source Java Virtual Machine in C by peter_d_sherman on Tuesday September 19, 2023 @03:41PM (#37575312)
Related:

Java Language and Virtual Machine Specifications

https://docs.oracle.com/javase/specs/index.html

OpenJDK

https://en.wikipedia.org/wiki/OpenJDK

Re:Simple Open-Source Java Virtual Machine in C by metadat on Tuesday September 19, 2023 @05:46PM (#37577259)
(2021)
Re:Simple Open-Source Java Virtual Machine in C by cowmix on Tuesday September 19, 2023 @06:24PM (#37577812)
I had a buddy that wrote a Java 1.1 JVM from scratch in C back in late '97. He created it completely from the defined specification from Sun and actually found bugs in the spec. IIRC, the found bugs in the thread(s) specification. I believe his JVM was one of the first clean-room JVM implementation outside of Sun's efforts.
Re:Simple Open-Source Java Virtual Machine in C by version_five on Tuesday September 19, 2023 @07:06PM (#37578308)
I can imagine that the spec would to some extent reflect an attempt to capture the behavior of the jvm they actually wrote, as opposed to being created first and then having Sun implement afterwards? It sounds like an interesting exercise to recreate it based on the spec and see what got missed.
Re:Simple Open-Source Java Virtual Machine in C by kevin_thibedeau on Tuesday September 19, 2023 @07:42PM (#37578621)
Their intent was to have hardware implementations. The basic spec is simple enough to make that tractable.
Re:Simple Open-Source Java Virtual Machine in C by speps on Tuesday September 19, 2023 @07:01PM (#37578258)
A similar effort but in Go from about a month ago: https://jacobin.org/ [1]

[1] https://news.ycombinator.com/item?id=37247394

Re:Simple Open-Source Java Virtual Machine in C by karmakaze on Tuesday September 19, 2023 @07:43PM (#37578634)
It wasn't actually possible to make a proper implementation from spec before Java 1.5. Quoting Wikipedia

> The original Java memory model developed in 1995, was widely perceived as broken, preventing many runtime optimizations and not providing strong enough guarantees for code safety. It was updated through the Java Community Process, as Java Specification Request 133 (JSR-133), which took effect back in 2004, for Tiger (Java 5.0).

Re:Simple Open-Source Java Virtual Machine in C by mjan22640 on Wednesday September 20, 2023 @12:51AM (#37580494)
~90% of the JVM instruction set are simple RISC instructions, the rest is object maintenance. Writting a JVM is like writting an emulator for a simple CPU/platform.
Re:Simple Open-Source Java Virtual Machine in C by ahoka on Wednesday September 20, 2023 @02:04AM (#37580879)
A simple CPU with a possibly different memory model than the host CPU.
Re:Simple Open-Source Java Virtual Machine in C by pjmlp on Wednesday September 20, 2023 @02:50AM (#37581160)
True until Java 7, not so with all the newer bytecodes.
Re:Simple Open-Source Java Virtual Machine in C by teleforce on Wednesday September 20, 2023 @03:03AM (#37581231)
It makes perfect sense at the time Sun is naming it JVM, apparently technically it's a VM. That meant they have had a valid claim to "write once, run anywhere" mantra. It's a shame that in reality it turned out later to be "write once, debug everywhere" kind of nightmare.
Re:Simple Open-Source Java Virtual Machine in C by suswagatam_rong on Wednesday September 20, 2023 @05:34AM (#37582219)
I so wish I could read that source code. For an amateur like me, it is so phenomenal :)
Re:Simple Open-Source Java Virtual Machine in C by alexshendi on Wednesday September 20, 2023 @01:36PM (#37587145)
I tried to get it to run Peter Norvig's JScheme [1]. Apparently I also need a class library like GNU classpath?

DISCLAIMER: not a Java expert or even practitoner.

[1] http://norvig.com/jscheme.html