Uploaded image for project: 'Spatial Information Systems'
  1. Spatial Information Systems
  2. SIS-578

Remove contravariance in filters and expressions

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1, 1.2, 1.3
    • 1.4
    • Features
    • None

    Description

      Since SIS 1.1, Filters and expressions in org.apache.sis.filter package have methods with a signature like below. This signature reproduced the state of GeoAPI 3.1 draft (not yet released).

      List<Expression<? super R, ?>> getParameters();
      

      However experience has shown that contravariance (the <? super> part) cause difficulties that are hard to resolve. The problem is that filters are often chained. When a code follows a chain of filters, it may need to check for parameters of parameters. In such cases, invoking the above getParameters() method, then invoking again getParameters() on the result, gives a type that looks like <? super ? super R>>, which is identified by the Java compiler as {{<? super #CAP1>. The consequence is many compilation errors of the kind "no method match List<Expression<? super #CAP1, ?>> which are hard to resolve otherwise than by unsafe cast. Consequently, for having more type-safe code, it seems necessary to change above method signature like below:

      List<Expression<R, ?>> getParameters();
      

      Attachments

        Activity

          People

            desruisseaux Martin Desruisseaux
            desruisseaux Martin Desruisseaux
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: