You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Julian Sedding (Created) (JIRA)" <ji...@apache.org> on 2011/12/22 01:23:30 UTC

[jira] [Created] (SLING-2341) SlingScriptHelper#getServices() causes ClassCastException

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
             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

        

[jira] [Commented] (SLING-2341) SlingScriptHelper#getServices() causes ClassCastException

Posted by "Julian Sedding (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174706#comment-13174706 ] 

Julian Sedding commented on SLING-2341:
---------------------------------------

Thanks for the quick fix!
                
> 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

        

[jira] [Assigned] (SLING-2341) SlingScriptHelper#getServices() causes ClassCastException

Posted by "Felix Meschberger (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger reassigned SLING-2341:
----------------------------------------

    Assignee: Felix Meschberger
    
> 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

        

[jira] [Updated] (SLING-2341) SlingScriptHelper#getServices() causes ClassCastException

Posted by "Julian Sedding (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-2341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Sedding updated SLING-2341:
----------------------------------

    Attachment: SLING-2341.patch

proposed patch
                
> 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
>             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

        

[jira] [Commented] (SLING-2341) SlingScriptHelper#getServices() causes ClassCastException

Posted by "Felix Meschberger (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-2341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174663#comment-13174663 ] 

Felix Meschberger commented on SLING-2341:
------------------------------------------

Thanks for reporting the bug and providing the patch.
                
> 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

        

[jira] [Resolved] (SLING-2341) SlingScriptHelper#getServices() causes ClassCastException

Posted by "Felix Meschberger (Resolved) (JIRA)" <ji...@apache.org>.
     [ 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