Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5152

object instanceof MyObject[] causes ClassDefNotFound exception within Closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.7.10
    • 1.8.5, 2.0-beta-2, 1.7.11
    • None
    • 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

      Attachments

        Activity

          People

            melix Cédric Champeau
            teammcs Miles Burton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: