1 Reply Latest reply on Jan 10, 2005 3:52 AM by Lefebvre M.

    New problem with the 3.0 version of javassist !

    Lefebvre M. Newbie

      Hello,

      I have just changed the version of my javassist library (from an unknown version -see at bottom- to 3.0) and I obtain a strange
      behaviour.

      I define a class extending ClassLoader referencing the class pool.

      *** I define the pool with the following code:

      pool = ClassPool.getDefault();

      //set the directories and jar files for search for the javassist pool
      pool.appendPathList(pathList + File.pathSeparator + flavorLib.getAbsolutePath());

      *** To fill it , I do:

      // Loading the initial file (whose loading is delegated to the parent class loader)
      try {
      virtualParameterClass = pool.get("tmbrowser.tmserver.VirtualParameter");
      } catch (NotFoundException e) {
      ...

      // Creating the wanted class
      boolean classAlreadyExist = false;
      try {
      upVParamClass = pool.get(upVParamClassName);
      // the class has already been defined
      classAlreadyExist = true;
      upVParamClass.defrost();

      } catch(NotFoundException e) {
      upVParamClass = pool.makeClass(upVParamClassName, virtualParameterClass);
      ...


      *** And to retrieve the java.lang.Class I want from the pool (source), I do:

      CtClass ctClass = source.get(name);
      if (ctClass != null)
      classfile = ctClass.toBytecode();

      // And I return a Class
      return defineClass(name, classfile, 0, classfile.length);



      With my old version, the class was properly loaded in my own classLoader, with the new one, it is loaded in the system one.

      Are some changes in the library explaining this phenomenon ? Or is there a probleme in my code that was masked with the old version.

      Thank you for your help, because I don't really know where to have a look. :-(

      ---
      Marilyne.

      Here is the content of the manifest of the old version:
      -------------------------------------------------------
      Manifest-Version: 1.0
      Ant-Version: Apache Ant 1.5.3
      Created-By: 1.4.1_01-b01 (Sun Microsystems Inc.)