Kotlin / kotlin-jupyter

Kotlin kernel for Jupyter/IPython
Apache License 2.0
1.12k stars 105 forks source link

readLine causing java.lang.ArrayIndexOutOfBoundsException #84

Closed jmagana2000 closed 4 years ago

jmagana2000 commented 4 years ago

When trying to use readLine in Jupyter Notebook it raises an exception

val name = readLine()

java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 6 org.jetbrains.kotlin.jupyter.JupyterConnection$StdinInputStream.read(connection.kt:91) kotlin.io.LineReader.readLine(Console.kt:173) kotlin.io.ConsoleKt.readLine(Console.kt:148) Line_19_jupyter.(Line_19.jupyter.kts:5) java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:96) kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:41) kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt) kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:51) org.jetbrains.kotlin.jupyter.ReplForJupyterImpl$doEval$resultWithDiagnostics$1.invokeSuspend(repl.kt:486) kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56) kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274) kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84) kotlinx.coroutines.BuildersKtBuildersKt.runBlocking(Builders.kt:59) kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) kotlinx.coroutines.BuildersKtBuildersKt.runBlocking$default(Builders.kt:38) kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source) org.jetbrains.kotlin.jupyter.ReplForJupyterImpl.doEval(repl.kt:486) org.jetbrains.kotlin.jupyter.ReplForJupyterImpl.eval(repl.kt:342) org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:143) org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt) org.jetbrains.kotlin.jupyter.ProtocolKt.evalWithIO(protocol.kt:356) org.jetbrains.kotlin.jupyter.ProtocolKt.shellMessagesHandler(protocol.kt:142) org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:104) org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:59)

altavir commented 4 years ago

The exception is bad, but it should not work in Jupyter anyway. We need to think about widgets support for that.