Question

I decompiled a DLL that originally came from J#. I see the following attributes that are absent from the original code:

[JavaFlags(0)]
public ToolBarButton toolBarButtonProg;

[JavaFlags(8)]
public static int lastClass;

I see that those JavaFlags are defined in the following J# namespace.

namespace com.ms.vjsharp.cor
{
  [AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
  public class JavaFlags : Attribute
  {
    public int attr;

    public JavaFlags(int attr)
    {
      this.attr = attr;
    }
  }
}

But what is the purpose of these attributes?

Was it helpful?

Solution

This attribute is likely added by the J# compiler to represent Java constructs which are not directly represented in the CLR. For example, there is no visibility modifier in the CLR which exactly mirrors the protected modifier in Java, so the compiler produces a method that is public in the CLR along with a [JavaFlags(4)] attribute so the J# compiler knows to treat the method as protected when compiling other Java code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top