我正在scala类上尝试javap -p类名,但在REPL中遇到错误

时间:2018-08-06 14:34:56

标签: scala read-eval-print-loop javap scala-repl

scala> class Department( val departmentId: Int, val departmentName: String)
defined class Department
scala> javap -p Department
<console>:12: error: not found: value javap
       javap -p Department
       ^
<console>:12: error: not found: value p
       javap -p Department
              ^

1 个答案:

答案 0 :(得分:1)

由于Scala REPL是不是 shell,因此您无法像在普通shell中那样调用javap程序。

您可以使用内置命令:javap

scala> class Department( val departmentId: Int, val departmentName: String)
defined class Department

scala> :javap -p Department
Compiled from "<console>"
public class $line4.$read$$iw$$iw$Department {
  private final int departmentId;
  private final java.lang.String departmentName;
  public int departmentId();
  public java.lang.String departmentName();
  public $line4.$read$$iw$$iw$Department(int, java.lang.String);
}

来自REPL :help

  

:javap <path|class>反汇编文件或类名