hypfvieh/dbus-java

Code generated by InterfaceCodeGenerator sometimes misses constructors

siepkes opened this issue · 5 comments

Maybe I'm doing something wrong but it seems that InterfaceCodeGenerator sometimes generates classes which misses a constructor:

public class AddConfigurationItemStruct extends Struct {
    @Position(0)
    private final String member0;
    @Position(1)
    private final Map member1;


    public String getMember0() {
        return member0;
    }

    public Map getMember1() {
        return member1;
    }

I encountered this issue while trying to generate classes for UDisk2 2.8.4 (CentOS): https://github.com/storaged-project/udisks/blob/udisks-2.8.4/data/org.freedesktop.UDisks2.xml

I used the following command in the dbus-java-utils folder in with both the master branch and dbus-java-parent-3.2.3 tag. Both yielded the same result:

mvn exec:java \
  -Dexec.mainClass="org.freedesktop.dbus.utils.generator.InterfaceCodeGenerator" \
  -Dexec.executable="java" \
  -Dexec.args="%classpath --inputFile org.freedesktop.UDisks2.xml --outputDir /somewhere ' '"

This is simply a bug .. No constructor will be created for structs. I will fix that in the next few days.

I updated to code, you may try it again with the latest changes.

That was fast!

Building the project without tests and then running the generator now generates structs with constructors, so thats great!

However I did ran into a test failure (see below) when trying to build with tests enabled. I didn't have that issue before:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.freedesktop.dbus.utils.generator.InterfaceCodeGeneratorTest
10:52:23.562 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Creating interface: org.fedoraproject.firewalld1.Direct
10:52:23.644 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Skipping: org.fedoraproject.IFirewallD1 - does not match given busName: org.fedoraproject.FirewallD1
10:52:23.644 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Skipping: org.freedesktop.DBus.Introspectable - does not match given busName: org.fedoraproject.FirewallD1
10:52:23.644 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Creating interface: org.fedoraproject.firewalld1.Ipset
10:52:23.659 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Creating interface: org.fedoraproject.firewalld1.Policies
10:52:23.691 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Skipping: org.freedesktop.DBus.Properties - does not match given busName: org.fedoraproject.FirewallD1
10:52:23.691 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Creating interface: org.fedoraproject.firewalld1.Zone
10:52:23.801 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Skipping: config - does not match given busName: org.fedoraproject.FirewallD1
10:52:23.823 [main] INFO  o.f.d.u.g.InterfaceCodeGenerator - Creating interface: org.freedesktop.networkmanager.device.Wireless
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.519 s <<< FAILURE! - in org.freedesktop.dbus.utils.generator.InterfaceCodeGeneratorTest
[ERROR] testCreateFirewallInterfaces  Time elapsed: 0.493 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <20> but was: <9>
	at org.freedesktop.dbus.utils.generator.InterfaceCodeGeneratorTest.testCreateFirewallInterfaces(InterfaceCodeGeneratorTest.java:36)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   InterfaceCodeGeneratorTest.testCreateFirewallInterfaces:36 expected: <20> but was: <9>
[INFO] 
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for dbus-java-parent 3.2.4-SNAPSHOT:
[INFO] 
[INFO] dbus-java-parent ................................... SUCCESS [  0.683 s]
[INFO] dbus-java .......................................... SUCCESS [ 59.090 s]
[INFO] dbus-java-osgi ..................................... SUCCESS [  6.588 s]
[INFO] dbus-java-utils .................................... FAILURE [  1.857 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

fixed, was a regression due to the change which made the busname optional when reading introspection data from file

Great! I've tested it and both building without test failures and generating classes for structs now works correctly. Thanks!