-3

I have this specific requirement due to the fact that a third-party library somehow has this interface A which extends B, which in turn extends C, D.

Now, the problem is that interface C extends D. IMO, since C already extends D, B should only extends C.

The issue arises when I try to use object of type interface A to bind a form in Vaadin Flow. The error message is: Duplicate key found for property [this common method].

I inspected the object and noticed there is the following hierarchy:

       // myObject:
       //   reflectionData:
       //     referent:
       //       interfaces:
       //         [0]:
       //           name: "com.example...." [interface B from above]
       //           reflectionData:
       //             referent:
       //               interfaces:
       //                 [0]:
       //                   name: "com.example..." [interface C from above]
       //                 [1]:
       //                   name: "com.example..." [interface D from above]

My idea was to somehow, by using Java reflection maybe, remove the second element of the array (interface D) (if it's possible, that is), before sending the object to Vaadin's Binder class.

kaya3
  • 47,440
  • 4
  • 68
  • 97
developer10
  • 1,450
  • 2
  • 15
  • 31
  • Hi, as you found a duplicate key for ... why not select the needed one ? – Gweltaz Niquel Nov 10 '20 at 09:03
  • 1
    Are you sure the inheritance of the protocols are as you describe them because it doesn't make sense. Does B really implement/extend _both_ C and D? – Joakim Danielson Nov 10 '20 at 09:04
  • @GweltazNiquel I'm not sure I understand the question. The error happens at a later stage, when the object with duplicate key is already sent to Vaadin. If I am able to remove this second interface from the object, I guess then Vaadin wouldn't find this duplicate property. – developer10 Nov 10 '20 at 09:05
  • @JoakimDanielson Yes, I'm sure. I already shared this with the authors, hoping the second (D) is unnecessary and that they would update the code. But it's unlikely. – developer10 Nov 10 '20 at 09:06
  • I would try to duplicate the object then cast choosed referent interface to D before sending it to Vaadin but we have too few code sample to guess how to intercept. – Gweltaz Niquel Nov 10 '20 at 09:14
  • @JoakimDanielson I actually got it wrong the first time - it's corrected now. Please, take a look! – developer10 Nov 10 '20 at 10:35

1 Answers1

1

You cannot modify reflection information in Java. But in fact, it is a bug in Vaadin, file a bug report. In Java, interface methods with same name (and parameters) are not considered duplicated - it is the same method. When java compiler doubts, it issues an error. If your program have been compiled, it is correct, and Vaadin must work with any correct program.

Alexei Kaigorodov
  • 13,189
  • 1
  • 21
  • 38