You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Felix Meschberger (Resolved) (JIRA)" <ji...@apache.org> on 2011/12/22 08:34:31 UTC
[jira] [Resolved] (SLING-2341) SlingScriptHelper#getServices()
causes ClassCastException
[ https://issues.apache.org/jira/browse/SLING-2341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger resolved SLING-2341.
--------------------------------------
Resolution: Fixed
Applied the patch (slightly modified) in Rev. 1222080.
This modification allows me to set the @SuppressWarning annotation on the assignment statement instead of on the method, which would be to broad.
> SlingScriptHelper#getServices() causes ClassCastException
> ---------------------------------------------------------
>
> Key: SLING-2341
> URL: https://issues.apache.org/jira/browse/SLING-2341
> Project: Sling
> Issue Type: Bug
> Components: Scripting
> Affects Versions: Scripting Core 2.0.18
> Reporter: Julian Sedding
> Assignee: Felix Meschberger
> Fix For: Scripting Core 2.0.20
>
> Attachments: SLING-2341.patch
>
>
> The implementation of ScriptHelper#getServices() creates an Object[] and tries to cast it to the generics class. This results in a ClassCastException, as an Object[] cannot be cast to a more specific array (i.e. ServiceType[]). The solution is to create an array of the correct type and size using java.util.reflect.Array#newInstance(), see discussion on stackoverflow[0].
> [0] http://stackoverflow.com/questions/529085/java-how-to-generic-array-creation
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira