Skip to content

incorrect overload is used in a pretty simple case #747

@pkit

Description

@pkit

Trying to implement one of the Debezium callback classes fails miserably with:

  File "jnius/jnius_export_class.pxi", line 1163, in jnius.JavaMultipleMethod.__call__
  File "jnius/jnius_export_class.pxi", line 877, in jnius.JavaMethod.__call__
  File "jnius/jnius_export_class.pxi", line 954, in jnius.JavaMethod.call_method
  File "jnius/jnius_utils.pxi", line 79, in jnius.check_exception
jnius.JavaException: JVM exception occurred: Class jdk.proxy1.$Proxy0 does not implement the requested interface java.util.Map java.lang.IncompatibleClassChangeError

The implementation is something like:

class PythonCompletionCallback(PythonJavaClass):
    __javainterfaces__ = ["io/debezium/engine/DebeziumEngine$CompletionCallback"]

    @java_method("(ZLjava/lang/String;Ljava/lang/Throwable;)V")
    def handle(self, success: bool, message: str, error: Exception):
        print(f"CB: Completed: {success} | {message} | {error}")

And it's called like:

        self.properties: Properties = Properties()
        self.consumer = PythonChangeConsumer()
        self.cb = PythonCompletionCallback()

        self.engine: DebeziumEngine = (  # type: ignore
            DebeziumEngine.create(EngineFormat.JSON)
            .using(self.cb)
            .using(self.properties)
            .notifying(self.consumer)
            .build()
        )

I suspect that it chooses the implementation of using() from here and not the correct one.

        /**
         * When the engine's {@link DebeziumEngine#run()} method completes, call the supplied function with the results.
         *
         * @param completionCallback the callback function; may be null if errors should be written to the log
         * @return this builder object so methods can be chained together; never null
         */
        Builder<R> using(CompletionCallback completionCallback);

The question is: how to force it to chose the correct one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions