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

ByteBuffer covariant incompatibilities with Java 8 when built with Java 9 or newer #299

Closed
lokkju opened this issue Mar 6, 2019 · 3 comments

Comments

@lokkju
Copy link

lokkju commented Mar 6, 2019

On Ubuntu 18.04 with libjline2-java_2.14.16, scala, sbt, and other REPLs that use jline2 don't display user input when typed. This seems to be caused by java.nio.ByteBuffer.limit covariance under JDK9 and later. Debian/Ubuntu package maintainers build the package with JDK11 by default, resulting in bytecode incompatibility with JDK8 and lower.

This can be fixed by adding a "maven.compiler.release" property to the pom.xml, but this then prevents JDK8 from being used to build the project, so I'm not sure if this is the best solution; or if this should be considered a packaging bug. Your input on this is welcome!

Welcome to Scala 2.11.12 (OpenJDK 64-Bit Server VM, Java 1.8.0_191).
Type in expressions for evaluation. Or try :help.
Trying to instantiate an InteractiveReader from scala.tools.nsc.interpreter.jline.InteractiveReader
Trying to instantiate an InteractiveReader from scala.tools.nsc.interpreter.jline_embedded.InteractiveReader
All InteractiveReaders tried: 
  - scala.tools.nsc.interpreter.jline.InteractiveReader --> 
	java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$scala$tools$nsc$interpreter$ILoop$$instantiater$1$1.apply(ILoop.scala:858)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$scala$tools$nsc$interpreter$ILoop$$instantiater$1$1.apply(ILoop.scala:855)
	at scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$mkReader$1(ILoop.scala:862)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$22$$anonfun$apply$10.apply(ILoop.scala:873)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$22$$anonfun$apply$10.apply(ILoop.scala:873)
	at scala.util.Try$.apply(Try.scala:192)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$22.apply(ILoop.scala:873)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$22.apply(ILoop.scala:873)
	at scala.collection.immutable.Stream.map(Stream.scala:418)
	at scala.tools.nsc.interpreter.ILoop.chooseReader(ILoop.scala:873)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1$$anonfun$newReader$1$1.apply(ILoop.scala:893)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.newReader$1(ILoop.scala:893)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.scala$tools$nsc$interpreter$ILoop$$anonfun$$preLoop$1(ILoop.scala:897)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1$$anonfun$startup$1$1.apply(ILoop.scala:964)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:990)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:891)
	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:891)
	at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)
	at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:891)
	at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
	at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
	at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
	at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
	at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;
	at jline.internal.InputStreamReader.<init>(InputStreamReader.java:104)
	at jline.console.ConsoleReader.setInput(ConsoleReader.java:330)
	at jline.console.ConsoleReader.<init>(ConsoleReader.java:248)
	at jline.console.ConsoleReader.<init>(ConsoleReader.java:236)
	at jline.console.ConsoleReader.<init>(ConsoleReader.java:224)
	at scala.tools.nsc.interpreter.jline.JLineConsoleReader.<init>(JLineReader.scala:64)
	at scala.tools.nsc.interpreter.jline.InteractiveReader.<init>(JLineReader.scala:33)
	... 28 more
@gnodet
Copy link
Member

gnodet commented Mar 6, 2019

I think the same kind of trick that was used in apache/felix@2ef06ec could be used in jline.

@lokkju
Copy link
Author

lokkju commented Mar 6, 2019

Awesome, that's probably a better fix

@gnodet gnodet closed this as completed in 12b98d9 Mar 8, 2019
@lokkju
Copy link
Author

lokkju commented Mar 25, 2019

@gnodet might you leave this open until a trick like you mentioned is implemented?

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

2 participants