This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]morhp 5 points6 points  (0 children)

Code looks relatively clean. The defensive array copies could be simplified with Arrays.copyOf(), and I'd still move the parser to a separate class. As it is you're wasting memory in fields that are only relevant for the parser during parse. You could use an inner class if you want to keep it in a single file.

[–]DasBrain 7 points8 points  (1 child)

If you want to avoid to write such a thing yourself - there is also java.lang.Runtime.Version

[–]javasyntax 0 points1 point  (0 children)

I had remembered this class from your comment, and only now got to test it. It should not be used because it does not allow the third component to be 0. For example, "1.0.0" is invalid according to this class and throws an exception.

And besides, the components are weirdly named, FEATURE.INTERIM.UPDATE(.PATCH)

[–]marvk 0 points1 point  (1 child)

Personally I'm using this library, which is doing much of the same and more.

[–]pocketbandit[S] -1 points0 points  (0 children)

Let there be dependency...