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

@TypeChecked and "Charset ISO_8859_1_CHARSET = Charset.forName("ISO-8859-1")": Cannot assign value of type java.lang.Class to variable of type java.nio.charset.Charset

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.6, 2.1.0-beta-1
    • Static Type Checker
    • None
    • Windows 7
      Eclipse
      Groovy Eclipse 2.7.1.xx-20120915

    Description

      package example
      
      import groovy.transform.TypeChecked
      
      import java.nio.charset.Charset
      
      @TypeChecked
      class PotentialTypeCheckerIssueExample {
              private static Charset ISO_8859_1_CHARSET = Charset.forName("ISO-8859-1")
      
              static void main(String[] args) {
                      new PotentialTypeCheckerIssueExample().printCharset()
              }
      
              def printCharset(){
                      println ISO_8859_1_CHARSET
              }
      }
      

      The type checker reports

      Groovy:[Static type checking] - Cannot assign value of type
      java.lang.Class to variable of type
      java.nio.charset.Charset        PotentialTypeCheckerIssueExample.groovy /GroovyTests/src/example        line
      9       Java Problem
      

      The code runs fine without @TypeChecked, the IDE shows the right
      return type (Charset).

      What's wrong here?

      Attachments

        Activity

          People

            melix Cédric Champeau
            peti Peti Koch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: