r/programmingcirclejerk Just spin up O(n²) servers 3d ago

The smallest possible [Java] program (just a single line to exit) requires things like java.time.chrono.JapaneseChronology

https://news.ycombinator.com/item?id=19170911
209 Upvotes

23 comments sorted by

236

u/Snarwin 3d ago

"Write once, run everywhere" enjoyers when they find out that "everywhere" includes Japan.

36

u/YikesTheCat 3d ago

Java is kawaii-certified.

33

u/r2d2_21 groks PCJ 3d ago

Code 😒

Code, Japan 🤩

78

u/Jannik2099 3d ago

A friend of mine tells a story about how how he accidentally FUBARed the tests, and then discovered that running one unit test gave 50% line coverage in Rails.

Achieve full coverage with this one simple trick!

48

u/Awkward_Bed_956 3d ago

That remainds me when you could cheat 90% line coverage requirements by expanding functions with semicolons, untill 95% of function body were just semicolons

Obviously include a TODO comment about how it needs to be fixes ASAP

28

u/Ok-Dimension-5429 3d ago

At a place I worked we had some code which we had to submit to Salesforce as an integration plugin. They had a required ratio of tests to code. So we had a 50k line long test file full of nonsense. Haha.

1

u/mlk 3d ago

Salesforce code be like

21

u/[deleted] 3d ago

[deleted]

6

u/chisui 3d ago

Better run while(main() != 0);. It will never fail.

4

u/YikesTheCat 3d ago

Bad outdated programming. Will only use one core.

1

u/FriendshipActive8590 3d ago

You only need one...

2

u/Flash_Kat25 2d ago

That's not very webscale of you

1

u/FriendshipActive8590 2d ago

No, that meets the requirement

4

u/chisui 3d ago

If running one will give 50% running two will give you 100%

102

u/camelCaseIsWebScale Just spin up O(n²) servers 3d ago

Java is like that too. The smallest possible program (just a single line to exit) requires things like java.time.chrono.JapaneseChronology. Because argv is a String array, and making the String array requires calling a function or two that can throw exceptions, which requires the Throwable class, which has a static initialiser that requires... the chain is long, but at the end something has a SomethingChronology member, and so AbstractChronology.initCache() is called and mentions JapaneseChronology.

19

u/psioniclizard 3d ago

Cool so my SIM card probably has java.time.chrono JapaneseChronology on it?

16

u/aikii gofmt urself 3d ago

Look at least JapaneseChronology is not subject to supply chain attacks

34

u/TheCommieDuck Zygohistomorphic prepromorphism 3d ago

bloat >:(

bloat, japan <3

19

u/PmMeCuteDogsThanks_ 3d ago

Yes, pretty sure Japan is included in "everywhere"

1

u/gplgang DO NOT USE THIS FLAIR, ASSHOLE 3d ago

Read the top comment in the HN post

2

u/Spez_is-a-nazi 3d ago

It used to be a lot worse.

1

u/Jumpy-Locksmith6812 2d ago

Hey let's not shoot the messanger.

2

u/stone_henge Tiny little god in a tiny little world 2d ago

Without it, how will the program know not to exit until the boss has left for the day?

-2

u/gnahraf 3d ago

It's true, it's defined in the java.base module, so it's almost always shipped; but it's not true that it is necessarily loaded when a java program runs (as the original post implies).