hk2
  1. hk2
  2. HK2-158

Descriptor.getLoader() should check Thread.getContextClassLoader()

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.0
    • Component/s: None
    • Labels:
      None

      Description

      According to https://hk2.java.net/2.2.0-b24/extensibility.html and https://hk2.java.net/2.2.0-b24/apidocs/org/glassfish/hk2/api/Descriptor.html#getLoader() the loading order is:

      1. The classloader of the class being injected into, otherwise
      2. HK2's classloader

      If a user invokes ServiceLocator.getService(Foo.class), then we don't know where Foo is being injected into. In such a case, I think it makes sense to check the value of Thread.getContextClassLoader() before using HK2's classloader.

        Activity

        Hide
        jwells added a comment -

        The CCL is now consulted if the other methods do not find the class. I could not add it in front because that would have backward compatibility issues. So if the class is not found by the other means it will try with the CCL.

        Show
        jwells added a comment - The CCL is now consulted if the other methods do not find the class. I could not add it in front because that would have backward compatibility issues. So if the class is not found by the other means it will try with the CCL.

          People

          • Assignee:
            jwells
            Reporter:
            cowwoc
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 30 minutes
              30m
              Remaining:
              Remaining Estimate - 30 minutes
              30m
              Logged:
              Time Spent - Not Specified
              Not Specified