On Sat, Oct 4, 2008 at 12:37 AM, Matthew Toseland
<[EMAIL PROTECTED]> wrote:
> On Thursday 02 October 2008 12:30, [EMAIL PROTECTED] wrote:
>> Author: j16sdiz
>> Date: 2008-10-02 11:30:51 +0000 (Thu, 02 Oct 2008)
>> New Revision: 22908
>>
>> Modified:
>>    trunk/freenet/src/freenet/support/MultiValueTable.java
>> Log:
>> Generic for MultiValueTable
>>
>> Modified: trunk/freenet/src/freenet/support/MultiValueTable.java
>> ===================================================================
>> --- trunk/freenet/src/freenet/support/MultiValueTable.java    2008-10-01
> 21:59:33 UTC (rev 22907)
>> +++ trunk/freenet/src/freenet/support/MultiValueTable.java    2008-10-02
> 11:30:51 UTC (rev 22908)
> ...
>>
>> -    public Object[] getArray(Object key) {
>> +    public V[] getArray(K key) {
>>          synchronized (table) {
>> -            Vector v = (Vector) table.get(key);
>> +            Vector<V> v = table.get(key);
>>              if (v == null)
>>                  return null;
>>              else {
>> -                Object[] r = new Object[v.size()];
>> +                V[] r = (V[])new Object[v.size()];
>
> This doesn't work.

This does not work for normal array.
A generic V[] is a Object[] in its underlying structure.

(yes, that's why people hate java generic -- too many special cases)

>
> bsh % Object[] objects = new Object[5];
> bsh % Long[] longs = (Long[]) objects;
> // Error: // Uncaught Exception: Typed variable declaration : at Line: 2 : in
> file: <unknown file> : ( Long [ ] ) objects
>
> Target exception: java.lang.ClassCastException: Cannot cast java.lang.Object
> [] to java.lang.Long []
>
> bsh % Long[] longs = (Long[]) objects;
>
>
>>                  v.copyInto(r);
>>                  return r;
>>              }
>>          }
>>      }
>>
>
> _______________________________________________
> Devl mailing list
> [email protected]
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
>
_______________________________________________
Devl mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to