I have the following scala code
package x.y
package object config {
type SomeType = AnotherType[YetAnotherOne]
}
The following is what JDGUI makes of it in Java
package x.y.config;
import scala.reflect.ScalaSignature;
@ScalaSignature(bytes="\006\001...")
public final class package {}
And...
package x.y.config;
public final class package$
{
public static final MODULE$;
static
{
new ();
}
private package$()
{
MODULE$ = this;
}
}
I have no problem with the disappearance of the type
definition(I expect that scalac does away with it)
I do wish to know specifically what the following is:
static
{
new ();
}
The MODULE$ gets explained here.
Thing is, when I cut and paste the Java code into my IDE it does not compile. Neither the non-typed public static final MODULE$;
nor the new ();
do.
Is it just some decompiling misalignment? Am I missing something?
What is going on here?
Edit:
as per request:
javap -c -l -private package\$.class
Compiled from "package.scala"
public final class x.y.config.package$ {
public static final x.y.config.package$ MODULE$;
public static {};
Code:
0: new #2 // class x/y/config/package$
3: invokespecial #12 // Method "<init>":()V
6: return
private x.y.config.package$();
Code:
0: aload_0
1: invokespecial #13 // Method java/lang/Object."<init>":()V
4: aload_0
5: putstatic #15 // Field MODULE$:Lx/y/config/package$;
8: return
LineNumberTable:
line 9: 0
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this Lx/y/config/package$;
}