8218913: Rename --strip-debug jlink plugin
Reviewed-by: alanb, mchung
This commit is contained in:
parent
c044650295
commit
15ec4ba5c6
@ -49,9 +49,9 @@ import jdk.tools.jlink.builder.DefaultImageBuilder;
|
||||
import jdk.tools.jlink.builder.ImageBuilder;
|
||||
import jdk.tools.jlink.internal.Jlink.PluginsConfiguration;
|
||||
import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
|
||||
import jdk.tools.jlink.internal.plugins.DefaultStripDebugPlugin;
|
||||
import jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin;
|
||||
import jdk.tools.jlink.internal.plugins.PluginsResourceBundle;
|
||||
import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
|
||||
import jdk.tools.jlink.plugin.Plugin;
|
||||
import jdk.tools.jlink.plugin.Plugin.Category;
|
||||
import jdk.tools.jlink.plugin.PluginException;
|
||||
@ -375,7 +375,7 @@ public final class TaskHelper {
|
||||
m.put(DefaultCompressPlugin.NAME, DefaultCompressPlugin.LEVEL_2);
|
||||
}, false, "--compress", "-c");
|
||||
mainOptions.add(plugOption);
|
||||
} else if (plugin instanceof StripDebugPlugin) {
|
||||
} else if (plugin instanceof DefaultStripDebugPlugin) {
|
||||
plugOption
|
||||
= new PluginOption(false,
|
||||
(task, opt, arg) -> {
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Red Hat, Inc.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.tools.jlink.internal.plugins;
|
||||
|
||||
import jdk.tools.jlink.plugin.Plugin;
|
||||
import jdk.tools.jlink.plugin.ResourcePool;
|
||||
import jdk.tools.jlink.plugin.ResourcePoolBuilder;
|
||||
|
||||
/**
|
||||
* Combined debug stripping plugin: Java debug attributes and native debug
|
||||
* symbols.
|
||||
*
|
||||
*/
|
||||
public final class DefaultStripDebugPlugin implements Plugin {
|
||||
|
||||
public static final String NAME = "strip-debug";
|
||||
|
||||
private final Plugin javaStripPlugin = new StripJavaDebugAttributesPlugin();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return PluginsResourceBundle.getDescription(NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
|
||||
return javaStripPlugin.transform(in, out);
|
||||
}
|
||||
|
||||
}
|
@ -25,26 +25,27 @@
|
||||
package jdk.tools.jlink.internal.plugins;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.tools.jlink.plugin.Plugin;
|
||||
import jdk.tools.jlink.plugin.ResourcePool;
|
||||
import jdk.tools.jlink.plugin.ResourcePoolBuilder;
|
||||
import jdk.tools.jlink.plugin.ResourcePoolEntry;
|
||||
import jdk.tools.jlink.plugin.Plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* Strip debug attributes plugin
|
||||
* Strip java debug attributes plugin
|
||||
*/
|
||||
public final class StripDebugPlugin implements Plugin {
|
||||
public static final String NAME = "strip-debug";
|
||||
public final class StripJavaDebugAttributesPlugin implements Plugin {
|
||||
public static final String NAME = "strip-java-debug-attributes";
|
||||
private final Predicate<String> predicate;
|
||||
|
||||
public StripDebugPlugin() {
|
||||
public StripJavaDebugAttributesPlugin() {
|
||||
this((path) -> false);
|
||||
}
|
||||
|
||||
StripDebugPlugin(Predicate<String> predicate) {
|
||||
StripJavaDebugAttributesPlugin(Predicate<String> predicate) {
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
@ -99,6 +99,9 @@ Order resources. e.g.: **/module-info.class,@classlist,/java.base/java/lang/**
|
||||
strip-debug.description=\
|
||||
Strip debug information from the output image
|
||||
|
||||
strip-java-debug-attributes.description=\
|
||||
Strip Java debug attributes from classes in the output image
|
||||
|
||||
strip-native-commands.description=\
|
||||
Exclude native commands (such as java/java.exe) from the image
|
||||
|
||||
|
@ -63,7 +63,8 @@ module jdk.jlink {
|
||||
jdk.tools.jlink.internal.Main.JlinkToolProvider;
|
||||
|
||||
provides jdk.tools.jlink.plugin.Plugin with
|
||||
jdk.tools.jlink.internal.plugins.StripDebugPlugin,
|
||||
jdk.tools.jlink.internal.plugins.DefaultStripDebugPlugin,
|
||||
jdk.tools.jlink.internal.plugins.StripJavaDebugAttributesPlugin,
|
||||
jdk.tools.jlink.internal.plugins.ExcludePlugin,
|
||||
jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin,
|
||||
jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin,
|
||||
|
@ -49,7 +49,7 @@ import jdk.tools.jlink.internal.Jlink.JlinkConfiguration;
|
||||
import jdk.tools.jlink.internal.Jlink.PluginsConfiguration;
|
||||
import jdk.tools.jlink.internal.PostProcessor;
|
||||
import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
|
||||
import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
|
||||
import jdk.tools.jlink.internal.plugins.DefaultStripDebugPlugin;
|
||||
|
||||
import tests.Helper;
|
||||
import tests.JImageGenerator;
|
||||
@ -168,7 +168,7 @@ public class IntegrationTest {
|
||||
//Strip debug
|
||||
{
|
||||
Map<String, String> config1 = new HashMap<>();
|
||||
config1.put(StripDebugPlugin.NAME, "");
|
||||
config1.put(DefaultStripDebugPlugin.NAME, "");
|
||||
Plugin strip = Jlink.newPlugin("strip-debug", config1, null);
|
||||
lst.add(strip);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test StripDebugPlugin
|
||||
* @summary Test StripJavaDebugAttributesPlugin
|
||||
* @author Jean-Francois Denise
|
||||
* @library ../../lib
|
||||
* @build tests.*
|
||||
@ -35,7 +35,7 @@
|
||||
* jdk.jlink/jdk.tools.jmod
|
||||
* jdk.jdeps/com.sun.tools.classfile
|
||||
* jdk.compiler
|
||||
* @run main StripDebugPluginTest
|
||||
* @run main StripJavaDebugAttributesPluginTest
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -44,6 +44,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
@ -53,18 +54,17 @@ import com.sun.tools.classfile.ClassFile;
|
||||
import com.sun.tools.classfile.Code_attribute;
|
||||
import com.sun.tools.classfile.ConstantPoolException;
|
||||
import com.sun.tools.classfile.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.tools.jlink.internal.ResourcePoolManager;
|
||||
import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
|
||||
import jdk.tools.jlink.plugin.ResourcePoolEntry;
|
||||
import jdk.tools.jlink.plugin.ResourcePool;
|
||||
import jdk.tools.jlink.internal.plugins.StripJavaDebugAttributesPlugin;
|
||||
import jdk.tools.jlink.plugin.Plugin;
|
||||
import jdk.tools.jlink.plugin.ResourcePool;
|
||||
import jdk.tools.jlink.plugin.ResourcePoolEntry;
|
||||
import tests.Helper;
|
||||
|
||||
public class StripDebugPluginTest {
|
||||
public class StripJavaDebugAttributesPluginTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new StripDebugPluginTest().test();
|
||||
new StripJavaDebugAttributesPluginTest().test();
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
@ -105,7 +105,7 @@ public class StripDebugPluginTest {
|
||||
|
||||
private void check(String path, byte[] content, String infoPath, byte[] moduleInfo) throws Exception {
|
||||
path = path.replace('\\', '/');
|
||||
StripDebugPlugin debug = new StripDebugPlugin();
|
||||
StripJavaDebugAttributesPlugin debug = new StripJavaDebugAttributesPlugin();
|
||||
debug.configure(new HashMap<>());
|
||||
ResourcePoolEntry result1 = stripDebug(debug, ResourcePoolEntry.create(path,content), path, infoPath, moduleInfo);
|
||||
|
Loading…
Reference in New Issue
Block a user