Readit News logoReadit News
andrewbinstock commented on Ask HN: What are you working on? (March 2025)    · Posted by u/david927
andrewbinstock · a year ago
A JVM written in go. [0] We're committed to a high-quality implementation that works reliably--so our test code is > 2.x the size of our production code. We can already run lots of classes, but the finished product won't be ready for alpha testing until, we hope!, end of this year.

[0] jacobin.org

andrewbinstock commented on Jacobin: A more than minimal JVM written in Go   jacobin.org/... · Posted by u/yla92
meisel · 3 years ago
Just curious, what's the purpose of this? Are there any production use cases it's targeting, or is it just for fun?
andrewbinstock · 3 years ago
Lead dev here. I gave a detailed reply earlier. Grep for "I've always thought of the JVM as magical technlogy" on this page and you'll find it.
andrewbinstock commented on Jacobin: A more than minimal JVM written in Go   jacobin.org/... · Posted by u/yla92
kernal · 3 years ago
>The goal is to provide a more-than-minimal implementation of the JVM that can run most class files and JARs

As with everything, the final 10% is 90% of the work.

andrewbinstock · 3 years ago
Lead dev here. It's been an amazing amount of work. I'd change the above adage to: Every 10% is 90% of the work!
andrewbinstock commented on Jacobin: A more than minimal JVM written in Go   jacobin.org/... · Posted by u/yla92
peter_d_sherman · 3 years ago
Very cool!

Hey, you know a feature which I would love to see (and maybe it's already in there) -- would be the ability to "orchestrate" Java code. In other words, to be able to add external event hooks from functions/procedures/methods -- at runtime...

These event hooks, when encountered, would be able to do such things as:

* Print/pipe a debug message to an external program or log or log viewer;

* The debug printer should contain the function/procedure/method name, parameter names, and parameter values automatically (there should be functionality to have them in both the invocation and after the function/procedure/method's code is complete, prior to returning to the caller, so two possible places per function/procedure/method...);

* The ability to selectively turn on/off such events at runtime;

* The ability to add additional code which could be evaluated for every such event (also at runtime), and make the determination if the event should be processed or skipped;

* The ability to do all of the above programmatically, via API...

* Some sort of GUI which automatically imports all function/procedure/method names of a running Java program at runtime, then gives the user the ability to track/log whichever ones they want, by simply selecting them to a secondary listbox of tracked function/procedure/methods...

Now, maybe some or all of that -- is already baked in there. I didn't look at the codebase long enough to know...

But if it is in there, that's awesome! And if one or more of those features are missing, then maybe a future version maintainer or forked version maintainer might be persuaded to add them in there...

(Side note: It would be nice to have the above functionality for all programming languages!)

Anyway, as said previously, looks very cool!

andrewbinstock · 3 years ago
Lead dev here. Some very cool ideas in there. Will copy/paste this into our task tracker on YouTrack for further consideration. Much appreciated.
andrewbinstock commented on Jacobin: A more than minimal JVM written in Go   jacobin.org/... · Posted by u/yla92
jsd1982 · 3 years ago
Does "capable of running Java 17 classes" imply Java >= 17 or Java <= 17?

I tried to run a Java 11 jar on my M1 Mac with $JAVA_HOME pointed at a temurin-11.0.20 JVM but no such luck:

    $ ./jacobin -jar my.jar
    Class Format Error: Class  has two package names: apple/security and com/sun/crypto/provider
      detected by file: cpParser.go, line: 241
    ParseAndPostClass: error parsing classes/module-info.class. Exiting.
    Class Format Error: Invalid access flags of MethodParameters attribute #1 in main
      detected by file: methodParser.go, line: 333
    Class Format Error:
      detected by file: methodParser.go, line: 109
    ParseAndPostClass: error parsing my.Main. Exiting.

andrewbinstock · 3 years ago
Thanks for your note. The package notes on Jacobin say that we strongly discourage folks from running it in its present form. There are enough features still to be implemented, that for anything but trivial classes, you won't have a good experience. TBH, we're about a year out (we think) from having a version we can solicit users to test.

Nonetheless, if you'd be kind enough to post the above error and the class you used into the GitHub Issues tracker [0], we'll definitely include it in our test suite and make sure whatever the problem is, it'll be corrected.

[0] https://github.com/platypusguy/jacobin/issues

andrewbinstock commented on Inside the JVM: Arrays and how they differ from other objects   blogs.oracle.com/javamaga... · Posted by u/ternaryoperator
SeanLuke · 3 years ago
> Another curiosity of Java arrays is that they can have a size of zero.

> This code will not result in an error message. This surprising feature is used primarily by code generators, which might create an array and then discover there are no values to place in it.

What? How can someone at Oracle have written this?

Zero-length arrays are used all the time when you call a function asking for an array of "the latest stuff" and it needs to be an array, not an ArrayList say (maybe it's an array of bytes). If there's no stuff, you get a zero-length array of course. The myriad foo.toArray(...) functions in Java's library do this for example.

andrewbinstock · 3 years ago
Author here. Zero-length arrays are used in the narrow domain you mention. but they are rare in bread-and-butter Java programming. Given some of the other comments on this page, you can see that this aspect is new to multiple readers. And in my experience speaking to Java devs, the reaction of surprise is far more common than "of course, I use them."
andrewbinstock commented on Inside the JVM: Arrays and how they differ from other objects   blogs.oracle.com/javamaga... · Posted by u/ternaryoperator
SeanLuke · 3 years ago
I was pretty disappointed that, for a blog called "Inside the JVM", very little in the blog entry discussed goings on inside the JVM. For example, when does the JVM typically optimize away bounds or null checks? How are arrays of booleans packed and what is their efficiency compared to arrays of bytes or words?
andrewbinstock · 3 years ago
Author here. Thanks for your comment. It's sometimes a little difficult to know how deeply to go into the innards of the JVM before readers' eyes glaze over and they can't follow. I'll bear in mind for future articles in this series that I can/should go deeper than the present level.
andrewbinstock commented on Inside the JVM: Arrays and how they differ from other objects   blogs.oracle.com/javamaga... · Posted by u/ternaryoperator
xdavidliu · 3 years ago
> (It’s somewhat counterintuitive that the zero dimension is not the first one in the array.)

I must've read this sentence at least 7 times, but don't understand what this means. Can anyone illuminate?

andrewbinstock · 3 years ago
Author here. This is simply a comment on the way that Java refers to the subarrays. I believe most developers would think of the first subarray as being referenced with [0], rather than with no index at all. That's all the comment was intended to point out.
andrewbinstock commented on Inside the JVM: Arrays and how they differ from other objects   blogs.oracle.com/javamaga... · Posted by u/ternaryoperator
layer8 · 3 years ago
To elaborate further, consider this quote from TFA:

For example,

strangePoints = new int[3][4][0][2]

In this declaration, all dimensions after the zero-size dimension are ignored. So, the result of this declaration is equivalent to a two-dimensional array of ints.

This is just plain wrong. It’s a four-dimensional array of ints, just one that cannot contain more than zero ints, because one of the dimensions is zero.

To illustrate,

    int[][] a = strangePoints[0][0];
will typecheck while

    int b = strangePoints[0][0];
will not (which however it should if the author’s claim that strangePoints is a two-dimensional array of ints was true).

The talk about Object having no size() method and arrays having therefore a length field is also confused. Arrays have distinct types (and classes, in the sense of getClass()), and therefore could very well have a size() method. It’s merely a stylistic choice of Java that they opted for the simpler .length syntax.

The article is so misguided as to be harmful.

andrewbinstock · 3 years ago
Author here. Your "correction" is wrong. All dimensions after the zero dimension are ignored by the JVM. This is explicitly stated in the JVM spec[0].The typecheck you're leaning on is a purely syntactical construct. Inside the JVM, the arrays function and are sized just as I described.

> Object having no size() method and arrays having therefore a length field is also confused. Arrays have distinct types (and classes, in the sense of getClass()), and therefore could very well have a size() method. It’s merely a stylistic choice of Java that they opted for the simpler .length syntax.

What's the "confused" part? Again, my description is accurate and you're simply saying that Java could have chosen a different way to do the same thing, but decided not to.

[0] https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-6.h...

andrewbinstock commented on Jacobin: A more than minimal JVM written in Go   jacobin.org/... · Posted by u/yla92
layer8 · 3 years ago
They’ll have to implement java.lang.Thread somehow, or not a lot will run on that JVM.
andrewbinstock · 3 years ago
Lead dev here. Yup, that's right. There are a few classes that we will be forced to implement in Go. We're fixated on keeping this number as low as possible, but Thread is one that is inescapable. Class is another inescapable one--if we're to support reflection, etc.

u/andrewbinstock

KarmaCake day2623July 10, 2012
About
Lead developer on Jacobin (JVM written in go--jacobin.org) Headed up Java Magazine (at Oracle). Earlier, editor in chief of Dr. Dobb's Journal, the original programming 'zine, and several earlier publications.

@platypusguy.

All comments intended to be helpful. If they're not, let me know.

View Original