Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8E684913E for ; Thu, 22 Dec 2011 07:33:31 +0000 (UTC) Received: (qmail 38014 invoked by uid 500); 22 Dec 2011 07:33:31 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 37976 invoked by uid 500); 22 Dec 2011 07:33:25 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 37969 invoked by uid 99); 22 Dec 2011 07:33:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2011 07:33:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2011 07:33:23 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A382E2388AB9; Thu, 22 Dec 2011 07:33:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1222080 - /sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java Date: Thu, 22 Dec 2011 07:33:02 -0000 To: commits@sling.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111222073302.A382E2388AB9@eris.apache.org> Author: fmeschbe Date: Thu Dec 22 07:33:02 2011 New Revision: 1222080 URL: http://svn.apache.org/viewvc?rev=1222080&view=rev Log: SLIGN-2341 Apply slightly modified patch by Julian Sedding (thanks alot!) - A temporary variable srv is used to be able to apply the @SuppressWarnings("unchecked") annotation to this assignment instead of to the method Modified: sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java Modified: sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java?rev=1222080&r1=1222079&r2=1222080&view=diff ============================================================================== --- sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java (original) +++ sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java Thu Dec 22 07:33:02 2011 @@ -19,6 +19,7 @@ package org.apache.sling.scripting.core; import java.io.IOException; +import java.lang.reflect.Array; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -220,7 +221,6 @@ public class ScriptHelper implements Sli /** * @see org.apache.sling.api.scripting.SlingScriptHelper#getServices(java.lang.Class, java.lang.String) */ - @SuppressWarnings("unchecked") public ServiceType[] getServices( Class serviceType, String filter) throws InvalidServiceFilterSyntaxException { @@ -231,6 +231,7 @@ public class ScriptHelper implements Sli if (refs != null) { final List objects = new ArrayList(); for (int i = 0; i < refs.length; i++) { + @SuppressWarnings("unchecked") final ServiceType service = (ServiceType) this.bundleContext.getService(refs[i]); if (service != null) { if ( this.references == null ) { @@ -241,7 +242,9 @@ public class ScriptHelper implements Sli } } if (objects.size() > 0) { - result = (ServiceType[]) objects.toArray(); + @SuppressWarnings("unchecked") + ServiceType[] srv = (ServiceType[]) Array.newInstance(serviceType, objects.size()); + result = objects.toArray(srv); } } return result;