Search code examples
javaclassloaderhelper

JDK's ClassLoaderHelper has no usage


ClassLoaderHelper has no meaning

class ClassLoaderHelper {
    private ClassLoaderHelper() {}
    static File mapAlternativeName(File lib) {
        return null;
    }

I didn't find any usages for mapAlternativeName which can't be overridden (static)

Also comment has no real meaning

/**
 * Returns an alternate path name for the given file
 * such that if the original pathname did not exist, then the
 * file may be located at the alternate location.
 * For most platforms, this behavior is not supported and returns null.
 */

Is it just leftover from previous version or just a designating Helper class for future use?

EDIT

I found a relevant bug (Resolution: Unresolved) JDK-7157665 : Use ClassLoaderHelper for all native library loads

The fix for 7134701 needs to be updated to make the same change for the other code paths where native libraries are loaded: namely - where non-bootstrap classloaders are used and - where System.load() is called

In both those cases an absolute pathname is provided, but (on Mac) we should attempt to load the original file first and on Mac, for compatibility with Apple's jdk 6, we should look for a .jnilib variant if the original name was *.dylib, and it wasn't found.


Solution

  • I download Java 12 source and found that class was changed, added constant:

    /**
     * Indicates, whether PATH env variable is allowed to contain quoted entries.
     */
    static final boolean allowsQuotedPathElements = true;
    

    And it is used in ClassLoader:

    if (ClassLoaderHelper.allowsQuotedPathElements && ...
    

    So this class can't be deleted (and it's designating Helper class for ClassLoader)