Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/net/JNet/Specific/JNetEventResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public JNetEventResult(IJVMBridgeBaseInitializer initializer) : base(initializer
/// <summary>
/// The <see cref="object"/> to be returned to the JVM side
/// </summary>
public object ReturnData { get => IExecute("getReturnData"); set => IExecute("setReturnData", value); }
public object ReturnData { get => IExecute("getReturnData"); } // disabled since JVM side raise an exception in any case set => IExecute("setReturnData", value); }
/// <summary>
/// Helper function to set both <see cref="HasOverride"/> and <see cref="ReturnData"/>
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/net/JNetReflector/InternalMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,7 @@ static string AnalyzeMethods(this Class classDefinition, IEnumerable<Class> clas
template = Template.GetTemplate(Template.SingleMethodTemplate);
singleMethod = template.Replace(AllPackageClasses.ClassStub.MethodStub.DECORATION, jDecoration.ToString())
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_EXECUTION, listenerHandlerType)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER, returnType == "void" ? string.Empty : AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER_FORMAT)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_NAME, baseHandlerName)
.Replace(AllPackageClasses.ClassStub.MethodStub.MODIFIER, modifier)
.Replace(AllPackageClasses.ClassStub.MethodStub.RETURNTYPE, returnType)
Expand Down Expand Up @@ -2049,6 +2050,7 @@ static string AnalyzeMethods(this Class classDefinition, IEnumerable<Class> clas
template = Template.GetTemplate(Template.SingleMethodTemplate);
singleMethod = template.Replace(AllPackageClasses.ClassStub.MethodStub.DECORATION, jDecoration.ToString())
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_EXECUTION, listenerHandlerType)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER, returnType == "void" ? string.Empty : AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER_FORMAT)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_NAME, baseHandlerName)
.Replace(AllPackageClasses.ClassStub.MethodStub.MODIFIER, modifier)
.Replace(AllPackageClasses.ClassStub.MethodStub.RETURNTYPE, returnType)
Expand Down Expand Up @@ -2078,6 +2080,7 @@ static string AnalyzeMethods(this Class classDefinition, IEnumerable<Class> clas
template = Template.GetTemplate(Template.SingleMethodTemplate);
singleMethod = template.Replace(AllPackageClasses.ClassStub.MethodStub.DECORATION, jDecoration.ToString())
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_EXECUTION, listenerHandlerType)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER, returnType == "void" ? string.Empty : AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER_FORMAT)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_NAME, baseHandlerName)
.Replace(AllPackageClasses.ClassStub.MethodStub.MODIFIER, modifier)
.Replace(AllPackageClasses.ClassStub.MethodStub.RETURNTYPE, returnType)
Expand Down Expand Up @@ -2149,6 +2152,7 @@ static string AnalyzeMethods(this Class classDefinition, IEnumerable<Class> clas
{
singleMethod = template.Replace(AllPackageClasses.ClassStub.MethodStub.DECORATION, jDecoration.ToString())
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_EXECUTION, listenerHandlerType)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER, returnType == "void" ? string.Empty : AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER_FORMAT)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_NAME, baseHandlerName)
.Replace(AllPackageClasses.ClassStub.MethodStub.MODIFIER, modifier)
.Replace(AllPackageClasses.ClassStub.MethodStub.RETURNTYPE, returnType)
Expand Down Expand Up @@ -2178,6 +2182,7 @@ static string AnalyzeMethods(this Class classDefinition, IEnumerable<Class> clas

singleMethod = template.Replace(AllPackageClasses.ClassStub.MethodStub.DECORATION, jDecoration.ToString())
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_EXECUTION, listenerHandlerType)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER, returnType == "void" ? string.Empty : AllPackageClasses.ClassStub.MethodStub.LISTENER_DISPOSE_HANDLER_FORMAT)
.Replace(AllPackageClasses.ClassStub.MethodStub.LISTENER_HANDLER_NAME, baseHandlerName)
.Replace(AllPackageClasses.ClassStub.MethodStub.MODIFIER, modifier)
.Replace(AllPackageClasses.ClassStub.MethodStub.RETURNTYPE, returnType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ ALLPACKAGE_CLASSES_STUB_CLASS_DECORATION_PLACEHOLDER
public partial class ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER : ALLPACKAGE_CLASSES_STUB_BASECLASS_PLACEHOLDERALLPACKAGE_CLASSES_STUB_WHERECLAUSES_PLACEHOLDER
{
const string _bridgeClassName = "ALLPACKAGE_CLASSES_STUB_JAVACLASS_PLACEHOLDER";

/// <summary>
/// Internal constructor: used internally from JCOBridge
/// Initializer used internally by JCOBridge. Do not use directly.
/// </summary>
[global::System.Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(IJVMBridgeBaseInitializer initializer) : base(initializer) { }

/// <summary>
/// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class
/// Generic constructor used by JCOBridge when a derived class needs to forward arguments to the base JVMBridgeBase class.
/// </summary>
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(params object[] args) : base(args) { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ ALLPACKAGE_CLASSES_STUB_CLASS_DECORATION_PLACEHOLDER
public partial class ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER : ALLPACKAGE_CLASSES_STUB_BASECLASS_PLACEHOLDERALLPACKAGE_CLASSES_STUB_WHERECLAUSES_PLACEHOLDER
{
const string _bridgeClassName = "ALLPACKAGE_CLASSES_STUB_JAVACLASS_PLACEHOLDER";

/// <summary>
/// Internal constructor: used internally from JCOBridge
/// Initializer used internally by JCOBridge. Do not use directly.
/// </summary>
[global::System.Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(IJVMBridgeBaseInitializer initializer) : base(initializer) { }

/// <summary>
/// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class
/// Generic constructor used by JCOBridge when a derived class needs to forward arguments to the base JVMBridgeBase class.
/// </summary>
/// <remarks>
/// <see cref="ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER"/> represents a JVM interface or abstract class in .NET.
/// Instantiating it directly outside of JCOBridge infrastructure is not supported and may produce undefined behavior.
/// </remarks>
[global::System.Obsolete("ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER class represents, in .NET, an instance of a JVM interface or abstract class. This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(params object[] args) : base(args) { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ ALLPACKAGE_CLASSES_STUB_CLASS_DECORATION_PLACEHOLDER
public partial class ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER : ALLPACKAGE_CLASSES_STUB_BASECLASS_PLACEHOLDER
{
/// <summary>
/// Internal constructor: used internally from JCOBridge
/// Initializer used internally by JCOBridge. Do not use directly.
/// </summary>
[global::System.Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(IJVMBridgeBaseInitializer initializer) : base(initializer)
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(IJVMBridgeBaseInitializer initializer) : base(initializer)
{
var listenerRuntimeType = GetType();
var listenerRuntimeType = GetType();
_hasALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDERSecondGate = MASES.JNet.Specific.JNetEventResult.GetMethodIsOverridden(listenerRuntimeType, nameof(ListenerShallManageEvent), typeof(int), typeof(object));
}

/// <summary>
/// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class
/// Generic constructor used by JCOBridge when a derived class needs to forward arguments to the base JVMBridgeBase class.
/// </summary>
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER(params object[] args) : base(args)
{
Expand All @@ -21,12 +22,27 @@ public partial class ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER : ALLPACKAGE_CLAS
InitializeHandlers(listenerRuntimeType);
}

/// <summary>
/// <see langword="true"/> if the user has overridden <see cref="ListenerShallManageEvent(int, object)"/> in a subclass.
/// Cached at construction to avoid per-event reflection cost. When <see langword="true"/>, the first gate always
/// returns <see langword="true"/> so that the second gate is reached regardless of whether individual event handlers are registered.
/// </summary>
readonly bool _hasALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDERSecondGate;

/// <inheritdoc/>
/// <remarks>
/// Evaluated in order:
/// <list type="number">
/// <item><see cref="ListenerShallManageEventIndex"/> delegate — index-based, no string conversion, lowest overhead.</item>
/// <item><see cref="ListenerShallManageEventName"/> delegate — name-based, resolves via <see cref="ConvertListenerEventIndexToEventName"/>.</item>
/// <item><see cref="ListenerShallManageEventHandlers"/> — returns <see langword="true"/> if the specific event has a registered delegate or a virtual method override.</item>
/// <item><see cref="_hasALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDERSecondGate"/> — returns <see langword="true"/> if the second gate is overridden, ensuring all events reach it.</item>
/// </list>
/// </remarks>
protected override bool ListenerShallManageEvent(int eventIndex)
{
if (ListenerShallManageEventIndex != null) return ListenerShallManageEventIndex(eventIndex); // test first gate base handler with index
if (ListenerShallManageEventName != null) return ListenerShallManageEventName(ConvertListenerEventIndexToEventName(eventIndex)); // or test first gate base handler with name
if (ListenerShallManageEventIndex != null) return ListenerShallManageEventIndex(eventIndex);
if (ListenerShallManageEventName != null) return ListenerShallManageEventName(ConvertListenerEventIndexToEventName(eventIndex));
if (ListenerShallManageEventHandlers(eventIndex)) return true;
return _hasALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDERSecondGate;
}
Expand All @@ -40,28 +56,40 @@ ALLPACKAGE_CLASSES_STUB_LISTENER_CLASS_PLACEHOLDER

#region ALLPACKAGE_CLASSES_STUB_CLASS_DIRECT_PLACEHOLDER declaration
/// <summary>
/// Direct override of <see cref="ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER"/> or its generic type if there is one
/// Concrete CLR representation of <see cref="ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER"/> returned by the JVM.
/// </summary>
/// <remarks>
/// When the JVM returns an instance of this listener type, JCOBridge needs a concrete CLR class to wrap it.
/// A full listener implementation cannot be used in this scenario because it would require user-provided handler code
/// that is not available at the point of construction. This class provides a minimal, handler-free wrapper:
/// <see cref="InitializeHandlers"/> is a no-op, <see cref="ListenerShallManageEvent(int)"/> unconditionally
/// returns <see langword="false"/> discarding all events immediately, and <see cref="AutoInit"/> is <see langword="false"/>
/// to prevent automatic JVM-side registration.
/// <para>Do not use this class directly to register event handlers — use <see cref="ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDER"/> instead.</para>
/// </remarks>
public partial class ALLPACKAGE_CLASSES_STUB_CLASS_DIRECT_PLACEHOLDER : ALLPACKAGE_CLASSES_STUB_CLASS_PLACEHOLDER
{
/// <summary>
/// Internal constructor: used internally from JCOBridge
/// Initializer used internally by JCOBridge. Do not use directly.
/// </summary>
[global::System.Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDERDirect(IJVMBridgeBaseInitializer initializer) : base(initializer) { }

/// <summary>
/// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class
/// Generic constructor used by JCOBridge when a derived class needs to forward arguments to the base JVMBridgeBase class.
/// </summary>
public ALLPACKAGE_CLASSES_STUB_SIMPLECLASS_PLACEHOLDERDirect(params object[] args) : base(args) { }

/// <inheritdoc/>
public override bool AutoInit => false;

/// <inheritdoc />
/// <inheritdoc/>
/// <remarks>No handlers are registered in this direct override — initialization is intentionally skipped.</remarks>
protected override void InitializeHandlers(global::System.Type _) { }

/// <inheritdoc/>
protected override bool ListenerShallManageEvent(int _) { return false; } // early discard since no handlers are registered
/// <remarks>Always returns <see langword="false"/> — all events are discarded at the first gate without reading any JVM argument data.</remarks>
protected override bool ListenerShallManageEvent(int _) => false;

const string _bridgeClassName = "ALLPACKAGE_CLASSES_STUB_JAVACLASS_DIRECT_PLACEHOLDER";
private static readonly global::System.Exception _LocalBridgeClazzException = null;
Expand Down
Loading
Loading