home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (Groovy3776Bug.groovy)

This example Groovy source code file (Groovy3776Bug.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

groovy3776bug, groovybugerror, groovybugerror, groovyclassloader, groovyclassloader, groovytestcase, invalidlistliteral, invalidlistliteral, multiplecompilationerrorsexception, multiplecompilationerrorsexception, reflection

The Groovy Groovy3776Bug.groovy source code

package groovy.bugs

import java.lang.reflect.*
import org.codehaus.groovy.control.MultipleCompilationErrorsException
import org.codehaus.groovy.GroovyBugError

class Groovy3776Bug extends GroovyTestCase {
    void testInvalidListWithMapEntryExpressions() {
        GroovyClassLoader cl = new GroovyClassLoader();
        
        def scriptStr = """
            class InvalidListLiteral {
                def x = [
                    [foo: 1, bar: 2]
                    [foo: 1, bar: 2]
                ]
            }
        """
        try {
            cl.parseClass(scriptStr)
            fail('Compilation should have failed with MultipleCompilationErrorsException')
        } catch(MultipleCompilationErrorsException mcee) {
            // ok if failed with this error.
        } catch(GroovyBugError gbe) {
            fail('Compilation should have failed with MultipleCompilationErrorsException but failed with GroovyBugError')
        }
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Groovy3776Bug.groovy source code file:

new blog posts

 

Copyright 1998-2014 Alvin Alexander, alvinalexander.com
All Rights Reserved.