[jboss-jira] [JBoss JIRA] Commented: (GPD-130) Class Cast exception in ConfigInfoElement.getConfigInfoElements()

Imran Naqvi (JIRA) jira-events at lists.jboss.org
Tue Aug 7 13:54:49 EDT 2007


    [ http://jira.jboss.com/jira/browse/GPD-130?page=comments#action_12371355 ] 
            
Imran Naqvi commented on GPD-130:
---------------------------------

yes th array should only contain ConfigInfoElements. But the following lines in ConfigInfoElements.getConfigInfoElements() always returns a class cast exception:

return (ConfigInfoElement[])configInfoElements.toArray(new Object[configInfoElements.size()]);

this is because we are trying to directly cast from Object[] to ConfigInfoElement[]. Even though every element in Object[] is a ConfigInfoElement, it is still not allowed to have two references to an array of different types. Instead something like this would work:

                                          ConfigInfoElement[] elements = new ConfigInfoElement[configInfoElements.size()];
		for (int i = 0; i < configInfoElements.size(); i++)
			elements[i] = (ConfigInfoElement) this.configInfoElements.get(i);

		return elements;

> Class Cast exception in ConfigInfoElement.getConfigInfoElements() 
> ------------------------------------------------------------------
>
>                 Key: GPD-130
>                 URL: http://jira.jboss.com/jira/browse/GPD-130
>             Project: JBoss jBPM GPD
>          Issue Type: Bug
>          Components: jpdl
>    Affects Versions: jBPM JPDL Designer 3.1.0.beta2
>            Reporter: Imran Naqvi
>         Assigned To: Koen Aers
>             Fix For: jBPM JPDL Designer 3.1.0.CR
>
>
> ConfigInfoElement.getConfigInfoElements() always throws a class cast exception. The method is trying to cast from an object[] to a ConfigInfoElement[]. Instead we should cast each object in the array individually and copy it to the resultant array. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list