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

ClassCastException in map argument constructor when Immutable and CompileStatic are used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.2
    • 2.3.5
    • None
    • None

    Description

      I'm working on an unit test for Grails and it fails with a ClassCastException.

      java.lang.ClassCastException: grails.test.runtime.TestPluginUsage cannot be cast to java.util.Map
      	at java.util.HashMap.hash(HashMap.java:366)
      	at java.util.HashMap.put(HashMap.java:496)
      	at java.util.HashSet.add(HashSet.java:217)
      	at java.util.AbstractCollection.addAll(AbstractCollection.java:342)
      	at grails.test.runtime.TestRuntimeFactory.getRuntimeForTestClass_closure1(TestRuntimeFactory.groovy:72)
      	at groovy.lang.Closure.call(Closure.java:423)
      	at groovy.lang.Closure.call(Closure.java:439)
      	at grails.test.runtime.TestRuntimeFactory.getRuntimeForTestClass(TestRuntimeFactory.groovy:63)
      	at grails.test.runtime.TestRuntimeFactorySpec.should instantiate correct plugins and features for #testClass.simpleName(TestRuntimeFactorySpec.groovy:20)
      

      With a debugger I can see that the object has a reference to a wrong metaclass .

      I tried to isolate the problem without success. I'll push the code to a separate branch in Grails so that you can reproduce the problem and connect a debugger to the failing test.

      Attachments

        Activity

          People

            melix Cédric Champeau
            lhotari Lari Hotari
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: