CommandGene bug

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CommandGene bug

Simone Bronzin
I think there is a bug in the CommandGene code about the subChildType  
management.

The constructor never sets  m_subChildTypes if specialCase is false  
and a_childSubTypes exists, so the subChildTypes is never set.

public CommandGene(final GPConfiguration a_conf, final int a_arity,
                      final Class a_returnType, final int a_subReturnType,
                      final int[] a_childSubTypes)
       throws InvalidConfigurationException {
     this(a_conf, a_arity, a_returnType);
     if (a_childSubTypes != null) {
       boolean specialCase = false;
       // Special case from convenient construction.
       // ------------------------------------------
       if (a_childSubTypes.length == 1) {
         if (a_childSubTypes[0] == 0) {
           m_subChildTypes = null;
           specialCase = true;
         }
       }
       if (!specialCase) {
         if (a_childSubTypes.length != a_arity) {
           throw new IllegalArgumentException(
               "Length of child sub types must equal"
               + " the given arity (or set the former to null)");
         }
       }
       else {
         m_subChildTypes = a_childSubTypes;
         }

     }
     else {
       m_subChildTypes = a_childSubTypes;
     }
     m_subReturnType = a_subReturnType;
   }


should become

public CommandGene(final GPConfiguration a_conf, final int a_arity,
                      final Class a_returnType, final int a_subReturnType,
                      final int[] a_childSubTypes)
       throws InvalidConfigurationException {
     this(a_conf, a_arity, a_returnType);
     if (a_childSubTypes != null) {
       boolean specialCase = false;
       // Special case from convenient construction.
       // ------------------------------------------
       if (a_childSubTypes.length == 1) {
         if (a_childSubTypes[0] == 0) {
           m_subChildTypes = null;
           specialCase = true;
         }
       }
       if (!specialCase) {
         if (a_childSubTypes.length != a_arity) {
           throw new IllegalArgumentException(
               "Length of child sub types must equal"
               + " the given arity (or set the former to null)");
         }
         else {
         m_subChildTypes = a_childSubTypes;
         }
       }

     }
     else {
       m_subChildTypes = a_childSubTypes;
     }
     m_subReturnType = a_subReturnType;
   }

Do u agree?


--

Simone Bronzin
Unitary
Executive

mobile: +39.3939459672



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Reply | Threaded
Open this post in threaded view
|

Re: CommandGene bug

Klaus Meffert-5
Simone,

sems as if you are right. Thanx for your detailled report and solution.

I will adapt the JGAP core to fix the bug.

Best

Klaus
www.klaus-meffert.com

 

> -----Original Message-----
> From: Simone Bronzin [mailto:[hidden email]]
> Sent: Monday, August 31, 2009 11:50 AM
> To: [hidden email]
> Subject: [jgap-users] CommandGene bug
>
> I think there is a bug in the CommandGene code about the
> subChildType management.
>
> The constructor never sets  m_subChildTypes if specialCase is
> false and a_childSubTypes exists, so the subChildTypes is never set.
>
> public CommandGene(final GPConfiguration a_conf, final int a_arity,
>                       final Class a_returnType, final int
> a_subReturnType,
>                       final int[] a_childSubTypes)
>        throws InvalidConfigurationException {
>      this(a_conf, a_arity, a_returnType);
>      if (a_childSubTypes != null) {
>        boolean specialCase = false;
>        // Special case from convenient construction.
>        // ------------------------------------------
>        if (a_childSubTypes.length == 1) {
>          if (a_childSubTypes[0] == 0) {
>            m_subChildTypes = null;
>            specialCase = true;
>          }
>        }
>        if (!specialCase) {
>          if (a_childSubTypes.length != a_arity) {
>            throw new IllegalArgumentException(
>                "Length of child sub types must equal"
>                + " the given arity (or set the former to null)");
>          }
>        }
>        else {
>          m_subChildTypes = a_childSubTypes;
>          }
>
>      }
>      else {
>        m_subChildTypes = a_childSubTypes;
>      }
>      m_subReturnType = a_subReturnType;
>    }
>
>
> should become
>
> public CommandGene(final GPConfiguration a_conf, final int a_arity,
>                       final Class a_returnType, final int
> a_subReturnType,
>                       final int[] a_childSubTypes)
>        throws InvalidConfigurationException {
>      this(a_conf, a_arity, a_returnType);
>      if (a_childSubTypes != null) {
>        boolean specialCase = false;
>        // Special case from convenient construction.
>        // ------------------------------------------
>        if (a_childSubTypes.length == 1) {
>          if (a_childSubTypes[0] == 0) {
>            m_subChildTypes = null;
>            specialCase = true;
>          }
>        }
>        if (!specialCase) {
>          if (a_childSubTypes.length != a_arity) {
>            throw new IllegalArgumentException(
>                "Length of child sub types must equal"
>                + " the given arity (or set the former to null)");
>          }
>          else {
>          m_subChildTypes = a_childSubTypes;
>          }
>        }
>
>      }
>      else {
>        m_subChildTypes = a_childSubTypes;
>      }
>      m_subReturnType = a_subReturnType;
>    }
>
> Do u agree?
>
>
> --
>
> Simone Bronzin
> Unitary
> Executive
>
> mobile: +39.3939459672
>
>
>
> --------------------------------------------------------------
> ----------------
> Let Crystal Reports handle the reporting - Free Crystal
> Reports 2008 30-Day trial. Simplify your report design,
> integration and deployment - and focus on what you do best,
> core application coding. Discover what's new with Crystal
> Reports now.  http://p.sf.net/sfu/bobj-july 
> _______________________________________________
> jgap-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jgap-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users