[patch] SyntheticRepository

Sylvain Pasche <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
Hello,

Well, I had some mysterious ClassNotFound exceptions untill I applied
the following fix. I don't know if it is the right place to put it,
but at least it works for me now ;-)

Cheers,

        Sylvain



*** SyntheticRepository.java      2003-01-09 19:01:50.000000000 +0100
--- SyntheticRepository.java    2003-01-22 21:53:47.000000000 +0100
***************
*** 121,160 ****
--- 121,164 ----
     * Remove class from repository
     */
    public void removeClass(JavaClass clazz) {
      _loadedClasses.remove(clazz.getClassName());
    }
  
    /**
     * Find an already defined (cached) JavaClass object by name.
     */
    public JavaClass findClass(String className) {
      return (JavaClass)_loadedClasses.get(className);
    }
  
    /**
     * Load a JavaClass object for the given class name using
     * the CLASSPATH environment variable.
     */
    public JavaClass loadClass(String className) 
      throws ClassNotFoundException
    {
+       if  (_loadedClasses.containsKey(className))
+           return (JavaClass) _loadedClasses.get(className);
+ 
      if(className == null || className.equals("")) {
        throw new IllegalArgumentException("Invalid class name " + className);
      }
  
      className = className.replace('/', '.'); // Just in case, canonical form
  
      try {
        return loadClass(_path.getInputStream(className), className);
      } catch(IOException e) {
        throw new ClassNotFoundException("Exception while looking for class " + 
                                       className + ": " + e.toString());
      }
    }
  
    /**
     * Try to find class source via getResourceAsStream().
     * @see Class
     * @return JavaClass object for given runtime class
     */
    public JavaClass loadClass(Class clazz) throws ClassNotFoundException {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.