Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8170834

internal API usage - add public API to determine if a class has been loaded

XMLWordPrintable

      A DESCRIPTION OF THE REQUEST :
      Prior to JDK 9, one could use reflection to bypass accessing checking and invoke the protected ClassLoader.findLoadedClass method to determine if a class with a given name had been loaded. Unlike Class.forName, the findLoadedClass method does not try to load the class. A public API is needed to make this functionality available in JDK 9 and later.

      JUSTIFICATION :
      To support loose coupling, it is useful to be able to test that a class has been loaded before trying to use it. A clear example is calling a method to release resources. If the class has not been loaded, it has no resources, so there is no point in loading the class to ask it to release resources.



      CUSTOMER SUBMITTED WORKAROUND :
      An alternative is to check for the package of the class being defined. This may or may not be equivalent to checking for the class being loaded.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: