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

Code Generation Creates Duplicate Conflicting Structn Files for firewalld #33

Closed sshort closed 5 years ago

sshort commented 5 years ago

Running the DBus Java code generation, henceforth referred to as CreateInterface, to generate code for the firewalld DBus interfaces creates a main API class and a number of supporting classes, in particular Struct?.java, which are used to pass data over the method calls between the client and the firewalld DBus service. The firewalld DBus interface name is ' org.fedoraproject.FirewallD1' and it exposes several objects using this interface. For the purposes of this disucssion, the ones I am interested in are:

Running CreateInterface to create code for the object path '/org/fedoraproject/FirewallD1/config` creates 16 Struct?.java files in the package org.fedoraproject.FirewallD1, named Struct1.java -> Struct16.java.

Running CreateInterface to create code for the object path '/org/fedoraproject/FirewallD1/config/service/0` creates 8 Struct?.java files in the package org.fedoraproject.FirewallD1, named Struct1.java -> Struct8.java.

Running CreateInterface to create code for the object path '/org/fedoraproject/FirewallD1/config/zone/0` creates 11 Struct?.java files in the package org.fedoraproject.FirewallD1, named Struct1.java -> Struct11.java.

Unfortunately, later Structn files overwrite earlier Structn files, and they have different fields and methods, so the generated code does not compile.

E.g. the Struct1.java file for objectPath /org/fedoraproject/FirewallD1/config is:

    package org.fedoraproject.FirewallD1.config;
    import java.util.List;
    import org.freedesktop.dbus.Position;
    import org.freedesktop.dbus.Struct;
    public final class Struct1 extends Struct
    {
       @Position(0)
       public final List<CharSequence> a;
       @Position(1)
       public final List<CharSequence> b;
       @Position(2)
       public final List<CharSequence> c;
       @Position(3)
       public final List<Integer> d;
      public Struct1(List<CharSequence> a, List<CharSequence> b, List<CharSequence> c, List<Integer> d)
      {
       this.a = a;
       this.b = b;
       this.c = c;
       this.d = d;
      }
    }

And the Struct1.java file for objectPath /org/fedoraproject/FirewallD1/config/service/0 is:

    package org.fedoraproject.FirewallD1.config;
    import java.util.List;
    import java.util.Map;
    import org.freedesktop.dbus.Position;
    import org.freedesktop.dbus.Struct;
    public final class Struct1 extends Struct
    {
       @Position(0)
       public final CharSequence a;
       @Position(1)
       public final CharSequence b;
       @Position(2)
       public final CharSequence c;
       @Position(3)
       public final List<Struct7> d;
       @Position(4)
       public final List<CharSequence> e;
       @Position(5)
       public final Map<CharSequence,CharSequence> f;
       @Position(6)
       public final List<CharSequence> g;
       @Position(7)
       public final List<Struct8> h;
      public Struct1(CharSequence a, CharSequence b, CharSequence c, List<Struct7> d, List<CharSequence> e, Map<CharSequence,CharSequence> f, List<CharSequence> g, List<Struct8> h)
      {
       this.a = a;
       this.b = b;
       this.c = c;
       this.d = d;
       this.e = e;
       this.f = f;
       this.g = g;
       this.h = h;
      }
    }