uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Eckart de Castilho (JIRA)" <...@uima.apache.org>
Subject [jira] [Commented] (UIMA-4299) improve generics for UIMA indexes and iterators
Date Fri, 10 Apr 2015 07:11:12 GMT

    [ https://issues.apache.org/jira/browse/UIMA-4299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14489080#comment-14489080
] 

Richard Eckart de Castilho commented on UIMA-4299:
--------------------------------------------------

The problem is, that wildcards in particular in method return values can lead to this ugly
kind of error:

{noformat}
The method setValue(capture#3-of ?) in the type Field<capture#3-of ?> is not applicable
for the arguments (capture#4-of ?)
{noformat}

One guy explains this in a blog entry [1] and suggests to use use "type capture" which we
cannot do here properly, since the type in question is not part of the arguments signature.

In a comment to this blog post, one reader quotes a section the book "Java Generics and Collection"
that summarizes my own bad experience:

{quote}
If you flip back three pages in that same book to Page 137, you'll see the advice that best
applies to this situation: *"Do not use wildcard types as return types. Rather than providing
additional flexibility to your users, it would force them to use wildcard types in client
code."* Or worse--as you admit--an unchecked cast, which defeats compile-time type safety,
the primary design goal of Java's generic type system.
{quote}

[1] http://java.dzone.com/articles/java-generics-wildcard-capture-useful-thing-to-know


> improve generics for UIMA indexes and iterators
> -----------------------------------------------
>
>                 Key: UIMA-4299
>                 URL: https://issues.apache.org/jira/browse/UIMA-4299
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.7.0SDK
>            Reporter: Marshall Schor
>            Priority: Minor
>             Fix For: 2.7.1SDK
>
>
> When the JCas is being used, there are Java classes for UIMA types.  
> Each index definition is associated with a top-most type in the type hierarchy.
> Indexes are used to create iterators of various kinds; some of these iterators are defined
within classes which implement Iterable.  
> Add generic mechanisms to the Indexes and iterators to support Iterables whose elements
are JCas types. 
> Update the APIs that get indexes over particular types to allow specifying those types
by the type class, and use this for generic typing, so casts are not necessary for user code.
> Make the generics work also when JCas is not in use.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message