JDK的ClassLoaderHelper没有用法

时间:2019-07-04 05:55:41

标签: java classloader helper

ClassLoaderHelper没有意义

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

我没有找到mapAlternativeName不能被使用(静态)的任何用法

评论也没有实际意义

/**
 * 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.
 */

它是以前版本的遗留下来的还是只是供将来使用的指定Helper类?

编辑

我发现了一个相关的错误(解决方案:未解决)JDK-7157665 : Use ClassLoaderHelper for all native library loads

  

需要更新7134701的修复程序,以便对其他代码路径进行相同的更改,其中   加载本地库:即   -使用非引导类加载器的地方,以及   -在其中调用System.load()

     

在这两种情况下,都提供了绝对路径名,但是(在Mac上)我们应该尝试加载   首先是Mac上的原始文件,为了与Apple的jdk 6兼容,我们应该寻找一个.jnilib   如果原始名称为* .dylib,但找不到,则为变体。

1 个答案:

答案 0 :(得分:0)

我下载了Java 12源代码,发现该类已更改,并添加了常量:

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

它在ClassLoader中使用:

if (ClassLoaderHelper.allowsQuotedPathElements && ...

所以不能删除此类(并且它为ClassLoader指定了Helper类)