Mario Fusco created DROOLS-1047:
-----------------------------------
Summary: Bean introspection is not compatible with Java 8 compiler
Key: DROOLS-1047
URL:
https://issues.jboss.org/browse/DROOLS-1047
Project: Drools
Issue Type: Bug
Reporter: Mario Fusco
Assignee: Mario Fusco
Consider the following 2 interfaces:
{code}
public interface Base {
Object getA();
}
public interface Ext extends Base {
String getA();
}
{code}
In Java 7 if you print the declared methods of the Ext interface:
System.out.println( Arrays.toString(Ext.class.getDeclaredMethods()) );
you obtain only one method:
[public abstract java.lang.String org.drools.compiler.IntrospectionTest$Ext.getA()]
This is expected because Class.getDeclaredMethods() "Returns an array containing
Method objects reflecting all the declared methods of the class or interface represented
by this Class object, including public, protected, default (package) access, and private
methods, but excluding inherited methods."
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclare...
Nevertheless if I try exactly the same thing in Java 8 I obtain a totally different
result:
[public abstract java.lang.String org.drools.compiler.IntrospectionTest$Ext1.getA(),
public default java.lang.Object org.drools.compiler.IntrospectionTest$Ext1.getA()]
Now it is also returning the method declared on the Base interface as it was a default
method. This second method is flagged as a bridge method (see here
https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getMethod-...
)
This change between Java 7 and 8 breaks getter/setter introspection of beans in some
specific case
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)