Abdera
  1. Abdera
  2. ABDERA-279

Faulty classloading - unreachable code

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1.1
    • Fix Version/s: None
    • Labels:
      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.

      1. fix_classloader.patch
        1.0 kB
        Antoine Toulme

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Antoine Toulme
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development