Hi folks,
I had this problem that I needed to create class objects for things
like "int" and "boolean", eg. the type specification that you would
use for a variable declaration or method parameter.
Since the normal Class.forName does not handle this really well, and
commons-lang does not provide s
--- Thomas Dudziak <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I had this problem that I needed to create class
> objects for things
> like "int" and "boolean", eg. the type specification
> that you would
> use for a variable declaration or method parameter.
> Since the normal Class.forName does n
(Ups, only replied to Wade, not the list)
On 9/5/05, Wade Chandler <[EMAIL PROTECTED]> wrote:
> What's a use case for it Tom? curious.
I just checked-in an enhancement for OJB that allows to specify which
constructor/factory-method to utilize for constructing objects read
from the database. The
Deja Vu :) +1
Jan-2005:http://mail-archives.apache.org/mod_mbox/jakarta-commons-dev/200501.mbox/[EMAIL
PROTECTED]
Feb-2005:http://mail-archives.apache.org/mod_mbox/jakarta-commons-dev/200502.mbox/[EMAIL
PROTECTED]
Various ClassLoader issues raised by Stephen, we agreed to hold off
until after 2
meBuffer.append( "L" + className + ";" );
}
clazz = Class.forName( actualNameBuffer.toString() );
}
else
{
clazz = Class.forName( className );
}
}
return clazz;
}
-Original Message-
From: Thomas Dudziak [mailto:[EMAIL PROTECTED]
Sen
tring abbreviation = ( String )abbreviationMap.get( className
> );
> if( abbreviation != null )
> {
> actualNameBuffer.append( abbreviation );
> }
> else
> {
> actualNameBuffer.append( "L" + className + ";" );
> }
> clazz = Class.forName(
oking to do. The obvious
place for it would be in ClassUtils, but I didn't see anything.
-Original Message-
From: Martin Cooper [mailto:[EMAIL PROTECTED]
Sent: Monday, September 05, 2005 10:19 PM
To: Jakarta Commons Developers List
Cc: [EMAIL PROTECTED]
Subject: Re: [lang] enhanced
irst place)?
-Original Message-
From: Henri Yandell [mailto:[EMAIL PROTECTED]
Sent: Monday, September 05, 2005 8:26 PM
To: Jakarta Commons Developers List; [EMAIL PROTECTED]
Subject: Re: [lang] enhanced version of Class.forName
Deja Vu :) +1
Jan-2005:http://mail-archives.apache.org/mod
Sorry, I meant "forCanonicalName" of course.
-Original Message-
From: James Carman [mailto:[EMAIL PROTECTED]
Sent: Monday, September 05, 2005 11:26 PM
To: 'Jakarta Commons Developers List'; [EMAIL PROTECTED]
Subject: RE: [lang] enhanced version of Class.forName
I ha
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> I would say that this is something that would be very useful. We did
> something similar in HiveMind. I can imagine an implementation like:
>
> private static Map typeMap = new HashMap();
> private static Map abbreviationMap = new HashMap();
ffer.append( "[" );
> }
> final String abbreviation = ( String )abbreviationMap.get( className
>);
> if( abbreviation != null )
> {
>actualNameBuffer.append( abbreviation );
> }
> else
> {
>actualNameBuffer.ap
Hi Thomas,
Thomas Dudziak wrote on Tuesday, September 06, 2005 9:09 AM:
[snip]
>
> * the direct usage of types (Integer.TYPE etc.) has obviously
> problems in environments with multiple class loaders (eg.
> Class.forName(String name, boolean initialize, ClassLoader
> classLoader); likewise there
On 9/6/05, Jörg Schaible <[EMAIL PROTECTED]> wrote:
> Thomas Dudziak wrote on Tuesday, September 06, 2005 9:09 AM:
>
> [snip]
> >
> > * the direct usage of types (Integer.TYPE etc.) has obviously
> > problems in environments with multiple class loaders (eg.
> > Class.forName(String name, boolean
On 9/6/05, Thomas Dudziak <[EMAIL PROTECTED]> wrote:
> On 9/6/05, Jörg Schaible <[EMAIL PROTECTED]> wrote:
>
> > Thomas Dudziak wrote on Tuesday, September 06, 2005 9:09 AM:
> >
> > [snip]
> > >
> > > * the direct usage of types (Integer.TYPE etc.) has obviously
> > > problems in environments with
iginal Message-
From: Henning P. Schmiedehausen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 06, 2005 3:30 AM
To: commons-dev@jakarta.apache.org
Subject: Re: [lang] enhanced version of Class.forName
"James Carman" <[EMAIL PROTECTED]> writes:
>I would say that this is s
PROTECTED]
Sent: Tuesday, September 06, 2005 3:09 AM
To: Jakarta Commons Developers List
Subject: Re: [lang] enhanced version of Class.forName
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> I would say that this is something that would be very useful. We did
> something similar in HiveM
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> 1. In an environment where a SecurityManager is installed (if you're
> running code that is going to try to replace system classes, I'd suggest
> it), code has to be given the permission to instantiate a ClassLoader.
> Also, that ClassLoader ha
classloader if it really is safer.
-Original Message-
From: Thomas Dudziak [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 06, 2005 8:59 AM
To: Jakarta Commons Developers List
Subject: Re: [lang] enhanced version of Class.forName
On 9/6/05, James Carman <[EMAIL PROTECTED]>
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> 1. If you're going to use that logic, then who is to say that the
> String.equals() or String.hashCode() method is implemented correctly?
> You're using a HashMap (so am I) that has Strings as keys. In your scenario
> (EvilClassLoader), the St
] enhanced version of Class.forName
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> 1. If you're going to use that logic, then who is to say that the
> String.equals() or String.hashCode() method is implemented correctly?
> You're using a HashMap (so am I) that has
sday, September 06, 2005 9:24 AM
To: Jakarta Commons Developers List
Subject: Re: [lang] enhanced version of Class.forName
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> 1. If you're going to use that logic, then who is to say that the
> String.equals() or String.hashCode
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> Well, I just tried your code against my test cases and it fails in two
> ways...
>
> 1. It doesn't throw an IllegalArgumentException when you pass in null.
> 2. It doesn't hand the actual java class names for array types (i.e.
> [[Ljava.lang.S
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> Okay, I caved (or compromised)! :-) I re-wrote the method to use your
> little trick of loading the array version of the class and taking the
> component type. The only problem I have with this is that I'm passing the
> "initialize" parameter i
September 06, 2005 10:12 AM
To: Jakarta Commons Developers List
Subject: Re: [lang] enhanced version of Class.forName
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> Okay, I caved (or compromised)! :-) I re-wrote the method to use your
> little trick of loading the array version o
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> 1. Well, it's not exactly the same thing. I'm talking about when they pass
> in just "boolean" or "int". In that case, we construct the name "[B" or
> "[I" and pass that to Class.forName() with the "initialize" parameter,
> thereby telling it
ed in (i.e. transforming it into the proper format)?
-Original Message-
From: Thomas Dudziak [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 06, 2005 10:39 AM
To: Jakarta Commons Developers List
Subject: Re: [lang] enhanced version of Class.forName
On 9/6/05, James Carman <[EMAIL PROTECTED
On 9/6/05, James Carman <[EMAIL PROTECTED]> wrote:
> Do you think we need to go through the trouble of throwing an
> IllegalArgumentException if it's not a well-formed class name (starts with
> character, blah blah blah)? Or, can we just let it throw a
> ClassNotFoundException after doing as much
James Carman wrote:
Do you think we need to go through the trouble of throwing an
IllegalArgumentException if it's not a well-formed class name (starts with
character, blah blah blah)? Or, can we just let it throw a
ClassNotFoundException after doing as much as we can with the string that's
pass
PROTECTED]
Sent: Tuesday, September 06, 2005 11:04 AM
To: Jakarta Commons Developers List
Subject: Re: [lang] enhanced version of Class.forName
James Carman wrote:
> Do you think we need to go through the trouble of throwing an
> IllegalArgumentException if it's not a well-formed class
IMO, you let the underlying JRE API throw the exception.
Gary
> -Original Message-
> From: James Carman [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 06, 2005 8:28 AM
> To: 'Jakarta Commons Developers List'
> Subject: RE: [lang] enhanced version of Clas
=?iso-8859-1?Q?J=F6rg_Schaible?= <[EMAIL PROTECTED]> writes:
>Hi Henning,
Hi Jörg,
>Well, looking into the JDK source I see no real advantage of not using
>endsWith. x.endsWith("[]") will exactly do 2 character compares (if the string
>matches), as well as your code above. And it only has one
ntext class loader.
--
Martin Cooper
-Original Message-
> From: Thomas Dudziak [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 06, 2005 3:09 AM
> To: Jakarta Commons Developers List
> Subject: Re: [lang] enhanced version of Class.forName
>
> On 9/6/05, James Ca
James Carman wrote:
Well, what does the [lang] "team" think about this approach (just letting
Class.forName() throw the ClassNotFoundException)? Does this work for you
guys? I have added a patch to issue 36512 which includes code to implement
it this way (my latest patch). Are there any votes
ite this method), but we might want to be consistent. I don't know.
-Original Message-
From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 06, 2005 4:25 PM
To: Jakarta Commons Developers List
Subject: Re: [lang] enhanced version of Class.forName
James Carman
Hi Henning,
Henning P. Schmiedehausen wrote on Tuesday, September 06, 2005 9:30 AM:
> "James Carman" <[EMAIL PROTECTED]> writes:
>
>> I would say that this is something that would be very useful. We did
>> something similar in HiveMind. I can imagine an implementation like:
>
> I always wonde
Hi Henning,
Henning P. Schmiedehausen wrote on Tuesday, September 06, 2005 6:09 PM:
[snip]
> => charAt is 3-4 times faster when not matching and almost twice as
>fast when matching. For the short case it is even faster.
>
> Get Test Class Source code from
> http://henning.schmiedehausen.org
36 matches
Mail list logo