Fragile base class problem with ImmediateExecutorService

2 messages Options
Embed this post
Permalink
gm-mrktc

Fragile base class problem with ImmediateExecutorService

Reply Threaded More More options
Print post
Permalink
A user/developer of ours has pointed out that our test code currently
does not compile under Java 1.6 (we produce all of our builds for 1.5
currently).  The root of the problem is that we are implementing an
interface from the standard Java libraries, ExecutorService, the
definition of which has changed slightly between Java  1.5 and 1.6.
There are actually several methods that are a problem in that
interface, but here is one example:

In Java 1.5 you have this method in the interface:

<T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks)

but in Java 1.6 the same method is declared as follows:

<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)

The obvious difference being the type parameter for the 'tasks'
collection has changed from "Callable<T>" to "? extends Callable<T>".

So here's the problem, the compiler is telling me that the method that
I use to implement this interface has to match exactly, meaning that
the class that compiles fine under Java 1.5 flails under Java 1.6 and
vice versa.

Aside from branching the code for this one class, does anyone know of
a good way to address this?

For reference the file we are referring to is
http://trac.marketcetera.org/trac.fcgi/browser/platform/trunk/core/src/test/java/org/marketcetera/core/ImmediateExecutorService.java

Also, I have attached a patch file for use with Java 1.6 compilers as
a temporary workaround.

Thanks.

graham

--
Marketcetera Trading Platform
download.run.trade.
www.marketcetera.org


_______________________________________________
m-etc-dev mailing list
[hidden email]
http://lists.marketcetera.org/cgi-bin/mailman/listinfo/m-etc-dev

java6.diff (1K) Download Attachment
gm-mrktc

Re: Fragile base class problem with ImmediateExecutorService

Reply Threaded More More options
Print post
Permalink
So to answer my own question...

I found this post:
http://permalink.gmane.org/gmane.comp.java.jsr.166-concurrency/4132

Which references this bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833

The suggested workaround is to avoid using generics at all in your
subclass.  This leads to a few new warnings, but at least compiles and
functions correctly....

graham


On 8/14/07, Graham Miller <[hidden email]> wrote:

> A user/developer of ours has pointed out that our test code currently
> does not compile under Java 1.6 (we produce all of our builds for 1.5
> currently).  The root of the problem is that we are implementing an
> interface from the standard Java libraries, ExecutorService, the
> definition of which has changed slightly between Java  1.5 and 1.6.
> There are actually several methods that are a problem in that
> interface, but here is one example:
>
> In Java 1.5 you have this method in the interface:
>
> <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks)
>
> but in Java 1.6 the same method is declared as follows:
>
> <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
>
> The obvious difference being the type parameter for the 'tasks'
> collection has changed from "Callable<T>" to "? extends Callable<T>".
>
> So here's the problem, the compiler is telling me that the method that
> I use to implement this interface has to match exactly, meaning that
> the class that compiles fine under Java 1.5 flails under Java 1.6 and
> vice versa.
>
> Aside from branching the code for this one class, does anyone know of
> a good way to address this?
>
> For reference the file we are referring to is
> http://trac.marketcetera.org/trac.fcgi/browser/platform/trunk/core/src/test/java/org/marketcetera/core/ImmediateExecutorService.java
>
> Also, I have attached a patch file for use with Java 1.6 compilers as
> a temporary workaround.
>
> Thanks.
>
> graham
>
> --
> Marketcetera Trading Platform
> download.run.trade.
> www.marketcetera.org
>
>


--
Marketcetera Trading Platform
download.run.trade.
www.marketcetera.org
_______________________________________________
m-etc-dev mailing list
[hidden email]
http://lists.marketcetera.org/cgi-bin/mailman/listinfo/m-etc-dev