hypfvieh / dbus-java

Improved version of java DBus library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/)
https://hypfvieh.github.io/dbus-java/
MIT License
185 stars 73 forks source link

CreateInterface for firewalld Creates Class / Package Name clash #35

Closed sshort closed 5 years ago

sshort commented 5 years ago

Running CreateInterface to create code for the object path '/org/fedoraproject/FirewallD1` creates a Java class org.fedoraproject.FirewallD1.java whose name is the same as a java package, so the code does not compile.

Also: the imports for DBusInterface and DBusSignal need to reflect the new package locations for these.

hypfvieh commented 5 years ago

Could you provide the introspection xml generated by DBus?

I don't use Fedora/firewalld and I've started a re-write of the CreateInterface tool and some more test data would be helpful.

sshort commented 5 years ago

Attached. If it helps I'm using firewalld on Mint for this.

firewalld_dbus_xml.zip

sshort commented 5 years ago

I've identified a problem I introduced. Because the Structs can now be in a package, the import for that package needs to be added to the generated interface class. For some interfaces/paths, the Struct definition has not yet been created, so the 'import xxx' statement cannot be written. I think that means that code generation needs to be a 2 pass process, but I am still trying to think of alternatives.

sshort commented 5 years ago

Fix offered in https://github.com/hypfvieh/dbus-java/pull/36

hypfvieh commented 5 years ago

I have added a new branch with a completely rewritten version of the interface creation tool. If you could take a look, that would be great.

The branch name is 'interface-tool', the class you have to run is org.freedesktop.dbus.utils.generator.InterfaceCodeGenerator

Please note that this tool is not done yet. It still lacks support for multi-value return and may have some serious bugs. I only tested it with a few DBus services and with some of your provided introspection XMLs.

If you find bugs and want to provide a fix for that, you are always welcome.

hypfvieh commented 5 years ago

The new InterfaceCodeGenerator is now part of the latest release. I'll close this bug report, please open a new one if you find bugs in the new implementation.

The old tool is still available, but deprecated.