[
https://issues.apache.org/jira/browse/SOLR-2410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13003690#comment-13003690
]
Yonik Seeley edited comment on SOLR-2410 at 3/7/11 11:40 PM:
-------------------------------------------------------------
Thanks Dawid!
bq. 2) cast superclass's array to (Object[]) first, then cast to the concrete
component type. Here:
I tried this, but couldn't get it to work:
{code}
class Example
{
public static class A<T> {
@SuppressWarnings("unchecked") // it is here for a reason :)
public T[] array = (T[]) new Object [1];
}
public static void main(String [] args)
{
A<Integer> clazzA = new A<Integer>();
System.out.println(((Integer[])((Object[])clazzA.array))[0]);
}
}
{code}
edit: I got it - you need to access the array as an Object[]
{code}
System.out.println( (Integer) (((Object[])clazzA.array)[0]));
{code}
was (Author: [email protected]):
Thanks Dawid!
bq. 2) cast superclass's array to (Object[]) first, then cast to the concrete
component type. Here:
I tried this, but couldn't get it to work:
{code}
class Example
{
public static class A<T> {
@SuppressWarnings("unchecked") // it is here for a reason :)
public T[] array = (T[]) new Object [1];
}
public static void main(String [] args)
{
A<Integer> clazzA = new A<Integer>();
System.out.println(((Integer[])((Object[])clazzA.array))[0]);
}
}
{code}
> ConcurrentLRUCache can throw class cast exception
> -------------------------------------------------
>
> Key: SOLR-2410
> URL: https://issues.apache.org/jira/browse/SOLR-2410
> Project: Solr
> Issue Type: Bug
> Affects Versions: 4.0
> Reporter: Yonik Seeley
> Fix For: 4.0
>
>
> ConcurrentLRUCache throws a class cast exception.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]