jpype icon indicating copy to clipboard operation
jpype copied to clipboard

Another default methods with @JImplements problem

Open ryanmkurtz opened this issue 1 year ago • 4 comments

I suppose this relates to #1181 and #1182.

I am trying to implement this Ghidra interface in PyGhidra with JPype like this:

@JImplements(BundleHostListener)
class PyListener:
    """
    PyGhidra Bundle Host Listener
    """
    
    def __init__(self, py_plugin: PyGhidraPlugin):
        pass
   
    @JOverride 
    def bundleBuilt(self, bundle, summary):
        print("bundleBuilt")

    @JOverride
    def bundleEnablementChange(self, bundle, newEnablement):
        print("bundleEnablementChange")

   ...

Things blow up at runtime if I don't implement every method in the interface, despite them all have default implementations. For example, if I don't override bunldesAdded():

java.lang.reflect.UndeclaredThrowableException: null
    jdk.proxy2/jdk.proxy2.$Proxy32.bundlesAdded(Unknown Source)
    ghidra.app.plugin.core.osgi.BundleHost.fireBundlesAdded(BundleHost.java:814)
    ghidra.app.plugin.core.osgi.BundleHost.add(BundleHost.java:214)
    ghidra.app.plugin.core.osgi.BundleHost.restoreManagedBundleState(BundleHost.java:890)
    ghidra.app.plugin.core.script.GhidraScriptComponentProvider.readConfigState(GhidraScriptComponentProvider.java:293)

Not a blocker for me, since I can just implement all of them. But, seems like a bug.

ryanmkurtz avatar Jan 24 '25 13:01 ryanmkurtz

I thought this was dealt with. I will take another look.

Thrameos avatar Jan 24 '25 18:01 Thrameos

I have the same issue with Jpype version 1.5.2, as said previously this is not a blocking stuff but this is bothersome.

VincentDary avatar Mar 20 '25 11:03 VincentDary

Its on the list. But I don't have a simple replicator of the error that doesn't require 3rd party libraries, so it is waiting until I can create one.

Thrameos avatar Mar 20 '25 14:03 Thrameos

I tested this again with the examples I have. I was not required to implement defaults on a simple class extension. Thus there is something confusing in the your case. I will need a reproducer to continue. It is likely something about the organization of the class inheritance.

Thrameos avatar Apr 16 '25 17:04 Thrameos