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

MalformedParameterizedTypeException when bounded generic attribute without visibility modifier

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.3
    • 2.3.7, 2.4.0-beta-3
    • None

    Description

      This code fails in runtime with MalformedParameterizedTypeException - run main to try it out:

      class Dependency<T> {
      }
      
      class Something<T extends Number> {
          Dependency<? super T> dependency
      
          static main(String[] args) {
              new Something<Integer>()
          }
      }
      

      However, it does not fail if a visibility modifier is added before dependency attribute - private, protected, public or @PackageScope transformation.

      This also fails with MalformedParameterizedTypeException and I don't know how to make it work:

      class Something<T extends Number> {
          void someMethod(Dependency<? super T> dependency) {
          }
      
          static main(String[] args) {
              new Something<Integer>()
          }
      }
      

      Do you know what may be the cause? Do you know of any workaround for the second case?

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            pbetkier Piotr Betkier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: