Release 0.3.3 [POMified]

54 views
Skip to first unread message

Dawid Weiss

unread,
Jan 25, 2011, 8:12:01 AM1/25/11
to java-high-performance-primitive-collections
Dear All,

Version 0.3.3 of HPPC has been released. This release does NOT come
with any code
changes other than cosmetic adjustments in test classes (no changes in
the library code).
It merely marks a switch to Maven as the build platform (full POM is
available) and Maven
Central as the distribution channel for final releases.

JIRA issues:
http://issues.carrot2.org/secure/IssueNavigator.jspa?reset=true&jqlQuery=project+%3D+HPPC+AND+fixVersion+%3D+%220.3.3%22+ORDER+BY+updated+DESC,+priority+DESC,+created+ASC&mode=hide

0.3.3 artefacts should be visible in Maven Central in about an hour (syncing).

Thanks,
Dawid

Dawid Weiss

unread,
Feb 17, 2011, 3:46:43 AM2/17/11
to dymaxion, java-high-performance-primitive-collections
Hi Spencer,

This is a known bug/issue that somehow slipped through (there is in
general a problem with generic arrays in Java, they're a pain). I
filed an issue for this here, watch it to get updates:

http://issues.carrot2.org/browse/HPPC-46

Thanks for the info,
Dawid

P.S. Use the project's mailing list so that others know about such
issues, please. Thanks!

On Thu, Feb 17, 2011 at 5:58 AM, dymaxion <spenc...@gmail.com> wrote:
> Dear David,
>
> I stumbled upon your HPPC libraries recently having previously look at
> Trove and Javolution.
> I like the goals of your library and the assertions based checks.
>
> I have come across an issue which is probably a trivial one for you to
> answer, regarding ObjectArrayList
> Whenever I access the buffer directly or call  toArray()  I get a
> ClassCastException at runtime.
> Instead for buffer access, I have to declare Object[] array,  then
> cast each individual element as I iterate over them to avoid the
> problem.
>
> Best regards
> Spencer
>
> eg.
>
> <code>
> ObjectArrayList<MyOwnType> events = new ObjectArrayList<MyOwnType>();
> events.add(.....);
>
> final int size = events.size();
> MyOwnType[] arr1 = events.buffer;
> MyOwnType[] arr2 = events.toArray();
> </code>
>
> Am I doing something silly or is this a known issue with
> workaround....
> I'm using JDK 1.7  (build 1.7.0-ea-b125)
>
>

Dawid Weiss

unread,
Mar 30, 2011, 4:39:52 AM3/30/11
to Spencer Goh, java-high-performance-primitive-collections
Unfortunately this is a result of how generic types are implemented in
Java (type erasure). There is no way to create that array with the
proper type (given in the generic argument). This could be done if one
gave the class type to the constructor, and then on using reflection,
but it makes very little sense.

I advise you to:

1) use the list's getter methods, they do proper casting to the target
type. Casts are cheap and these methods will get inlined anyway.
2) if you really need those arrays, do a cast to Object[] before any
loops (local variable) and then cast to your desired type inside the
loop (again, casts are cheap).
3) if you need T[] array, you will have to create it and
System.arraycopy elements.

Dawid

On Wed, Mar 30, 2011 at 10:15 AM, Spencer Goh <em...@spencergoh.com> wrote:
> Hi David,
>
> I noted the fix for the toArray() method. Thanks.
>
> Is there any workaround for the buffer direct access issue?
>
> I have to do a double cast in order to iterate over an ObjectArrayList's
> internal buffer
> See attached code and test result
>
> Thanks
> Spencer

Reply all
Reply to author
Forward
0 new messages