Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-177

Incorrect assumption about Class.getPackage()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • RC 1
    • Beta 9
    • jaxrs
    • None
    • Low

      AbstractJAXBContextFinder uses Class.getPackage(). The javadocs for this method state that it can return null (its up the classloader), so you can't rely on it to look up the class package. The correct solution is to use string manipulation on the class name instead, such as:

      String packageName;
      int packageSeparator = name.lastIndexOf('.');
      if (packageSeparator != -1)
      {
      packageName = type.getName().substring(0, packageSeparator);
      }
      else
      {
      packageName = type.getName();
      }

              patriot1burke@gmail.com Bill Burke (Inactive)
              hani13_jira Hani Suleiman (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: