Return-Path: Delivered-To: apmail-felix-dev-archive@www.apache.org Received: (qmail 10998 invoked from network); 23 Jul 2008 12:13:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jul 2008 12:13:09 -0000 Received: (qmail 31357 invoked by uid 500); 23 Jul 2008 12:13:08 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 31320 invoked by uid 500); 23 Jul 2008 12:13:07 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 31306 invoked by uid 99); 23 Jul 2008 12:13:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jul 2008 05:13:07 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of fmeschbe@gmail.com designates 209.85.134.184 as permitted sender) Received: from [209.85.134.184] (HELO mu-out-0910.google.com) (209.85.134.184) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jul 2008 12:12:13 +0000 Received: by mu-out-0910.google.com with SMTP id w9so1451646mue.0 for ; Wed, 23 Jul 2008 05:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=u7vtmj5O6JQuklDcjXwLhRI4EJle5s4V2BgTmD8PjrU=; b=B746pYKgKTdAMCAAeb0OO4nM5JoLo0j/Mph4ul4uanwCu1szaeOHZOWpJ+QxulBSLA W9BtRESQCiYlKJ0e2tJ7NR18Vymgl4xhvRG+ZgiuyrYHT7YV8/UJf9T/H7+VIGauYzda aMPsoiaLiv/I73eme81lVp0MsSXFQEYJRRZ/Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=F8ZrV7S0fzPl62CmPoaJIgKZbY7YzsyYSqDs2MsJIpVYYY6zBWueLHdmxe2inDL9u1 VAuiuTi7oKCiN4ANMO5YLGHDD+NDURodMGv2nU/PD63qFarqV8cpzW8RPWGNy+U7oMqz ifQ2VXhWimn6IdSUs13SmiJMBt/tp2eKqUpCc= Received: by 10.103.6.6 with SMTP id j6mr4542301mui.89.1216815157651; Wed, 23 Jul 2008 05:12:37 -0700 (PDT) Received: from bslm-046.corp.day.com ( [87.102.138.82]) by mx.google.com with ESMTPS id j2sm52691676mue.8.2008.07.23.05.12.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 23 Jul 2008 05:12:35 -0700 (PDT) Message-ID: <48872031.4070009@gmail.com> Date: Wed, 23 Jul 2008 14:12:33 +0200 From: Felix Meschberger User-Agent: Thunderbird 2.0.0.14 (X11/20080501) MIME-Version: 1.0 To: dev@felix.apache.org Subject: Re: Question about class loading and SCR (see FELIX-624) References: <487213B7.2040303@apache.org> <81f0d9c0807070609qf1460beledef80369cf703c0@mail.gmail.com> <48721B84.4030404@apache.org> <81f0d9c0807070719v18de67d5t7805037a968c3d66@mail.gmail.com> <48722DD7.1070304@apache.org> In-Reply-To: <48722DD7.1070304@apache.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, Carsten Ziegeler schrieb: > Stuart McCulloch wrote: >> >> looking at the current code that trawls the super-classes, I believe the >> problem could be solved by changing 'DependencyManager.java:734' >> so a ClassNotFoundException will drop down to the exhaustive search >> of declared methods (this code would need to be refactored out, so it >> can be called from multiple catch blocks) The reason for trawling the super-classes is, that protected methods are only accessible through reflection with the Class.getDeclaredMethod method. This method in turn only returned methods of the Class itself not methods of extended classes. >> >> re-writing that whole function might reveal more optimizations though :) >> > Yes, I took a much simpler approach which should be alright: I use the > bundle which exports the service for loading the class. This classloader > has already loaded the class as the bundle is exporting this service. > And this class should be the same which should be used for the > bind/unbind method as otherwise class cast exceptions would occur. Right, this should work as the framework should already guarantee that the class object used by the service and the class object used by the abstract class with the bind methods are the same. Nevertheless, I would think, that using the class loader from Class.getClassLoader() of the class providing the bind (or unbind) method to be called is probably better than using the bundle providing the service. Its just cleaner IMHO. That is the assignment of the parameterClass in DependencyManager#734 would be: parameterClass = targetClass.getClassLoader().loadClass(parameterClassName) instead of using serviceBundle.loadClass. Of course, we would have to catch (and ignore) the ClassNotFoundException here, as the loader of the target class might not have the parameter class because the target class does not have the bind method we are looking for. WDYT ? Regards Felix > > A quick test of our hugh application massivly using SCR did not reveal > any problems. > > Carsten >