New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix buggy Java version check in Scaladoc tool #8904
Conversation
We have the hardened |
Interesting, thank you, I was not aware. It chokes on the underscores in some The reuse is tempting, but in this context I think I'm a bit more comfortable going with the following (IMO) maximally robust code: lazy val javaVersion: Int =
System.getProperty("java.specification.version").split('.').take(2).map(_.toIntOption) match {
case Array(Some(1), Some(n)) => n // example: 1.8.0_242
case Array(Some(n)) => n // example: 14
case Array(Some(n), _) => n // example: 11.0.7
case _ => 8 // shrug!
} I want to get this merged so I can re-run the CB and get 2.13.2 out, but I'd be fine with further revisions. |
412346f
to
c45a5f0
Compare
this is a post-2.13.1 regression, due to scala#8663 the bug was that the Java version might be e.g. "14", with no . characters at all, causing StringIndexOutOfBoundsException this was caught by the Scala community build
c45a5f0
to
8983b69
Compare
Jason said somewhere once he reused it for Java versions. I guess I can grep for it. I had touched ScalaVersion, and I also remember a laborious thing about soc wanting version checking to have no dependencies (in particular, no regex). |
Oh, it was "just a test":
|
god forbid that |
System.getProperty("java.specification.version").split('.').take(2).map(_.toIntOption) match { | ||
case Array(Some(1), Some(n)) => n // example: 1.8.0_242 | ||
case Array(Some(n)) => n // example: 14 | ||
case Array(Some(n), _) => n // example: 11.0.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case Array(Some(v), _*) => v
for both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 cleverness, -1 readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*_*)
(if (version.startsWith("1.")) { | ||
version.substring(2, 3) | ||
lazy val javaVersion: Int = | ||
System.getProperty("java.specification.version").split('.').take(2).map(_.toIntOption) match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.split('.')
is augmentString
, split("\\.")
is java which notices it's a split on literal char, not a pattern. Just to footnote, as I always have to look it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL 8
is the new shrug emoji.
Oh, soc was about |
de-duplicating this with |
The big S on my chest stands for ... Somebody. |
|
I was literally in the middle of editing my strike-thru. |
we're here all night or until CI is green, whichever comes first |
Ten-four, looks like we got us a convoy. |
this is a post-2.13.1 regression, due to #8663
the bug was that the Java version might be e.g. "14", with
no
.
character at all, causing StringIndexOutOfBoundsExceptionthis was caught by the Scala community build