Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-2051

Blueprint Spring SpringApplicationContext ClassLoader implementation not working for loadClass(name, resolve) operation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • blueprint-spring-1.0.0
    • None
    • Blueprint
    • None

    Description

      Blueprint Spring SpringApplicationContext uses its own ClassLoader.

      This class loader implementation however is not handling calls to loadClass(String name, boolean resolve), which is used by other class loaders.
      Therefore if we obtain class loader for app context and use it for example with Groovy, it will fail asĀ 

      @Override
      public Class<?> loadClass(String name) throws ClassNotFoundException...

      Will not be called at all.

      Proper implementation should be:

      @Override
      public Class<?> loadClass(String name) throws ClassNotFoundException {
          return loadClass(name, false);
      }
      
      @Override
      public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
          for (ClassLoader cl : parentClassLoaders) {
              try {
                  Class<?> c = cl.loadClass(name);
                  if (resolve) {
                      resolveClass(c);
                  }
                  return c;
              } catch (ClassNotFoundException e) {
                  // Ignore
              }
          }
          throw new ClassNotFoundException(name);
      } 

      Attachments

        Activity

          People

            Unassigned Unassigned
            nannou9 Piotr Klimczak
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: