Uploaded image for project: 'Abdera'
  1. Abdera
  2. ABDERA-279

Faulty classloading - unreachable code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.1.1
    • None
    • None

    Description

      The Discover class uses this method to get a class:

            private static <T> Class<T> getClass(ClassLoader loader, String spec) {
              Class<T> c = null;
              try {
                  c = (Class<T>)loader.loadClass(spec);
                  c = (Class<T>)(c != null ? c : getClass(Discover.class.getClassLoader(), spec));
              } catch (ClassNotFoundException e) {
                  throw new RuntimeException(e);
              }
              return c;
          }
      

      However the first line inside the try statement will throw a CNF exception if the class cannot be found. As a result, the second line is never executed.

      c = (Class<T>)(c != null ? c : getClass(Discover.class.getClassLoader(), spec));
      

      The code executes recursively, which makes things harder. I would recommend changing the way the code is currently written to avoid recursion.

      Attachments

        1. fix_classloader.patch
          1.0 kB
          Antoine Toulme

        Activity

          People

            Unassigned Unassigned
            toulmean Antoine Toulme
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: