Sometimes you find an excellent question to ponder about, and sometimes it leads to a nice puzzle. If you like puzzles, you can check out the unicorn one, that was kind of fun, or the first one we did ages ago.
Today, however, I’d like to pose you a code-golf like challenge:
What’s the smallest Java class you can generate using javac (any vendor, any release)?
Note that the class doesn’t have to be executable just to be valid. However, if you find a nice small class that you can run after the compilation (public static void main and all that) you get bonus points.
Originally, I’ve been asked that by my colleague Dmitri, who’s also a JRebel core engineer, so he knows a thing or two about Java classes. We had fun in slack trying all kinds of different tricks and generating smaller and smaller classes.
Now it’s your turn! I cannot offer any real prizes, except for the eternal glory and fame that you will get next week when we’ll post and explain the best and most compelling solutions that we get.
Please don’t spoil the fun by disclosing your attempts in the comments, but heat up the challenge by telling us the size of your smallest classes. Can you get it to under 100 or maybe even 50 bytes? Oh, if you want to share the solution, please email the source code for the class and the details of the javac and the command you used to compile the code to firstname.lastname@example.org with the subject “RebelLabs smallest Java class puzzle.”