C# nested class should be compiled to static inner class for Java

Compile following code for Android:

public class MainActivity: Activity {
    public override void onCreate(Bundle savedInstanceState) {
        base.onCreate(savedInstanceState);
        ContentView = R.layout.main;
    }

    private class NestedClass{
    }
}

Then decompile it to check the generated Java code:

public class MainActivity extends Activity {

private class NestedClass {
}

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}}

I find the NestedClass is a non-static inner class in Java. As we know, nested class in C# won’t capture its outer class, so the equivalent one in Java should be static inner class which is more efficient.

Java != Oxygene. Nested classes in Oxygene are different then nested classes in Java.

Yes but I mean the RO C# => Java result can be optimized. The static inner class is more efficient than non-static one.

@Esword: It is a static inner class, just that the decompiler doesn’t see it as such.

Thanks! I’ve used reflection to check if it actually contains the this pointer of outer class and it’s not.