twosigma / beakerx

Beaker Extensions for Jupyter Notebook
http://BeakerX.com
Apache License 2.0
2.8k stars 381 forks source link

Kotlin kernel is broken on windows with default java 10 #7759

Open altavir opened 6 years ago

altavir commented 6 years ago

If the system JAVA_HOME is pointing to java 10, then kotlin kernel crashes on start. For some reason it uses system default instead of conda JDK. Also it is not compatible with JDK 10.

The kernel itself does not seem to use forbidden operations, so I think the problem is that you use outdated kotlin version. Current one is 1.2.60 and 1.3 is coming soon.

jpallas commented 6 years ago

Activating the conda environment should change JAVA_HOME to point to the conda install of openjdk8. Is that not happening in your configuration?

I tried to find information on Kotlin's compatibility with different JDK versions, like this info about Scala, but I couldn't find anything similar.

Do you know whether the current Kotlin kernel works with JDK 10 on any platform?

altavir commented 6 years ago

I did not use separate environment for kotlin, just primary conda directory. It does not make sense to do otherwise since I do not use Python for anything but notebooks.

Current Kotlin is definitely compatible with Java 9-10. It should probably work with 1.2.21, which is used in current beaker distribution as well. The problem is not with kotlin itself, but with the way kotlin scripts are interpreted in beakerx. You are using kotlin repl, which was never intended to be used this way and is undocumented and unreliable in general. I think that insides of kotlin kernel should be rewritten with JSR223 interface instead. I myself and kotlin community could contribute an implementation, but the problem is that I do not truly understand how does one create separate kernel in beakerx and how to make it accessible via conda. A tutorial of "making beakerx kernel for dummies" would be nice. Also now, that beakerx is released, the update cycle is long and I think that it would be good to completely detach kotlin kernel from the main distribution and allow it to develop on it own.

jpallas commented 6 years ago

(Side note: I'm just a user and occasional contributor, I don't speak for two sigma or the BeakerX project.)

I don't think BeakerX is tested against Java 9 or 10. Java 9 definitely introduced some incompatible changes around class loaders, so there's definitely potential for problems. That's all I know for sure. I wouldn't be surprised if there is some incompatibility that affects some or all of the kernels. If you are not using an environment with openjdk8, I think you are in uncharted waters.

For what it's worth, I stumbled on this complaint about the performance of Kotlin's JSR223 interface. I have no idea whether the issue raised was valid then or is still, but JSR223 might not be the solution you're hoping for. The only other Jupyter kernel for kotlin I can find looks like it also uses the jetbrains kotlin repl.

There's no stable API defined for the kernel base, as it's not intended to be a stand-alone library. I wouldn't try to treat it like one; in my experience with other projects, that's not likely to work well. I'd suggest following the model that github naturally supports: make a fork, keep the fork as up to date with the upstream as possible, and offer pull requests when you have something you think is an improvement. In the worst case, you could do your own releases of your kernel, but, yeah, that would have a learning curve.

altavir commented 6 years ago

The problem you pointed at is not crucial for notebook mode since it appears only only on kernel initialization. Anyway, we can interact with kotlin developers on that, I think that they will be happy to fix problems as they arise. Kotlin JSR 223 support is a rather new development, so we can fix everything as we go.

There were plans (even before beakerx) to separate each kernel to a stand-alone library and also there were a lot of requests to create a tutorial on building your own kernel. So I would urge developers to move in that direction. Meanwhile, I will play around with JSR 223 and see if it is ready for use.

By the way, contrary to REPL, JSR 223 supports bindings like groovy, so it is possible to reload kernel (change classpath, etc.) without loosing data and also share variables across JVM kernels.

EfimovVladimir commented 6 years ago

Can't reproduce this (windows 7). I've installed java 10 , changed JAVA_HOME for java10 . Console displays for me about version this: image

Notebook with java kernel displays for me java 8 image

Kotlin works fine for me.

altavir commented 6 years ago

Here is the situation for me: capture

1.8.0_131 is where the JAVA_HOME points. I have exactly the same situation on another machine with windows 10. It has different version of JDK 8, but kernels are pointing at it and not at conda JDK. In both cases I've installed beakerx in root environment by conda install -c conda-forge beakerx

EfimovVladimir commented 6 years ago

@altavir Does the conda list command display that you have openjdk package on your root conda environment?

altavir commented 6 years ago

openjdk 8.0.121 1 It does