TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: I spent my vacation writing a modern JVM assembler

218 pointsby noone_youknowalmost 3 years ago

24 comments

j_ham3almost 3 years ago
Nice project! At Guardsquare, we have a similar project: <a href="https:&#x2F;&#x2F;github.com&#x2F;Guardsquare&#x2F;proguard-assembler" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Guardsquare&#x2F;proguard-assembler</a><p>One of the things we use it for is testing: we can craft specific bytecode sequences that we want to test; for example, it&#x27;s useful to test cases we&#x27;ve seen in the wild (e.g. obfuscated code) or to create a test that doesn&#x27;t rely on a specific compiler&#x2F;version.<p>An example of using the assembler from a ProGuard unit test <a href="https:&#x2F;&#x2F;github.com&#x2F;Guardsquare&#x2F;proguard&#x2F;blob&#x2F;master&#x2F;base&#x2F;src&#x2F;test&#x2F;kotlin&#x2F;proguard&#x2F;util&#x2F;ProguardAssemblerTest.kt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Guardsquare&#x2F;proguard&#x2F;blob&#x2F;master&#x2F;base&#x2F;src...</a>
评论 #31605802 未加载
noone_youknowalmost 3 years ago
I had a lot of fun doing this, and along the way I learned a lot about writing Gradle and IntelliJ plugins, and I hope others might find this fun too :)
评论 #31604944 未加载
pdpialmost 3 years ago
I implemented a .class disassembler a while back by literally reading the spec. It&#x27;s surprisingly accessible.
评论 #31600745 未加载
评论 #31605114 未加载
评论 #31602406 未加载
评论 #31601610 未加载
dvtalmost 3 years ago
Very cool! Reminds me of a little toy (and very unfinished) project I worked on almost a decade ago (jeez, can&#x27;t believe it&#x27;s been that long): <a href="https:&#x2F;&#x2F;github.com&#x2F;dvx&#x2F;jssembly" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dvx&#x2F;jssembly</a><p>Even our syntax is somewhat similar, though you&#x27;re using plugins for cleaner code which is an awesome idea.
评论 #31600543 未加载
donsupremealmost 3 years ago
Bravo! you and I have very different way to decompress during a vacation
评论 #31601044 未加载
评论 #31610518 未加载
jpgvmalmost 3 years ago
This is awesome.<p>I have been toying with writing my own little JVM language (for education purposes) and this could go a long way to making that a bunch easier.<p>Thanks for sharing!
评论 #31600908 未加载
评论 #31604913 未加载
评论 #31600199 未加载
评论 #31600729 未加载
评论 #31600788 未加载
tstackalmost 3 years ago
I used to use jasmin to generate invalid code to test an old JVM. I assume this has the same relaxed attitude that will let you generate invalid code?
评论 #31600618 未加载
Strs2FillMyDrmsalmost 3 years ago
My question (if I may), When people say the bytecode is &quot;platform independent&quot; I ask, exactly what platform is it being freed from?<p>The compiler? The &quot;cloud&quot;?<p>And this goes back to my lack of understanding of what &quot;publishing&quot; a package means to Oracle and the ecosystem in general.<p>If I publish something on Maven, my guess is that it is transformed into bytecode directly, so that when I pull my package from a diff device the code can run. In this case if the entire &quot;internet&quot; collapses then the only way to run my code would be a flashdrive with the .java file run via a compiler... unless there is a machine that has the JVM installed WITHOUT the compiler... THEN the bytecode is useful... Am I correct?
评论 #31601026 未加载
评论 #31603742 未加载
评论 #31602188 未加载
ElijahLynnalmost 3 years ago
These are the type of posts that make some of us noobs feel like imposters, lol. (been coding webstack-ish for 10 years, fwiw, can&#x27;t even begin to write an assembler though :shrug:)<p>Good on you though, we need inspiration too! And you definitely should feel great about pulling that off! I am imaging it must have been some really fantastic &quot;flow&quot; time! How did you feel while writing it? Did you have family or friend distractions? Did you feel super focused? What is that story?<p>What are some of your focus patterns that you have identified? What gets you motivated when you feel stuck?
评论 #31601877 未加载
评论 #31605770 未加载
评论 #31601339 未加载
评论 #31601500 未加载
评论 #31602804 未加载
oh_sighalmost 3 years ago
I enjoyed reading about doing some things with the jvm which are not possible through the java language - can anyone recommend a page that goes further into that concept?
评论 #31611362 未加载
评论 #31602998 未加载
mbfgalmost 3 years ago
Looks like a fun project. One thing i&#x27;d be interested in, is if it&#x27;s slower than using javac, given that the JIT can optimize common idioms that the compiler spits out. For instance, for some JITs, in the past anyway, This code<p>int myNumber = getANumber(); String s = &quot;&quot; + myNumber;<p>was faster to run than<p>int myNumber = getANumber(); String s= String.valueOf(myNumber);<p>even though the bytecode for the second bit of code is a proper subset of the first. (Meaning the first section had all the byte code of the second, plus some extra stuff.)<p>And yet the first ran faster than the second. So unless you&#x27;ve got some spectacularly tricky algorithm that you can naturally express in java, and can in jasm, i&#x27;m betting the javac output will be as fast or faster.<p>Again tho, i&#x27;m not criticizing the author for doing this project at all. Kudos!
评论 #31604227 未加载
评论 #31605748 未加载
brabelalmost 3 years ago
Groovy version of this but based off Jasmine: <a href="https:&#x2F;&#x2F;github.com&#x2F;renatoathaydes&#x2F;Grasmin" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;renatoathaydes&#x2F;Grasmin</a>
FastEatSlowalmost 3 years ago
Brilliant, much better than having to use heavy and clunky tools like recaf or jbytemod, or one-off java projects with ow2 ASM to create custom classes.
mrslavealmost 3 years ago
Why not Jasmin?<p>Congrats on publishing your application. If this was something more than self-education please sell the benefits over Jasmin in your README? Looking forward to having a play with it.
评论 #31605778 未加载
userbinatoralmost 3 years ago
That syntax seems to be implying that the next step is to integrate this into the compiler, so you can write inline Asm in Java.
评论 #31605784 未加载
cbm-vic-20almost 3 years ago
&quot;Let&#x27;s just get this out of the way, shall we?<p>{code here} &quot;<p>Thanks for doing that; I can&#x27;t stand it when I go to a site for something new and can&#x27;t find what it actually looks like without digging around.
评论 #31600122 未加载
评论 #31600321 未加载
nnoitraalmost 3 years ago
&quot;With my recent scaling-back of the rosco_m68k project that’s been getting all my free time for the past couple of years, I needed a fun project to do during my time off, and I ideally wanted to take a break from Motorola 68k assembly and electronics and do something different.&quot;<p>All of your free time is consumed in programming?<p>Isn&#x27;t it a bit absurd to have your entire life revolve around programming?
评论 #31604090 未加载
评论 #31604066 未加载
self_awarenessalmost 3 years ago
Good method of helping to manually obfuscate some calls, so that reverse engineering can be harder.
eternalbanalmost 3 years ago
<p><pre><code> ... checkcast java&#x2F;lang&#x2F;String areturn </code></pre> Looks like a typo.
评论 #31599925 未加载
评论 #31603753 未加载
playing_coloursalmost 3 years ago
Can anyone recommend a good source (book, articles) to learn Java Bytecode?
评论 #31600382 未加载
评论 #31601136 未加载
评论 #31600373 未加载
评论 #31600559 未加载
recursivedoubtsalmost 3 years ago
amazing!<p>I will definitely discuss this in my compilers class, which targets JVM bytecode as a back end!
评论 #31599754 未加载
H4sh3almost 3 years ago
public static main([java&#x2F;lang&#x2F;String)V {<p>is this open square brackets a typo?
评论 #31609888 未加载
rurbanalmost 3 years ago
kotlin is modern now? I would not dare to use jasm in my hypothetical new language targeting the JVM. I&#x27;d rather write this anew in C++ or C.
tornadofartalmost 3 years ago
Impressive
评论 #31600155 未加载