Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access bytecode created by Scala REPL

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.

like image 977
Nikita Ivanov Avatar asked Mar 27 '11 07:03

Nikita Ivanov


People also ask

How do I access scala REPL?

We can start Scala REPL by typing scala command in console/terminal.

What is scala REPL?

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).


1 Answers

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...

like image 178
huynhjl Avatar answered Oct 11 '22 14:10

huynhjl