[jboss-jira] [JBoss JIRA] (DROOLS-1047) Bean introspection is not compatible with Java 8 compiler

Petr Široký (JIRA) issues at jboss.org
Mon Feb 1 10:12:00 EST 2016


     [ https://issues.jboss.org/browse/DROOLS-1047?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Petr Široký updated DROOLS-1047:
--------------------------------
    Component/s: core engine


> 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
>          Components: core engine
>            Reporter: Mario Fusco
>            Assignee: Mario Fusco
>             Fix For: 7.0.0.Final
>
>
> 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#getDeclaredMethods--
> 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-java.lang.String-java.lang.Class...- )
> 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)



More information about the jboss-jira mailing list