Re: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z)
On Sunday 05 May 2002 18:56, you wrote: Give me some time and I'll try to write a surogate Clazz.forName(className, classLoader) method that would take into account all possible types (including primitives and their arrays) as suggested by Dr. Christoph Jung. Ok, here it is. I attached it to the patch-551329: http://sourceforge.net/tracker/index.php?func=detailaid=551329group_id=22866atid=376687 This is org.jboss.util.ClassUtils class with a single static method: loadClass(String className, ClassLoader cl); It could be put into the common module, or alternatively into the existing org.jboss.util.Classes class. Peter ___ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
Re: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z)
On Friday 03 May 2002 06:24, Dain Sundstrom wrote: In org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCQueryMetaDataFactory I have a method (convertToJavaClass) that does the name to array class conversion. Here is the core: int arraySize = 0; while(name.endsWith([])) { name = name.substring(0, name.length()-2); arraySize++; } try { // get the base class Class c = entity.getClassLoader().loadClass(name); // if we have an array get the array class if(arraySize 0) { int[] dimensions = new int[arraySize]; for(int i=0; iarraySize; i++) { dimensions[i]=1; } c = Array.newInstance(c, dimensions).getClass(); } return c; } catch(ClassNotFoundException e) { throw new DeploymentException(Parameter class not found: + name); } I think this won't work in SpyObjectMessage. It uses java.io.ObjectStreamClass.getName() to obtain the class name. When I came across this problem in SpyObjectMessage, I remember that the debugging output I inserted printed out the name of the class in the form as documented in the Class.getName() method: new Object[1][1][1].getClass().getName() would be something like that: [[[Ljava.lang.Object; While Dain's method might serve it's purpose in his code, I think it won't work in SpyObjectMessage directly. It must be changed to acomodate this syntax. Give me some time and I'll try to write a surogate Clazz.forName(className, classLoader) method that would take into account all possible types (including primitives and their arrays) as suggested by Dr. Christoph Jung. Regards, Peter ___ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
Re: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z)
They should be the same thing as far as any of the docs I have read, but the observed difference is that Class.forName maintains a cache of Class objects keyed by name. Once a class is loaded by a given ClassLoader, it is that version of the class that is returned regardless of what the ClassLoader passed to Class.forName will return. We have run up against this with reloading EJBs and RMI proxies as the RMI subsystem makes use of the Class.forName(..., ClassLoader) call when dealing with MarshalledObjects. Scott Stark Chief Technology Officer JBoss Group, LLC - Original Message - From: Hiram Chirino [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 02, 2002 7:29 PM Subject: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z) Question for you classloading feaks out there, what is the difference between: x = some.class.name; Thread.currentThread().getContextClassLoader().loadClass(x); and x = some.class.name; Class.forName(x, false, Thread.currentThread().getContextClassLoader()); Peter Levart, submitted a patch that replaces a statment like the first with a statment like the seconds. It's supposed to allow loading array class for a base class that hasn't been loaded yet. My thing is, it seems like they do the same thing. What's the difference? Regards, Hiram ___ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
RE: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z)
makes no sense to me, ask for clarification and example marcf |-Original Message- |From: [EMAIL PROTECTED] |[mailto:[EMAIL PROTECTED]]On Behalf Of Hiram |Chirino |Sent: Thursday, May 02, 2002 7:30 PM |To: [EMAIL PROTECTED] |Subject: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z) | | |Question for you classloading feaks out there, what is the difference |between: | |x = some.class.name; |Thread.currentThread().getContextClassLoader().loadClass(x); | |and | |x = some.class.name; |Class.forName(x, false, | Thread.currentThread().getContextClassLoader()); | |Peter Levart, submitted a patch that replaces a statment like the |first with |a statment like the seconds. It's supposed to allow loading |array class for a base class that hasn't been loaded yet. | |My thing is, it seems like they do the same thing. What's the difference? | |Regards, |Hiram | |_ |Chat with friends online, try MSN Messenger: http://messenger.msn.com | | |___ | |Have big pipes? SourceForge.net is looking for download mirrors. We supply |the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] |___ |Jboss-development mailing list |[EMAIL PROTECTED] |https://lists.sourceforge.net/lists/listinfo/jboss-development ___ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
RE: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z)
|but the observed difference is that Class.forName maintains a cache |of Class objects keyed by name. Once a class is loaded by a given |ClassLoader, it is that version of the class that is returned regardless |of what the ClassLoader passed to Class.forName will return. We is that right? that is fucked up... man I can't believe these people. marcf ___ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
Re: [JBoss-dev] getContextClassLoader() vs. Class.forName(x,y,z)
In org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCQueryMetaDataFactory I have a method (convertToJavaClass) that does the name to array class conversion. Here is the core: int arraySize = 0; while(name.endsWith([])) { name = name.substring(0, name.length()-2); arraySize++; } try { // get the base class Class c = entity.getClassLoader().loadClass(name); // if we have an array get the array class if(arraySize 0) { int[] dimensions = new int[arraySize]; for(int i=0; iarraySize; i++) { dimensions[i]=1; } c = Array.newInstance(c, dimensions).getClass(); } return c; } catch(ClassNotFoundException e) { throw new DeploymentException(Parameter class not found: + name); } It that what he wanted to do? -dain Hiram Chirino wrote: Question for you classloading feaks out there, what is the difference between: x = some.class.name; Thread.currentThread().getContextClassLoader().loadClass(x); and x = some.class.name; Class.forName(x, false, Thread.currentThread().getContextClassLoader()); Peter Levart, submitted a patch that replaces a statment like the first with a statment like the seconds. It's supposed to allow loading array class for a base class that hasn't been loaded yet. My thing is, it seems like they do the same thing. What's the difference? Regards, Hiram _ Chat with friends online, try MSN Messenger: http://messenger.msn.com ___ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development ___ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development