A couple of days ago, Dawid Weiss filed a bug related to @ikvm.lang.Internal and while fixing the bug I realized that the feature has significantly evolved since its introduction, but that was never documented.
I originally introduced @ikvm.lang.Internal as a relatively simple workaround for an annoying short coming of Java and mainly for my own convenience in writing the core class libraries, but when I added support InternalsVisibleAttribute things became more complex.
The support for InternalsVisibleToAttribute in itself is something that evolved from relatively weak to the current state of mostly working (there is still one known issue, where InternalsVisibleToAttribute annotations won't be recognized during a multi target build, but this isn't very high priority, because in the common cases ikvmc will automatically add (and recognize) the InternalVisibleToAttribute when needed during multi target compilation.)
So what does @ikvm.lang.Internal do?
It's actually still relatively simple: It marks a type or member as "internal". This means that its Java access modifiers will be ignored (even private members can be marked as internal) and that any other assembly that has access to the assembly's internals will be able to access it (in the case of members, you also need to be able to access to containing type, of course.)
For members this looks a lot like the C# internal access modifier, but for types there is a significant difference to be aware of. From Java code in another assembly (that is designated by InternalsVisibleTo) you can only access types that are explicitly marked with @ikvm.lang.Internal, note that this is unlike C# where any non-nested type can be accessed.
At runtime, when you use reflection to inspect a type or member marked with @ikvm.lang.Internal, it will appear as package accessible. When you use reflection to invoke, set or get a member, it will be treated as internal.
I fixed the bug Dawid reported and also fixed the "effectively final" optimization to not mark classes with @ikvm.lang.Internal as final. The fixes will be in the next 0.44 release candidate.
I apologize for the lameness of this, but the comment spam was driving me nuts.
In order to be able to post a comment, you need to answer a simple question. Hopefully this question
is easy enough not to annoy serious commenters, but hard enough to keep the spammers away.
Anti-Spam Question: What method on java.lang.System returns an object's original hashcode (i.e. the
one that would be returned by java.lang.Object.hashCode() if it wasn't overridden)? (case is significant)
Powered by: newtelligence dasBlog 2.3.12105.0
© Copyright 2017, Jeroen Frijters