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

NullObject.metaClass

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-3
    • None
    • None

    Description

      Hi,

      I execute this. The third shell.evaluate throws an exception:

      final GroovyShell shell = new GroovyShell( binding, FormsGroovyConfiguration.CONFIG );
      // THIS WILL FORCE NULL VARIABLES TO PRINT AS '' INSTEAD OF NULL
      // http://stackoverflow.com/questions/10517817/how-to-get-rid-of-null-when-concating-string-in-groovy
      shell.evaluate("org.codehaus.groovy.runtime.NullObject.metaClass.toString = { return '' }");
      

      And got the next exception. This used to work in Java 10 and before, it crashes under Java 11. Could have something to do with java modulesĀ ?

      Exception in thread "JavaFX Application Thread" BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy' null
       at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970)
       at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
       at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:582)
       at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:324)
       at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:294)
       at groovy.lang.GroovyShell.parseClass(GroovyShell.java:558)
       at groovy.lang.GroovyShell.parse(GroovyShell.java:570)
       at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454)
       at groovy.lang.GroovyShell.evaluate(GroovyShell.java:493)
       at groovy.lang.GroovyShell.evaluate(GroovyShell.java:464)
      

      Attachments

        Activity

          People

            emilles Eric Milles
            dprutean Pruteanu Dragos
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: