Is there any way to access the bytecode produced by REPL (i.e. the line of Scala you just typed and executed in REPL).
I need it for class loading to a remote node.
We can start Scala REPL by typing scala command in console/terminal.
The Scala REPL (“Read-Evaluate-Print-Loop”) is a command-line interpreter that you use as a “playground” area to test your Scala code. To start a REPL session, just type scala at your operating system command line, and you'll see this: $ scala Welcome to Scala 2.13.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_131).
Look at this thread: http://thread.gmane.org/gmane.comp.lang.scala.internals/4506. It may give you some ideas.
Is there a way for me to use the findBytesForClassName to recover the original bytes of the class? I'm trying to directly serialize REPL objects for parallelization to other JVMs and I can't use RMI.
Answer:
Look at Javap.scala and then ILoop.scala. The :javap command does exactly what you want. The key is pathToFlatName.
It would require 2.9. The participants to that thread are also SO users...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With