Skip to content

doc-jar fails on OpenJDK 9+ #376

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

Closed
adamretter opened this issue Dec 10, 2019 · 12 comments
Closed

doc-jar fails on OpenJDK 9+ #376

adamretter opened this issue Dec 10, 2019 · 12 comments

Comments

@adamretter
Copy link

The error is:

[INFO] --- scala-maven-plugin:4.3.0:doc-jar (scala-doc-jar) @ csv-validator-core ---
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at scala_maven_executions.MainHelper.runMain(MainHelper.java:161)
	at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
Caused by: java.lang.NoClassDefFoundError: javax/tools/ToolProvider
	at scala.reflect.io.JavaToolsPlatformArchive.iterator(ZipArchive.scala:301)
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
	at scala.reflect.io.AbstractFile.foreach(AbstractFile.scala:92)
	at scala.tools.nsc.util.DirectoryClassPath.traverse(ClassPath.scala:277)
	at scala.tools.nsc.util.DirectoryClassPath.x$15$lzycompute(ClassPath.scala:299)
	at scala.tools.nsc.util.DirectoryClassPath.x$15(ClassPath.scala:299)
	at scala.tools.nsc.util.DirectoryClassPath.packages$lzycompute(ClassPath.scala:299)
	at scala.tools.nsc.util.DirectoryClassPath.packages(ClassPath.scala:299)
	at scala.tools.nsc.util.DirectoryClassPath.packages(ClassPath.scala:264)
	at scala.tools.nsc.util.MergedClassPath$$anonfun$packages$1.apply(ClassPath.scala:358)
	at scala.tools.nsc.util.MergedClassPath$$anonfun$packages$1.apply(ClassPath.scala:358)
	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.tools.nsc.util.MergedClassPath.packages$lzycompute(ClassPath.scala:358)
	at scala.tools.nsc.util.MergedClassPath.packages(ClassPath.scala:353)
	at scala.tools.nsc.symtab.SymbolLoaders$PackageLoader$$anonfun$doComplete$1.apply$mcV$sp(SymbolLoaders.scala:269)

Adding the option-nobootcp to the args for doc-jar seems to be a viable workaround, i.e.:

                      <execution>
                        <id>scala-doc-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>doc-jar</goal>
                        </goals>
                        <configuration>
                            <args>
                                <arg>-nobootcp</arg>
                            </args>
                        </configuration>
                    </execution>
@slandelle
Copy link
Collaborator

Can't reproduce, please provide a simple sample project to reproduce (not your full multi-module project with tons of plugins).

@adamretter
Copy link
Author

@slandelle is the output from Travis CI with logs, which shows JDK 1.8 passing, but JDK 9, 10, and 11 failing with that error helpful? You can see it here - https://travis-ci.org/digital-preservation/csv-validator/builds/623143738

@slandelle
Copy link
Collaborator

slandelle commented Dec 10, 2019

As I said, your project is way too complicated and involves lots of plugins to be able to investigate in isolation.
Run mvn package scala:doc-jar against https://github.com/davidB/scala-maven-plugin/tree/master/samples/prj_multi_modules with Java 11 and you'll see the javadoc jars are properly generated.

@asmotrich
Copy link

@slandelle I see exactly the same failure with the same stack trace using scala-maven-plugin 4.3.0 with the prj_multi_modules but using Scala 2.11.12 and Java 11. Scala 2.12.X works fine though.

@SethTisue
Copy link

using Scala 2.11.12 and Java 11. Scala 2.12.X works fine though

I think this is an upstream problem in Scala 2.11 (and presumably 2.10 as well), rather than a Maven problem per se: scala/bug#10603

that ticket also recommends adding -nobootcp to the Scala compiler flags, as Adam recommends above

@asmotrich
Copy link

The -nobootcp flag did not help with Scala 2.11 on Java 11.

@SethTisue
Copy link

The -nobootcp flag did not help with Scala 2.11 on Java 11.

Can you provide a simple sample project that demonstrates this?

@asmotrich
Copy link

@SethTisue you can take your sample project samples/prj_multi_modules and just change the Scala version to 2.11.12. I tried with and without -nobootcp, no difference. But as you mentioned before, this is probably Scala 2.11 issue.

@slandelle
Copy link
Collaborator

Generally speaking, it seems scala-compiler 2.11 doesn't work properly with Java 11.

Switching to 2.11.11 here and running mvn package with Java 11 crashes:

error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
	at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
	at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
	at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
	at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
	at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
	at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
	at scala.reflect.internal.Mirrors$RootsBase.getClassByName(Mirrors.scala:102)
	at scala.reflect.internal.Mirrors$RootsBase.getRequiredClass(Mirrors.scala:105)
	at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:257)
	at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:257)
	at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1390)
	at scala.tools.nsc.Global$Run.<init>(Global.scala:1242)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
	at scala.tools.nsc.MainClass.doCompile(Main.scala:23)
	at scala.tools.nsc.Driver.process(Driver.scala:51)
	at scala.tools.nsc.Main.process(Main.scala)

Anyway, I'm closing this issue as that's really not something that can be fixed here, it could only be fixed in .

Now, let's be realistic:

  • Scala 2.11.11 was released on 13-Apr-2017
  • Java 11 reached GA on 25-Sept-2018

We can safely say Scala 2.11 has reached end-of-life and Java 11 support is very unlikely to happen. And IMHO, it shouldn't.

Libraries are dropping Scala 2.11 support as well:

Your Scala version has been dead for 2.5 years, time to upgrade, people!

@SethTisue
Copy link

I think Stephane is right to close the ticket, but we can still discuss workarounds.

Stephane writes:

Generally speaking, it seems scala-compiler 2.11 doesn't work properly with Java 11.

My working hypothesis is that it can be always be made to work by passing -nobootcp, as per scala/bug#10603

Switching to 2.11.11 here and running mvn package with Java 11 crashes:

True, but adding -nobootcp fixes it: SethTisue@217d282

@asmotrich writes:

you can take your sample project samples/prj_multi_modules and just change the Scala version to 2.11.12. I tried with and without -nobootcp, no difference

that wasn't my experience. when I tried it, SethTisue@217d282 fixes both mvn package and mvn package scala:doc-jar

you say it doesn't work for you in your project. perhaps you are doing something differently?

@slandelle
Copy link
Collaborator

you say it doesn't work for you in your project. perhaps you are doing something differently?

On my side, it didn't work but I configured at execution level instead of root one, which might have been wrong (I never remember how this works...).

@asmotrich
Copy link

asmotrich commented Dec 17, 2019 via email

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

No branches or pull requests

4 participants