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

        Hide
        Cédric Champeau added a comment -

        Formatting tags

        Show
        Cédric Champeau added a comment - Formatting tags
        Hide
        Cédric Champeau added a comment -

        Can you attach a complete script which demonstrates the problem? Thanks!

        Show
        Cédric Champeau added a comment - Can you attach a complete script which demonstrates the problem? Thanks!
        Hide
        Roshan Dawrani added a comment -

        The following fails with "java.lang.ClassFormatError: Illegal class name "MyObject[]" in class file" on master.

        class MyObject{}
        assert !("" instanceof MyObject[])
        
        Show
        Roshan Dawrani added a comment - The following fails with "java.lang.ClassFormatError: Illegal class name "MyObject[]" in class file" on master. class MyObject{} assert !("" instanceof MyObject[])
        Hide
        Cédric Champeau added a comment -

        Fixed. Thanks for the example Roshan.

        Show
        Cédric Champeau added a comment - Fixed. Thanks for the example Roshan.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: