Live data from Hacker News

I have written a JVM in Rust

andreabergia.com

1–10 of 185 posts

Re: I have written a JVM in Rust

#2
Nice project, congrats!

One thing struck me as a bit odd:

> In particular, it does not support: generics

What kind of support is there for generics in the JVM? Maybe I'm too naive to assume that due to type erasure on bytecode level everything is just an Object, ie. a reference type? Or do you mean the class definition parser - but then, you don't really have any checks in place to see if the class file is valid (other than the basic syntax)?

Re: I have written a JVM in Rust

#3
Great project, congrats! Mad respect.

Started working on something very similar a few years back and gave up pretty soon for some stupid reason. Maybe I should try again, am getting better at getting stuff done.

Re: I have written a JVM in Rust

#4
post #2

Nice project, congrats! One thing struck me as a bit odd: > In particular, it does not support: generics What kind of support is there for generics in the JVM? Maybe I'm too naive to assume that due to type erasure on bytecode level everything is just an Object, ie. a reference type? Or do you mean the class definition parser - but then, you don't really have any checks in place to see if the class file is valid (oth…

pretty much this - generics have (rare) implications to the reflection (but it's unsupported as well) but overall they are replaced with the nearest class/interface when compiled.

OTOH lack of string interning is super strange [it's trivial to implement], and w/o it JVM is not a thing. String being equal by reference is important, and part of JLS.

Lack of thread makes the entire endeavor a toy project.

Re: I have written a JVM in Rust

#5
post #2

Nice project, congrats! One thing struck me as a bit odd: > In particular, it does not support: generics What kind of support is there for generics in the JVM? Maybe I'm too naive to assume that due to type erasure on bytecode level everything is just an Object, ie. a reference type? Or do you mean the class definition parser - but then, you don't really have any checks in place to see if the class file is valid (oth…

They might be talking about the checkcast operation: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.ht...

This is generated when you do something like: final Main value = list.get(0);

http://henrikeichenhardt.blogspot.com/2013/05/how-are-java-g...

Re: I have written a JVM in Rust

#6
post #4
post #2

Nice project, congrats! One thing struck me as a bit odd: > In particular, it does not support: generics What kind of support is there for generics in the JVM? Maybe I'm too naive to assume that due to type erasure on bytecode level everything is just an Object, ie. a reference type? Or do you mean the class definition parser - but then, you don't really have any checks in place to see if the class file is valid (oth…

pretty much this - generics have (rare) implications to the reflection (but it's unsupported as well) but overall they are replaced with the nearest class/interface when compiled. OTOH lack of string interning is super strange [it's trivial to implement], and w/o it JVM is not a thing. String being equal by reference is important, and part of JLS. Lack of thread makes the entire endeavor a toy project.

“I want to stress that this is a toy JVM, built for learning purposes and not a serious implementation.”

Re: I have written a JVM in Rust

#8
post #6
post #4

Earlier quoted context omitted.

pretty much this - generics have (rare) implications to the reflection (but it's unsupported as well) but overall they are replaced with the nearest class/interface when compiled. OTOH lack of string interning is super strange [it's trivial to implement], and w/o it JVM is not a thing. String being equal by reference is important, and part of JLS. Lack of thread makes the entire endeavor a toy project.

“I want to stress that this is a toy JVM, built for learning purposes and not a serious implementation.”

The rest of the stuff, incl. I/O is actually on the trivial side - threads do require planning. This is what I meant by being a 'toy' project, threads (and JMM) would be impossible to bolt in later on.

Re: I have written a JVM in Rust

#9
post #5
post #2

Nice project, congrats! One thing struck me as a bit odd: > In particular, it does not support: generics What kind of support is there for generics in the JVM? Maybe I'm too naive to assume that due to type erasure on bytecode level everything is just an Object, ie. a reference type? Or do you mean the class definition parser - but then, you don't really have any checks in place to see if the class file is valid (oth…

They might be talking about the checkcast operation: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.ht... This is generated when you do something like: final Main value = list.get(0); http://henrikeichenhardt.blogspot.com/2013/05/how-are-java-g...

The cast is added by javac, so it just needs to verify the object on the stack to be compatible w/ the provided class. That part is very simple.
Post reply on HN