Groovy
  1. Groovy
  2. GROOVY-5152

object instanceof MyObject[] causes ClassDefNotFound exception within Closure

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.10
    • Fix Version/s: 1.8.5, 2.0-beta-2, 1.7.11
    • Component/s: None
    • Labels:
      None

      Description

      The following code causes ClassDefNotFound exception:

      public Map<String, Object> toMap() {
              Map<String, Object> params = getPropertiesWithoutClassData()
              Map<String, Object> params = new HashMap<String,Object>();
              
              params.each { 
                 if(it.value instanceof MyObject[]){ 
      params.add(it.key, it.value)
       }else{
      params.add("test","test")
                 } 
              }
      
         return params
      }
      

      The equivalent java code works normally:

      public Map<String, Object> toMap() {
              Map<String, Object> params = getPropertiesWithoutClassData()
              Map<String, Object> params = new HashMap<String,Object>();
      
      for(String param : params)
      {
       if(params.get(param) instanceof MyObject[]){ 
      params.add("works", "works")
       }else{
      params.add("test","test")
                 } 
      }
      
         return params
      }
      

      Running MacOSX 10.6.6

        Activity

        Miles Burton created issue -
        Cédric Champeau made changes -
        Field Original Value New Value
        Description The following code causes ClassDefNotFound exception:

        public Map<String, Object> toMap() {
                Map<String, Object> params = getPropertiesWithoutClassData()
                Map<String, Object> params = new HashMap<String,Object>();
                
                params.each {
                   if(it.value instanceof MyObject[]){
        params.add(it.key, it.value)
         }else{
        params.add("test","test")
                   }
                }

           return params
        }

        The equivalent java code works normally:
        public Map<String, Object> toMap() {
                Map<String, Object> params = getPropertiesWithoutClassData()
                Map<String, Object> params = new HashMap<String,Object>();

        for(String param : params)
        {
         if(params.get(param) instanceof MyObject[]){
        params.add("works", "works")
         }else{
        params.add("test","test")
                   }
        }

           return params
        }
         
        Running MacOSX 10.6.6
        The following code causes ClassDefNotFound exception:
        {code}
        public Map<String, Object> toMap() {
                Map<String, Object> params = getPropertiesWithoutClassData()
                Map<String, Object> params = new HashMap<String,Object>();
                
                params.each {
                   if(it.value instanceof MyObject[]){
        params.add(it.key, it.value)
         }else{
        params.add("test","test")
                   }
                }

           return params
        }
        {code}
        The equivalent java code works normally:
        {code}
        public Map<String, Object> toMap() {
                Map<String, Object> params = getPropertiesWithoutClassData()
                Map<String, Object> params = new HashMap<String,Object>();

        for(String param : params)
        {
         if(params.get(param) instanceof MyObject[]){
        params.add("works", "works")
         }else{
        params.add("test","test")
                   }
        }

           return params
        }
        {code}
        Running MacOSX 10.6.6
        Cédric Champeau made changes -
        Assignee Cedric Champeau [ melix ]
        Cédric Champeau made changes -
        Fix Version/s 1.8.5 [ 18071 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 2.0-beta-2 [ 18072 ]
        Fix Version/s 1.7.11 [ 17244 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12734076 ] Default workflow, editable Closed status [ 12745854 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12971574 ] Default workflow, editable Closed status [ 12979415 ]

          People

          • Assignee:
            Cédric Champeau
            Reporter:
            Miles Burton
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development