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

type mismatch when the expected type is java.lang.Class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Static Type Checker
    • None

    Description

      I have the following program

      class Test {
        public static void main(String [] args) {
          java.lang.Class<String> lapse = 1;
        }
      } 

      Actual behavior

      The code compiles, but I get the following runtime error:

       Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '1' with class 'java.lang.Integer' to class 'java.lang.Class' due to: java.lang.ClassNotFoundException: 1
      org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '1' with class 'java.lang.Integer' to class 'java.lang.Class' due to: java.lang.ClassNotFoundException: 1
          at Test.main(test.groovy:3)

      Expected behavior

      The code should have been rejected

      Tested against master (commit: e6b9133726af9cdea2bc6db7b55523cd88f7190e)

      Attachments

        Activity

          People

            Unassigned Unassigned
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: