You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Henri Yandell <fl...@gmail.com> on 2005/01/26 23:34:39 UTC
[lang] new method on ClassUtils
I'd like to add ClassUtils.forName; to all intents and purposes the
same as Class.forName except that:
1) It understands arrays ending with [] instead of the [L<class>; ugliness.
2) It can handle primitives, "int" would correctly return int.class.
3) (perhaps?) null-safe. No idea really, just throwing it in :)
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] new method on ClassUtils
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Can we not leave this until after 2.1?? Rushing
something like this is a Bad Idea...
Stephen
--- Henri Yandell <fl...@gmail.com> wrote:
> On Wed, 2 Feb 2005 00:19:06 -0000, Stephen
> Colebourne
> <sc...@btopenworld.com> wrote:
> > I think that we would have to ask for classloader
> advice ;-)
>
> Probably.
>
> > I suspect we would need:
> >
> > loadClassSystemClassLoader() - Class.forName
> > loadClassThreadContextClassLoader() - thread
> > loadClassLangClassLoader() - from ClassUtils
> > loadClass(ClassLoader)
>
> We could just do the latter? Let's all the options
> be used without us
> having to drag through a list of all the likely
> options. No matter
> what classloader advice we got, it's likely to be
> usable.
>
> Hen
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] new method on ClassUtils
Posted by Henri Yandell <fl...@gmail.com>.
Potential problem with the forName is bad issue, we already have a
method using forName:
convertClassNamesToClasses
which turns a List of String into a List of Class using forName.
So, a) this seems to be a problem? b) I'd like to point it at the new
forName method (or however that gets solved).
Hen
On Tue, 1 Feb 2005 20:11:09 -0500, Henri Yandell <fl...@gmail.com> wrote:
> On Wed, 2 Feb 2005 00:19:06 -0000, Stephen Colebourne
> <sc...@btopenworld.com> wrote:
> > I think that we would have to ask for classloader advice ;-)
>
> Probably.
>
> > I suspect we would need:
> >
> > loadClassSystemClassLoader() - Class.forName
> > loadClassThreadContextClassLoader() - thread
> > loadClassLangClassLoader() - from ClassUtils
> > loadClass(ClassLoader)
>
> We could just do the latter? Let's all the options be used without us
> having to drag through a list of all the likely options. No matter
> what classloader advice we got, it's likely to be usable.
>
> Hen
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] new method on ClassUtils
Posted by Henri Yandell <fl...@gmail.com>.
On Wed, 2 Feb 2005 00:19:06 -0000, Stephen Colebourne
<sc...@btopenworld.com> wrote:
> I think that we would have to ask for classloader advice ;-)
Probably.
> I suspect we would need:
>
> loadClassSystemClassLoader() - Class.forName
> loadClassThreadContextClassLoader() - thread
> loadClassLangClassLoader() - from ClassUtils
> loadClass(ClassLoader)
We could just do the latter? Let's all the options be used without us
having to drag through a list of all the likely options. No matter
what classloader advice we got, it's likely to be usable.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] new method on ClassUtils
Posted by Stephen Colebourne <sc...@btopenworld.com>.
I think that we would have to ask for classloader advice ;-)
I suspect we would need:
loadClassSystemClassLoader() - Class.forName
loadClassThreadContextClassLoader() - thread
loadClassLangClassLoader() - from ClassUtils
loadClass(ClassLoader)
;-)
Stephen
----- Original Message -----
From: "Henri Yandell" <fl...@gmail.com>
> The important part for me is the munging that stops primitives being
> special and [] not working. I'm happy to replace the forName part with
> a better way and rename to getClass.
>
> Would Thread.currentThread().getContextClassLoader().loadClass(String)
> be acceptable instead of the forName call?
>
> Hen
>
> On Thu, 27 Jan 2005 23:43:58 -0000, Stephen Colebourne
> <sc...@btopenworld.com> wrote:
>> While I support the addition of a get class method in principle, I am
>> concerned that this brushes over the class loader issue. I would say that
>> Class.forName() will often cause problems, so maybe this isn't the best
>> way
>> to code this.
>>
>> Stephen
>>
>> ----- Original Message -----
>> From: "Henri Yandell" <fl...@gmail.com>
>> >I committed this btw.
>> >
>> > Hen
>> >
>> > On Wed, 26 Jan 2005 17:34:39 -0500, Henri Yandell <fl...@gmail.com>
>> > wrote:
>> >> I'd like to add ClassUtils.forName; to all intents and purposes the
>> >> same as Class.forName except that:
>> >>
>> >> 1) It understands arrays ending with [] instead of the [L<class>;
>> >> ugliness.
>> >> 2) It can handle primitives, "int" would correctly return int.class.
>> >> 3) (perhaps?) null-safe. No idea really, just throwing it in :)
>> >>
>> >> Hen
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>> >
>> >
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] new method on ClassUtils
Posted by Henri Yandell <fl...@gmail.com>.
The important part for me is the munging that stops primitives being
special and [] not working. I'm happy to replace the forName part with
a better way and rename to getClass.
Would Thread.currentThread().getContextClassLoader().loadClass(String)
be acceptable instead of the forName call?
Hen
On Thu, 27 Jan 2005 23:43:58 -0000, Stephen Colebourne
<sc...@btopenworld.com> wrote:
> While I support the addition of a get class method in principle, I am
> concerned that this brushes over the class loader issue. I would say that
> Class.forName() will often cause problems, so maybe this isn't the best way
> to code this.
>
> Stephen
>
> ----- Original Message -----
> From: "Henri Yandell" <fl...@gmail.com>
> >I committed this btw.
> >
> > Hen
> >
> > On Wed, 26 Jan 2005 17:34:39 -0500, Henri Yandell <fl...@gmail.com>
> > wrote:
> >> I'd like to add ClassUtils.forName; to all intents and purposes the
> >> same as Class.forName except that:
> >>
> >> 1) It understands arrays ending with [] instead of the [L<class>;
> >> ugliness.
> >> 2) It can handle primitives, "int" would correctly return int.class.
> >> 3) (perhaps?) null-safe. No idea really, just throwing it in :)
> >>
> >> Hen
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> >
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] new method on ClassUtils
Posted by Stephen Colebourne <sc...@btopenworld.com>.
While I support the addition of a get class method in principle, I am
concerned that this brushes over the class loader issue. I would say that
Class.forName() will often cause problems, so maybe this isn't the best way
to code this.
Stephen
----- Original Message -----
From: "Henri Yandell" <fl...@gmail.com>
>I committed this btw.
>
> Hen
>
> On Wed, 26 Jan 2005 17:34:39 -0500, Henri Yandell <fl...@gmail.com>
> wrote:
>> I'd like to add ClassUtils.forName; to all intents and purposes the
>> same as Class.forName except that:
>>
>> 1) It understands arrays ending with [] instead of the [L<class>;
>> ugliness.
>> 2) It can handle primitives, "int" would correctly return int.class.
>> 3) (perhaps?) null-safe. No idea really, just throwing it in :)
>>
>> Hen
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang] new method on ClassUtils
Posted by Henri Yandell <fl...@gmail.com>.
I committed this btw.
Hen
On Wed, 26 Jan 2005 17:34:39 -0500, Henri Yandell <fl...@gmail.com> wrote:
> I'd like to add ClassUtils.forName; to all intents and purposes the
> same as Class.forName except that:
>
> 1) It understands arrays ending with [] instead of the [L<class>; ugliness.
> 2) It can handle primitives, "int" would correctly return int.class.
> 3) (perhaps?) null-safe. No idea really, just throwing it in :)
>
> Hen
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org