felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard S. Hall" <he...@ungoverned.org>
Subject Re: IllegalArgumentException when trying to load a class
Date Mon, 03 Jan 2011 16:26:59 GMT
On 1/3/11 8:01, Michael Petritsch wrote:
> I think the java spec is not very clear on this. The classname has to
> be a "binary name" (which afaik a string containing parenthesis can't
> be), but still the loadClass method is accepting any type of string as
> parameter and the only exception this method should throw is a
> ClassNotFoundException.

It is my understanding that any method may throw runtime exceptions at 
any time, so they are not limited to some set of declared exceptions.

Regardless, I'm willing to look into improving it, if you want to open a 
bug with the information from your original message.

-> richard

> And when trying to loadClass(String className) with
> sun.misc.Launcher.AppClassLoader you get a ClassNotFoundException if
> the passed string contains parenthesis.
>
> I checked some sourcecode of harmony and they also never filter out
> strings with parenthesis (they're throwing a NullPointerException if
> the string is null though).
>
> So it is not legal to have classnames containing parenthesis, but it's
> (practically) legal trying to load such classes.
>
> Regards,
> Michael
>
> On Sun, Jan 2, 2011 at 4:32 PM, Richard S. Hall<heavy@ungoverned.org>  wrote:
>> Is it legal to have a parenthesis in a class name?
>>
>> What appears to be happening, is that this is just confusing our handling of
>> the dynamic import, because it is not expecting a parenthesis.
>>
>> If it isn't legal, then it is not clear what the "correct" exception should
>> be. If it is legal, then definitely open up a bug report.
>>
>> ->  richard
>>
>> On 1/2/11 9:25, Michael Petritsch wrote:
>>> Hi,
>>>
>>> a few weeks ago I wrote to the user-mailinglist but did not get a
>>> reply. That's why I am trying the dev-list now. We have the following
>>> situation here: a bundle is trying to load a class with a classname
>>> that contains '(' and ')'. Now usually (by other classloaders) the
>>> bundle is receiving a "ClassNotFoundException". Felix (or swissbox, I
>>> don't know who should be finally throwing the classnotfoundexception)
>>> is throwing an uncaught IllegalArgumentException instead.
>>>
>>> Here is the stacktrace:
>>>
>>> java.lang.IllegalArgumentException: Illegal value: Document doc =
>>> element.getOwnerDocument();
>>>       at
>>> org.apache.felix.framework.capabilityset.SimpleFilter.parseSubstring(SimpleFilter.java:399)
>>>       at
>>> org.apache.felix.framework.util.manifestparser.RequirementImpl.convertToFilter(RequirementImpl.java:162)
>>>       at
>>> org.apache.felix.framework.util.manifestparser.RequirementImpl.<init>(RequirementImpl.java:49)
>>>       at
>>> org.apache.felix.framework.Felix$FelixResolver.isAllowedDynamicImport(Felix.java:4139)
>>>       at
>>> org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:4029)
>>>       at
>>> org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1367)
>>>       at
>>> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:723)
>>>       at
>>> org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)
>>>       at
>>> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)
>>>       at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>>>       at
>>> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:634)
>>>       at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1594)
>>>       at
>>> org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:887)
>>>       at
>>> org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176)
>>>       at
>>> org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:194)
>>>       at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>>>       at org.milyn.util.ClassUtil.forName(ClassUtil.java:82)
>>>
>>> Looking forward to some feedback on this topic.
>>>
>>> Regards,
>>> Michael

Mime
View raw message