Repository navigation
generator output should avoid mentioning non-public types #11849
Description
Context: dotnet/java-interop#1261
dotnet/java-interop#1261 describes a scenario in which public interfaces inherit package-private types:
package net.dot.jni.test;
/* package */ interface BaseInterface {
String m();
}
public interface InterfaceMethodInheritance extends BaseInterface, PublicInterface {
String n();
}
/* package */ interface InternalInterface {
String o();
}
public interface PublicInterface extends InternalInterface {
String p();
}The above is part of the tests/Java.Base-Tests build. After Java.Base-Tests is built, the following file is created: tests/Java.Base-Tests/obj/$(Configuration)-net8.0/_ji/mcw/Net.Dot.Jni.Test.IInterfaceMethodInheritance.cs
which contains:
namespace Net.Dot.Jni.Test {
internal partial class IInterfaceMethodInheritanceInvoker : global::Java.Lang.Object, IInterfaceMethodInheritance {
static readonly JniPeerMembers _members_net_dot_jni_test_BaseInterface = new JniPeerMembers ("net/dot/jni/test/BaseInterface", typeof (IInterfaceMethodInheritanceInvoker));
static readonly JniPeerMembers _members_net_dot_jni_test_InterfaceMethodInheritance = new JniPeerMembers ("net/dot/jni/test/InterfaceMethodInheritance", typeof (IInterfaceMethodInheritanceInvoker));
static readonly JniPeerMembers _members_net_dot_jni_test_InternalInterface = new JniPeerMembers ("net/dot/jni/test/InternalInterface", typeof (IInterfaceMethodInheritanceInvoker));
static readonly JniPeerMembers _members_net_dot_jni_test_PublicInterface = new JniPeerMembers ("net/dot/jni/test/PublicInterface", typeof (IInterfaceMethodInheritanceInvoker));
}
}The concern is that the above snippet mentions two non-public types: net/dot/jni/test/BaseInterface and net/dot/jni/test/InternalInterface. If (when?) these types "go away" in the future -- they're not public, and thus could be removed or renamed at any point in time -- then the type initializer for IInterfaceMethodInheritanceInvoker will throw an exception, as e.g. new JniPeerMembers ("net/dot/jni/test/BaseInterface", …) will throw an exception because net/dot/jni/test/BaseInterface will not be found.
Activity
[generator] Fix StackOverflow when copying DIM via private interfaces (…
dotnet-policy-service commentedon Jul 1, 2026
We suspect this issue is stale and no longer relevant. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
dotnet-policy-service commentedon Jul 15, 2026
This issue will now be closed since it had been marked "possibly-stale" but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.