It does not matter which classloader you use. The classes loaded by the 
SystemClassLoader will allways be available due to the ClassLoader parent 
delegation.

Regards,
Hiram


>From: Jason Dillon <[EMAIL PROTECTED]>
>To: Dain Sundstrom <[EMAIL PROTECTED]>
>CC: JBoss-dev <[EMAIL PROTECTED]>
>Subject: Re: [JBoss-dev] Loading array class object by name
>Date: Sun, 24 Feb 2002 18:18:15 -0800
>
>Hrm... did you try using ClassLoader.getSystemClassLoader() ?
>
>--jason
>
>
>Dain Sundstrom wrote:
>
>>Doesn't work.  I tried [Ljava/lang/Object; and both without the
>>semicolon.
>>
>>-dain
>>
>>Jason Dillon wrote:
>>
>>>Try loading "[Ljava.lang.Object;" instead... which is the class name
>>>returned from Object[].class.getName();
>>>
>>>--jason
>>>
>>>
>>>Dain Sundstrom wrote:
>>>
>>>>
>>>>
>>>>Jason Dillon wrote:
>>>>
>>>>>What is the value for name you are using?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>In my test code "java.lang.Object[]"
>>>>
>>>>
>>>>>Why not just use Class.class?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>Because I am trying to load a parameter type from an xml file that
>>>>
>>>>just has the string name of the type.
>>>>
>>>>
>>>>
>>>>>Or if you really want to use Class.forName to load Class, then you
>>>>>should be able to use the system class loader.
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>>Is this after yesterdays Server/ServerLoader change?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>No new feature.  Class.forName docs say you can load arrays but it
>>>>is broken.  Here is the code I use now:
>>>>
>>>>private Class convertToJavaClass(String name) throws
>>>>DeploymentException {
>>>>    // Check primitive first
>>>>    for (int i = 0; i < PRIMITIVES.length; i++) {
>>>>       if(name.equals(PRIMITIVES[i])) {
>>>>          return PRIMITIVE_CLASSES[i];
>>>>       }
>>>>    }
>>>>
>>>>    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; i<arraySize; i++) {
>>>>             dimensions[i]=1;
>>>>          }
>>>>          c = Array.newInstance(c, dimensions).getClass();
>>>>       }
>>>>
>>>>       return c;
>>>>    } catch(ClassNotFoundException e) {
>>>>       throw new DeploymentException("Parameter class not found: " +
>>>>             name);
>>>>    }
>>>>}
>>>>
>>>>This is lame but works.
>>>>
>>>>-dain
>>>
>>>
>>>
>>>
>>
>
>
>
>_______________________________________________
>Jboss-development mailing list
>[EMAIL PROTECTED]
>https://lists.sourceforge.net/lists/listinfo/jboss-development



_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to