Update listeners generation to manage original class
masesdevelopers opened this issue · 4 comments
The problem is strictly related to listeners and comes from many things:
- considering
Serializer<TJVMT>
, it inherits fromMASES.JCOBridge.C2JBridge.JVMBridgeListener
because the .NET side shall be informed if JVM requests something- this invocation in https://github.com/masesgroup/KNet/blob/16b0b133224961e348885dd607ed31130fc5fa33/src/net/KNet/Specific/Serialization/SerDes.cs#L131 requests an instance of JVM
Serializer
interface, not the listener JVM class, and cast it to .NETSerializer<TJVMT>
- the class
Serializer<TJVMT>
, by definition, hasAutoInit
flag set to true, so it initialize anMASES.JCOBridge.C2JBridge.JVMBridgeListener
To avoid the problem the code shall be updated to:
- create a new class named, e.g.
SerializerDirect<TJVMT>
which:
- extends
Serializer<TJVMT>
- overrides
AutoInit
and set it to false- overrides the
BridgeClassName
and set its value to the JVM interface name e.g.org.apache.kafka.common.serialization.Serializer
- override https://github.com/masesgroup/KNet/blob/16b0b133224961e348885dd607ed31130fc5fa33/src/net/KNet/Generated/Org/Apache/Kafka/Common/Serialization/Serde.cs#L269 in a new class named
SerDesDirect<TJVMT>
and within it allocate theSerializerDirect<TJVMT>
class
Originally posted by @masesdevelopers in masesgroup/KNet#448 (comment)
The idea is to update JNetReflector to create a new class, beside each listener, which:
- extends the original
- overrides
AutoInit
and set it to false - overrides the
BridgeClassName
and set its value to the JVM interface name - create a new protected flag named
InitHandlers
in listener class which enable or disable execution of https://github.com/masesgroup/KNet/blob/16b0b133224961e348885dd607ed31130fc5fa33/src/net/KNet/Generated/Org/Apache/Kafka/Common/Serialization/Serde.cs#L219, default is set to true; in the new class will be set to false
In case the listener interface is returned back from a method, create an extra method. beside the original one, which uses the new generated class to wrap the JVM reference.
Latest version of JCOBridge introduced a limitation on method CastTo which raises in
the following exception System.InvalidOperationException: java/lang/reflect/Type cannot be converted to java/lang/reflect/ParameterizedType even if the previous test in passed.The direct class e.g.
misses all members like IsBridgeInterface and so on, plus IsBridgeListener shall becomes false.Meanwhile add the missing developed classes (see https://github.com/masesgroup/JNet/actions/runs/9080784354/job/24953109309)
, plus IsBridgeListener shall becomes false.
On IsBridgeListener
cannot be done an override, however the side-by-side Direct class shall be used only as wrapper and never can be instantiated from CLR.
All developed classes under Java.Util.Function
namespace shall have the Direct counterpart