You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by Murray Altheim <mu...@altheim.com> on 2009/07/02 06:11:57 UTC

Generics in 2.8.2 and 3.x

I thought about labeling this message: "mismatch between
FormUtil.requestToMap() and FormInfo.addSubmission()" but it seemed
a bit long and the issue is wider.

I'm not sure if this is a bug or not but in sifting through compatibility
changes regarding JSPWiki 2.8.2 and Java's generics, I now and then run
across either missing generic code in 2.8.2, incompatibilities between my
own code and the generic declarations in 2.8.2, or even seeming incompat-
ibilities in 2.8.2's use of generics.

What I'm assuming is this: if 2.8.2 is meant as the stable, longstanding
bridge between where most users are expected to be now and the 3.x code
in the future, we might have people using 2.8.2 for quite a long time.
This is especially true given that there's likely a lot of custom code,
JSP modifications, and/or template work based in 2.8.2 that will take
people a long time to migrate, if they even plan to migrate. I know that
in my case we've got a substantial infrastructure investment in 2.8.2
and I've got dozens of plugins that would need migrating, with ever-
shrinking budgets and time to accomplish that.

That said, 2.8.2 is missing a lot of generic declarations, and I seem to
have found at least one or two incompatibilities. I'm no expert in Java
generics, but I'm not certain the decisions made in 2.8.2 are correct,
e.g., I believe a number of cases of <Object> might instead need to be
either <?> or <? extends Foo>. For example, using FormUtil.requestToMap()
with a FormInfo object, one runs quickly into this:

     FormInfo info = new FormInfo();
     Map<String,String> handlerParams
             = FormUtil.requestToMap(
                 context.getHttpRequest(),
                 HANDLERPARAM_PREFIX );
     // modify parameters...
     info.addSubmission(handlerParams); // expects <String,Object>

Since the Map supplied with the WikiPlugin API is <String,Object>
I'm wondering if FormUtil.requestToMap() shouldn't be the same, or
if perhaps the choice of <String,Object> is in general an issue.
Should it perhaps be <String,?> instead? (I admit I'm still sometimes
confused by generics).

A second question is what to do in general about generics prior to
release of 3.x.  Version 2.8.2 will potentially be the main distribution
for a long time, and I'm wondering if it's possible to release a new
genericized version, either creating a new branch or bumping up the
version number appropriately. Any generic declarations would be checked
against what's happening in 3.x. This does represent an API change, but
for those of us trying to integrate 2.8.2 into other code (as I am),
a genericized version of 2.8.2 would be welcome. As I mentioned, I've
been genericizing a local copy, which seems both like a bad idea and a
waste if not shared, but I'm trying to update a ton of code right now,
and JSPWiki as part of my toolkit needs to play well with the rest,
and fit various project requirements (e.g., code compatibility).

In summary:

    1. what to do about bugs in the generics implementation in 2.8.2?
       (if actually bugs)

    2. is there any possibility of having a post 2.8.2 version that
       includes Java generics?

Thoughts?

Murray

PS. Apologies on my absence of late: my schedule has been a bit more
     hectic than I'd imagined, changes of all sorts...
...........................................................................
Murray Altheim <murray09 at altheim dot com>                       ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record