当前位置: 首页>>代码示例>>Java>>正文


Java Plugin.transform方法代码示例

本文整理汇总了Java中jdk.tools.jlink.plugin.Plugin.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Plugin.transform方法的具体用法?Java Plugin.transform怎么用?Java Plugin.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.tools.jlink.plugin.Plugin的用法示例。


在下文中一共展示了Plugin.transform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stripDebug

import jdk.tools.jlink.plugin.Plugin; //导入方法依赖的package包/类
private ResourcePoolEntry stripDebug(Plugin debug, ResourcePoolEntry classResource,
        String path, String infoPath, byte[] moduleInfo) throws Exception {
    ResourcePoolManager resources = new ResourcePoolManager();
    resources.add(classResource);
    if (!path.endsWith("module-info.class")) {
        ResourcePoolEntry res2 = ResourcePoolEntry.create(infoPath, moduleInfo);
        resources.add(res2);
    }
    ResourcePoolManager results = new ResourcePoolManager();
    ResourcePool resPool = debug.transform(resources.resourcePool(),
            results.resourcePoolBuilder());
    System.out.println(classResource.path());

    return resPool.findEntry(classResource.path()).get();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:StripDebugPluginTest.java

示例2: applyCompressor

import jdk.tools.jlink.plugin.Plugin; //导入方法依赖的package包/类
private ResourcePool applyCompressor(Plugin plugin,
        ResourcePoolManager inputResources,
        ResourcePoolEntry res,
        List<Pattern> includesPatterns) {
    ResourcePoolManager resMgr = new ResourcePoolManager(ByteOrder.nativeOrder(),
            inputResources.getStringTable());
    ResourcePool compressedResourcePool = plugin.transform(inputResources.resourcePool(),
        resMgr.resourcePoolBuilder());
    String path = res.path();
    ResourcePoolEntry compressed = compressedResourcePool.findEntry(path).get();
    CompressedResourceHeader header
            = CompressedResourceHeader.readFromResource(ByteOrder.nativeOrder(), compressed.contentBytes());
    if (isIncluded(includesPatterns, path)) {
        if (header == null) {
            throw new AssertionError("Path should be compressed: " + path);
        }
        if (header.getDecompressorNameOffset() == 0) {
            throw new AssertionError("Invalid plugin offset "
                    + header.getDecompressorNameOffset());
        }
        if (header.getResourceSize() <= 0) {
            throw new AssertionError("Invalid compressed size "
                    + header.getResourceSize());
        }
    } else if (header != null) {
        throw new AssertionError("Path should not be compressed: " + path);
    }
    return compressedResourcePool;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:CompressorPluginTest.java

示例3: doCheckVM

import jdk.tools.jlink.plugin.Plugin; //导入方法依赖的package包/类
private void doCheckVM(String vm, String[] input, String jvmcfg, String[] expectedOutput, String expectdJvmCfg) throws Exception {
    // Create a pool with jvm.cfg and the input paths.
    byte[] jvmcfgContent = jvmcfg.getBytes();
    ResourcePoolManager poolMgr = new ResourcePoolManager();
    poolMgr.add(
        ResourcePoolEntry.create("/java.base/lib/jvm.cfg",
            ResourcePoolEntry.Type.NATIVE_LIB, jvmcfgContent));

    // java.base/module-info.class is used by exclude vm plugin
    // to get current osName(). We read it from jrt-fs and add a
    // ResourcePoolEntry
    poolMgr.add(
        ResourcePoolEntry.create("/java.base/module-info.class",
            ResourcePoolEntry.Type.CLASS_OR_RESOURCE, getJavaBaseModuleInfo()));
    for (String in : input) {
        poolMgr.add(ResourcePoolEntry.create(in,
                ResourcePoolEntry.Type.NATIVE_LIB, new byte[0]));
    }
    ResourcePoolManager outMgr = new ResourcePoolManager();

    Plugin p = new ExcludeVMPlugin();
    Map<String, String> config = new HashMap<>();
    if (vm != null) {
        config.put(ExcludeVMPlugin.NAME, vm);
    }
    p.configure(config);
    ResourcePool out = p.transform(poolMgr.resourcePool(), outMgr.resourcePoolBuilder());

    String newContent = new String(out.findEntry("/java.base/lib/jvm.cfg").get().contentBytes());

    if (!expectdJvmCfg.equals(newContent)) {
        throw new Exception("Got content " + newContent + " expected " + expectdJvmCfg);
    }

    // Apart from native resources, we should find jvm.cfg and
    // java.base/module-info.class. So, we add 2 here to the
    // expected count!
    if (out.entryCount() != (expectedOutput.length + 2)) {
        out.entries().forEach(m -> {
            System.err.println(m.path());
        });
        throw new Exception("Invalid output size " + out.entryCount() + " expected " + (expectedOutput.length + 2));
    }

    out.entries().forEach(md -> {
        if (md.path().equals("/java.base/lib/jvm.cfg") ||
            md.path().equals("/java.base/module-info.class")) {
            return;
        }
        boolean contained = false;
        for (String o : expectedOutput) {
            if (md.path().equals(o)) {
                contained = true;
                break;
            }
        }
        if (!contained) {
            throw new RuntimeException(md.path() + " not expected");
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:62,代码来源:ExcludeVMPluginTest.java


注:本文中的jdk.tools.jlink.plugin.Plugin.transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。