Scala 中Object 反编译Java 模拟运行
Scala 源代码
// Obj1.scala
package com.abc.scala
object Obj1 {
def main(args: Array[String]): Unit = {
println("I am here.")
}
def func(name:String): Unit = {
println("Greating! " + name)
}
func("ABC")
}
Scala 编译及运行
scalac Obj1.scala && scala com.abc.scala.Obj1
Java 反编译及注释
JD-GUI 反编译软件
package com.abc.from.scala;
public class Obj1 {
public static void main(String[] paramArrayOfString) {
Obj1$.MODULE$.main(paramArrayOfString);
}
}
final class Obj1$ {
private Obj1$() {
func("ABC");
}
public static final Obj1$ MODULE$;
static {
MODULE$ = new Obj1$();
}
public void main(String[] args) {
System.out.println("I am here. from JD");
}
public void func(String name) {
System.out.println((new StringBuilder()).append("Greating! ").append(name).toString());
}
}
Java 编译及运行
javac -d . Obj1.java && java com.abc.from.scala.Obj1