Skip to content

Commit 3a44ae9

Browse files
committed
Drop Java 8 leftovers from comment and test helper
1 parent f941ff8 commit 3a44ae9

2 files changed

Lines changed: 12 additions & 34 deletions

File tree

semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ public Void visitPackage(PackageTree node, Void unused) {
256256
// Stop traversal at the package declaration. JDK 17+ TreePathScanner
257257
// recurses into the package name's identifiers and would emit a
258258
// self-reference for `package X.Y;`; JDK 11 does not. Skipping the
259-
// whole package subtree keeps semanticdb output stable across JDKs and
260-
// matches the long-standing JDK 8/11 behavior of not emitting a
261-
// reference for the package declaration itself.
259+
// whole package subtree keeps semanticdb output stable across JDKs by
260+
// matching the JDK 11 behavior of not emitting a reference for the
261+
// package declaration itself.
262262
return null;
263263
}
264264

tests/buildTools/src/test/scala/tests/BaseBuildToolSuite.scala

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -148,51 +148,29 @@ abstract class BaseBuildToolSuite extends MopedSuite(ScipJava.app) {
148148
}
149149

150150
object BaseBuildToolSuite {
151+
// Major version of the JVM that `java` on PATH resolves to. Compiled and
152+
// executed as a subprocess because the test JVM may differ from PATH.
151153
lazy val externalJavaVersion: Int = {
152154
val tmpDir = os.temp.dir()
153-
var version = Option.empty[String]
154155
try {
155156
os.write(tmpDir / "PrintJavaVersion.java", PrintJavaVersion)
156-
157157
os.proc("javac", "PrintJavaVersion.java").call(cwd = tmpDir)
158-
159-
version = Some(
160-
os.proc("java", "PrintJavaVersion").call(cwd = tmpDir).out.text()
161-
)
158+
os.proc("java", "PrintJavaVersion")
159+
.call(cwd = tmpDir)
160+
.out
161+
.text()
162+
.trim
163+
.toInt
162164
} finally {
163165
os.remove.all(tmpDir)
164166
}
165-
166-
version
167-
.map(parseJavaVersion)
168-
.getOrElse(sys.error("Failed to detect external JDK version"))
169-
}
170-
171-
private def parseJavaVersion(raw: String) = {
172-
val prop = raw.takeWhile(c => c.isDigit || c == '.')
173-
174-
val segments = prop.split("\\.").toList
175-
176-
segments match {
177-
// Java 17.0.1, 11.0.20.1, ..
178-
case modern :: _ :: _ :: rest =>
179-
modern.toInt
180-
// Java 12
181-
case modern :: Nil =>
182-
modern.toInt
183-
case other =>
184-
sys.error(
185-
s"Cannot process [java.version] property, unknown format: [$raw]"
186-
)
187-
}
188167
}
189168

190169
private val PrintJavaVersion = """
191170
public class PrintJavaVersion {
192171
public static void main(String[] args) {
193-
System.out.print(System.getProperty("java.version"));
172+
System.out.print(Runtime.version().feature());
194173
}
195174
}
196-
197175
"""
198176
}

0 commit comments

Comments
 (0)