cegredev / josi

A Java library designed to make making decisions based on the current operating system easier.
MIT License
36 stars 4 forks source link

Unix is not Linux #7

Open dbwiddis opened 3 years ago

dbwiddis commented 3 years ago

See the backronym for GNU.

Interestingly, Current OpenJDK versions only include os.name for AIX in the Unix category, having dropped support for Solaris; but it's definitely distinct from Linux. Looking in the history, they did previously include Solaris and AIX as distinct OS Types from Linux.

There should either be a separate Family for UNIX under which Solaris should fall, as well as AIX, and any other Unix flavors you want to support, or if you only want to support AIX and Solaris (matching pre-2020 OpenJDK with Solaris support) then you should add a separate family for AIX.

Should you choose to group UNIX separately, you might include the following values from os.name in older closed-source JDK versions, or versions ported to the respective OS's: FreeBSD, NetBSD, OpenBSD, DragonflyBSD, HP-UX, AIX, Solaris (also SunOS).

I'm sure the z/OS people want support too but I can't find it definitively.

cegredev commented 3 years ago

Interesting, thanks a lot for the info!

You're right, Unix is not Linux and it doesn't make sense the way it is implemented right now. I think having a separate family for Unix based systems is probably the better solution here, as I want to avoid bloating the family enum. There is just one major flaw with this I can think of at the moment, which is that Linux and Mac would still be their own families and people would probably expect something like UBUNTU.isFamily(Family.UNIX) to return true, even though it would return false.

There are ways to fix this however, like for example introducing something like "child-families" or making the family field of OS an array/list. I'll have to think about this and experiment with it before I'll be sure what to do.

dbwiddis commented 3 years ago

Don't even get started on whether macOS is Unix and what XNU is. 😁

If you want to include Linux (and macOS) in an umbrella "Unix-like" or "*nix" family that could work, where the "Unix-like super-family" includes macOS, Linux, and "pure" Unix flavors. Not something to rush into, though.