Skip to content
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

JDK API mappings not working sometimes (?) #347

Open
armanbilge opened this issue Jul 18, 2022 · 8 comments
Open

JDK API mappings not working sometimes (?) #347

armanbilge opened this issue Jul 18, 2022 · 8 comments

Comments

@armanbilge
Copy link
Member

I put a dogfood test for this inside the site plugin.

[error] .../sbt-typelevel/site/src/main/scala/org/typelevel/sbt/site/TypelevelHeliumExtensions.scala:47:3: Could not find any member to link for "java.net.URL".
[error]   /**
[error]   ^
[error] one error found
$ java -version
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment Homebrew (build 11.0.15+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.15+0, mixed mode)
@satorg
Copy link
Contributor

satorg commented Jul 18, 2022

On temurin11 it fails as well:

$ java -version
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment Temurin-11.0.15+10 (build 11.0.15+10)
OpenJDK 64-Bit Server VM Temurin-11.0.15+10 (build 11.0.15+10, mixed mode)

@armanbilge
Copy link
Member Author

Aha, thanks for that. I was able to reproduce with temurin 11 on linux. We should add that to CI and fix it :)

@satorg
Copy link
Contributor

satorg commented Jul 18, 2022

And which JDK is it currently working on? Did you have it succeeding on any JVM locally?

@armanbilge
Copy link
Member Author

It works on the JDK 8 and JDK 17 temurins used in CI.

@armanbilge
Copy link
Member Author

Huh. Locally it fails for me even with temurin 17. Ok, this is pretty bizarre.

@DavidGregory084
Copy link
Member

FWIW I have been seeing this intermittently on sbt-tpolecat too when running scripted tests

sbt:sbt-tpolecat> scripted
[info] Wrote /Users/davidgregory/Repos/sbt-tpolecat/plugin/target/scala-2.12/sbt-1.0/sbt-tpolecat-0.4.1+31-2f9e1eda+20220728-1550-SNAPSHOT.pom
[info] Main Scala API documentation to /Users/davidgregory/Repos/sbt-tpolecat/plugin/target/scala-2.12/sbt-1.0/api...
[info] compiling 1 Scala source to /Users/davidgregory/Repos/sbt-tpolecat/plugin/target/scala-2.12/sbt-1.0/classes ...
model contains 17 documentable templates
[error] /Users/davidgregory/Repos/sbt-tpolecat/plugin/src/main/scala/io/github/davidgregory084/ScalacOptions.scala:409:3: Could not find any member to link for "java.lang.Runtime#availableProcessors".
[error]   /** Configures the number of worker threads for the compiler backend.
[error]   ^
[error] one error found

@armanbilge
Copy link
Member Author

@DavidGregory084 sure, but does sbt-tpolecat have something like this in its settings? It's a known issue but supposedly we solved it 😅

private val javaApiMappings = {
// scaladoc doesn't support this automatically before 2.13
val baseUrl = javaMajorVersion match {
case v if v < 11 => url(s"https://docs.oracle.com/javase/${v}/docs/api/")
case v => url(s"https://docs.oracle.com/en/java/javase/${v}/docs/api/java.base/")
}
doc / apiMappings ~= { old =>
val runtimeMXBean = ManagementFactory.getRuntimeMXBean
val oldSchool = Try(
if (runtimeMXBean.isBootClassPathSupported)
runtimeMXBean
.getBootClassPath
.split(File.pathSeparatorChar)
.map(file(_) -> baseUrl)
.toMap
else Map.empty
).getOrElse(Map.empty)
val newSchool = Map(file("/modules/java.base") -> baseUrl)
// Latest one wins. We are providing a fallback.
oldSchool ++ newSchool ++ old
}

@DavidGregory084
Copy link
Member

Uhhhhh no 😆 I'm still confused that it's intermittent though in both cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants