Default method in interface in Java 8 and Bean Info Introspector -
I have a slight problem with the default methods in interface and Bininfo introspector In this example, the interface is: interface < pre> and two classes class A and class B: Public Static Class ClassA Tools Interface {} Public Stable Class Classb Tool Interface {public string getLetter () {Return "B"; }} The PropertyDescriptors print from BeanInfo in the main method app: And the result is: Why the default method is "letters" Is not showing in the form of property? Is this a bug or a feature? I think, Can it be assumed that the bug is a brown area, that's why I feel like this. Obviously, "heir" is now a way from a class interface to which it is generally considered to be a waiter / setter / mutator. But at the same time, the whole thing is against the purpose of the interface - an interface can not possibly provide anything that can be considered property, because it is stateless and non-behavioral, it means only description for behavior, even protecting methods are basically stable, unless they use the real properties of a solid implementation. On the other hand, if we believe that defenders officially inherited (as provide default implementation ) to some extent obvious vague Definition), synthetic methods should be created in the class implementing them, and they belong to those classes and they are public stable interface interface {default public string getLetter () {return "A"; }}
public static string formatData (property descriptor [PDA] {returnArease.Sistribute} (PDS) .stream () .map ((pd) - & gt; pd.getName ()). Collect (collectors. Joshi (",")); } Public static zero main (string [] args) {try {system.out.println (format data (Introspector.getBeanInfo (ClassA.class) .getPropertyDescriptors ())); System.out.println (formatData (Introspector.getBeanInfo (ClassB.class) .getPropertyDescriptors ())); } Grip (introspection exception e) {e.printStackTrace (); }}
class squares, letters
does not process
interface hierarchy chains, even though there may be something in Java with 8 virtual extension methods (aka defender, default methods) that looks like a few sorting methods. This is a simplified inspector who claims:
property descriptor lookup obviously this is not the case, otherwise the whole thing Will be working. It seems that protective methods are getting any special treatment.
Comments
Post a Comment