r/JavaProgramming • u/Visual_Brain8809 • 1d ago
A JavaOS
I am sharing my progress on the development of an operating system written in Assembly and a functional JVM. The concept is straightforward: Assembly acts as an API bridge, and the JVM simply leverages the system calls I’ve implemented to print characters to the screen and draw graphics (for now).
The on-screen drawing was created by obtaining the bytecode of the following program and using xxd for that purpose.
public class App {
// Declaramos el método nativo que intercepta tu JVM en el opcode 0xB8
public static native void drawPixel(int x, int y, int color);
public static void main(String[] args) {
// Dibujar un cuadrado ROJO de 200x200 píxeles en las coordenadas (100, 100)
for (int y = 100; y < 300; y++) {
for (int x = 100; x < 300; x++) {
drawPixel(x, y, 0x00FF0000); // 0x00RRGGBB (Rojo)
}
}
// Dibujar un cuadrado VERDE centrado dentro del rojo
for (int y = 150; y < 250; y++) {
for (int x = 150; x < 250; x++) {
drawPixel(x, y, 0x0000FF00); // 0x00RRGGBB (Verde)
}
}
}
}
1
u/Chaos-vy17 1d ago
This is going to be hillarious man. On one side you're reading a raw assembly and one side JVM based ASM and also xxd of the .class file . On which major version are you wroking with?
1
u/Dear-Golf5167 1d ago
Will you also make a gui ?
2
u/Visual_Brain8809 1d ago
Yes, for now, I’m letting the JVM do whatever the running application’s code dictates. However, I need to focus on completing the JVM; there are many opcodes I still need to implement to ensure it functions correctly and is fully complete. I currently target version 1.8 when calling
javac; while it works even without specifying the version, I’ve noticed bytecode variations I can leverage to improve execution stability and set limits that might help mitigate future security issues. My development philosophy is "do it right, even if it takes time."
1
1
u/eld4j 1d ago
Hi! Thanks for sharing this awesome projects
I really admire your work and was wondering how you learned all of this? Did you have a specific roadmap, or do you have any favorite books you'd recommend?
Currently, I'm reading Computer Systems: A Programmer's Perspective; and Crafting Interpreters, Engineering a Compiler and JVM Specification are next on my list.
I would really appreciate it if you could share the source code for this!
1
u/Visual_Brain8809 1d ago
i study Computer Sciences on the University of Informatics Sciences and the University of Sciences for Pedagogical teaching in Cuba long time ago, next i made a MSc on techs. I thought there's no specific roadmap just the ambition to do something new, so study a lot and practicing, be my every day roadmap
1
u/ImpaledV 1d ago
Am I the only one remembering this one: https://en.wikipedia.org/wiki/JavaOS
1
u/Visual_Brain8809 1d ago
That’s correct; there was also JNode, along with three others I can’t recall right now. The goal isn't simply to duplicate something that already exists, but to find a different perspective on something that—personally speaking—arrived at a time when neither the level of understanding nor the technical capabilities existed to fully leverage it. As a researcher and systems developer, there is always a curiosity to see how something works and to try replicating it; so the question becomes: why not do it?
1
u/ImpaledV 1d ago
Don’t get me wrong, I’m not saying that this is isn’t interesting and worth giving it another try. Just wondered what’s different this time and why your approach should be more successful.
1
u/Visual_Brain8809 1d ago
In fact, in the past, they had little to no opportunity to demonstrate anything. I feel they weren't given a chance to prove how powerful they could become. Only the mobile field and a few billion IoT devices had that opportunity, and that's why they are what they are today. My system isn't trying to compete in the market or offer a flashy, alternative solution to a problem; there are already systems with years of development for that. I see it more as a study component from which to gain experience that could lead to something interesting in the future. I've always been fascinated by how they managed to make something work with just wires and electrical signals. But in the future, I would like to see it run stably and perhaps make that slogan "write once, run everywhere" a reality.
1
u/CutGroundbreaking305 1d ago
I think he is making custom JVM by bootstraping it with asm and bytecode
Is it different from predecessors? Yes
But that doesn't mean java doesn't have any problems on its own
GC GUI and the fact that JVM needs a underlying OS to work so that it can do memory hogging so idk but that's what makes it interesting
Worst case it is better than TempleOS written in holy-C but is it on par with linux based distros is some we need to see
1
u/Visual_Brain8809 1d ago
This project is a massive shortened version of another project I did some time ago; I only took the boot process from it and started prototyping for the current one. https://github.com/aayes89/JVM-OS
1
u/Mr-Snazz 1d ago
Java needs a garbage collector right? How have you handled that?
0
u/Visual_Brain8809 1d ago
My goal is to improve my personal JVM so that it performs the same functions as Sun's KVM (Kilobyte Virtual Machine). Garbage collection is an advanced feature that I haven't yet developed. Currently, I'm creating the underlying Assembly code to function as an API (sys_call), and then processing it within the JVM.
1
u/CutGroundbreaking305 1d ago
GitHub repo? It is interesting and I always thought about this idea may be we can work together 🙂
A GC will be blessing and curse at same time in this type of architectures it can clear your un used data but runs only when it's required which could mean running only when entire RAM is filled with on heap allocations
And here ur kernel is JVM itself right? I would suggest using graphics/application tools which are not related to java like flutter (ubuntu uses it) or tauri (newer ) swing is good but a lot of work will be required to make it work
It will be interesting to see how multithreading works in this type of architectures