|
| 1 | +This tool allows you to connect a Scala REPL console to running Oracle (Sun) |
| 2 | +JVM processes without any prior setup at the target process. |
| 3 | + |
| 4 | +[](http://www.youtube.com/watch?v=h45QQ45D9P8) |
| 5 | + |
| 6 | +## Download |
| 7 | + |
| 8 | +Download and extract |
| 9 | +[scalive-1.0.zip](https://drive.google.com/folderview?id=0B4nP_B5KDxyPdW9xLU5USVJoSzg) |
| 10 | +(if you're using enterprise GMail account, you may need to log out to download), |
| 11 | +you will see: |
| 12 | + |
| 13 | +``` |
| 14 | +scalive-1.0/ |
| 15 | + scalive |
| 16 | + scalive.bat |
| 17 | + scalive-1.0.jar |
| 18 | +
|
| 19 | + scala-library-2.10.2.jar |
| 20 | + scala-compiler-2.10.2.jar |
| 21 | + scala-reflect-2.10.2.jar |
| 22 | +
|
| 23 | + scala-library-2.10.3.jar |
| 24 | + scala-compiler-2.10.3.jar |
| 25 | + scala-reflect-2.10.3.jar |
| 26 | +``` |
| 27 | + |
| 28 | +scala-library, scala-compiler, and scala-reflect of the appropriate version |
| 29 | +will be loaded to your running JVM process, if they have not been loaded. |
| 30 | + |
| 31 | +For convenience, Scala 2.10.2 and 2.10.3 JARs are preincluded. If your process |
| 32 | +is using a different Scala version, you need to manually download the |
| 33 | +corresponding JARs and save them as above. |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +Run the shell script `scalive` (*nix) or `scalive.bat` (Windows). |
| 38 | + |
| 39 | +To see a list of running JVM processes and their process IDs: |
| 40 | + |
| 41 | +``` |
| 42 | +scalive |
| 43 | +``` |
| 44 | + |
| 45 | +To connect a Scala REPL console to a process: |
| 46 | + |
| 47 | +``` |
| 48 | +scalive <pid> |
| 49 | +``` |
| 50 | + |
| 51 | +## How it works |
| 52 | + |
| 53 | +Scalive uses the [Attach API](https://blogs.oracle.com/CoreJavaTechTips/entry/the_attach_api) |
| 54 | +to tell the target process to load an [agent](http://javahowto.blogspot.jp/2006/07/javaagent-option.html). |
| 55 | + |
| 56 | +The agent then creates a TCP server to let the Scalive process interact with the |
| 57 | +target process. The Scalive process acts as a client. |
| 58 | + |
| 59 | +See also [liverepl](https://github.com/djpowell/liverepl), a similar REPL |
| 60 | +console for Clojure. |
| 61 | + |
| 62 | +## Known issues |
| 63 | + |
| 64 | +1. |
| 65 | + |
| 66 | +For simplicity and to avoid memory leak when you attach/detach many times, |
| 67 | +Scalive only supports processes with only the default system class loader, |
| 68 | +without additional class loaders (Ex: normal standalone JVM processes, like |
| 69 | +[Play](http://www.playframework.com/) or |
| 70 | +[Xitrum](http://ngocdaothanh.github.io/xitrum/) in production mode). |
| 71 | + |
| 72 | +Processes with multiple class loaders like |
| 73 | +[SBT](http://www.scala-sbt.org/) are not supported. |
| 74 | + |
| 75 | +2. |
| 76 | + |
| 77 | +These features will be added in the future: |
| 78 | + |
| 79 | +* [Use up/down arrows keys to navigate the console history, pasting multiline block of code etc.](https://github.com/ngocdaothanh/scalive/issues/1) |
| 80 | +* [Use tab key for autocompletion](https://github.com/ngocdaothanh/scalive/issues/2) |
0 commit comments