groovy
  1. groovy
  2. GROOVY-5152

object instanceof MyObject[] causes ClassDefNotFound exception within Closure

    Details

    • Type: Bug Bug
    • Status: Closed 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
    • Number of attachments :
      0

      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

        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 -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0-beta-2 [ 18072 ]
        Fix Version/s 1.7.11 [ 17244 ]
        Fix Version/s 1.8.5 [ 18071 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: