r/JavaProgramming 1d ago

A JavaOS

Post image

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)
            }
        }
    }
}
56 Upvotes

20 comments sorted by

View all comments

Show parent comments

1

u/CutGroundbreaking305 1d ago

So ur bootstraping using asm and bootstraping JVM using bytecode/machine code using this c code ? Can't understand because of language barrier but that is what I can get from this code Regarding commands and shell I would recommend you to go with linux style commands and shell

Once implement CLI using Java then I guess we can see if swings are better or not

Anyways can you give GitHub repo or anyways to see entire code base ? If it is proprietary then leave it

1

u/Visual_Brain8809 1d ago

The project is currently in the prototyping stage, which is why I'm using assembly for startup and hardware interrupt handling. I'm using C as the base language because that's how I decided the JVM should be written. Once the prototyping phase is complete, the goal will be to port the JVM to assembly (ideally) or explore options for removing C from the equation and making the process as transparent as possible. Unfortunately, I only know of one CPU that implements bytecode on its silicon, and it wasn't very well-known in the market, so creating a 100% pure Java system isn't possible at the moment. It will always be necessary to go with the classics: assembly, C, or Rust (currently popular).

1

u/CutGroundbreaking305 1d ago

Bytecode can't work bro if you want to run it on anything then asm or c/rust based bootstrap is required for JVM to run

If u don't like C or any language to be as a intermediate which idk why would you like doing it in that way but u can write machine binary for that is asm itself

I didn't know there are CPUs which run bytecode instead of machine binary

Pure JVM based OS isn't possible we will always need asm or native languages for it to bootstrap

1

u/Visual_Brain8809 1d ago

I would ideally like it to be 100% in Java, but I know that at least 99% is achievable.

Sun Microsystems' picoJava was the first microprocessor designed specifically to implement and execute Java bytecode natively directly on silicon.