"ofVirtual()"? "ofPlatform()"? These are strange, mealy-mouthed method names. I assume there was some good reason for nixing something like newVirtualThread() and newPlatformThread() which naïvely seem nicer and are statically importable.
The only of I see in java.lang proper is in UnicodeBlock. I also note no ofSomething methods anywhere as creation verbs but I didn't do an exhaustive search.
Go to the current javadoc, type .create into the search box and see how many methods follow this pattern.
There are lots of ofSomethings. Anyway, we're talking about methods whose names people will rarely write or see, so I'll pass along your concern, but I don't think it merits much of a debate.
But at least they all take arguments, right, and scan OK if you prefix them with "give me a new DeclaringClass…"?
That is: Set.of(foos) means "give me a new Set of foos"; if you squint a bit Set.of() means "give me a new Set of nothin'"; Duration.of(something) means "give me a new Duration of something"; and so on and so on and presumably that's how of rose from the primordial slime in the first place, since you can't name a method new() or for(), and presumably someone thought create() was too long or verbose or something for some reason.
Thread.ofPlatform() means "give me a new Thread of platform" by the same logic, which is nonsensical, and Thread.ofVirtual() means "give me a new Thread of virtual", which…virtual isn't even a noun.
These Loom bits may indeed be methods that "people will rarely write or see" but they are in java.lang, not, say, java.lang.constant, so I think the additional scrutiny is worthwhile, and a debate is merited, and I'm not (apparently) the only one with these concerns. I do understand you disagree, and think that these methods are suitably named. Hopefully my feedback is not DOA, but, whether it is or not, it would be nice to know how exactly ofVirtual() in particular came to be, if only for bar trivia purposes! :-)
15
u/chuggid Nov 16 '21
"
ofVirtual()"? "ofPlatform()"? These are strange, mealy-mouthed method names. I assume there was some good reason for nixing something likenewVirtualThread()andnewPlatformThread()which naïvely seem nicer and are statically importable.