8164689: Retrofit jar, jlink, jmod as a ToolProvider
Reviewed-by: alanb, lancea
This commit is contained in:
parent
71c0fe8710
commit
44a7c1b644
@ -56,8 +56,8 @@ public interface ToolProvider {
|
|||||||
/**
|
/**
|
||||||
* Returns the name of this tool provider.
|
* Returns the name of this tool provider.
|
||||||
*
|
*
|
||||||
* @apiNote It is recommended that the name be the same as would be used on
|
* @apiNote It is recommended that the name be the same as would be
|
||||||
* the command line: for example, "javac", "jar", "jlink".
|
* used on the command line: for example, "javac", "jar", "jlink".
|
||||||
*
|
*
|
||||||
* @return the name of this tool provider
|
* @return the name of this tool provider
|
||||||
*/
|
*/
|
||||||
@ -67,12 +67,13 @@ public interface ToolProvider {
|
|||||||
* Runs an instance of the tool, returning zero for a successful run.
|
* Runs an instance of the tool, returning zero for a successful run.
|
||||||
* Any non-zero return value indicates a tool-specific error during the
|
* Any non-zero return value indicates a tool-specific error during the
|
||||||
* execution.
|
* execution.
|
||||||
|
*
|
||||||
* Two streams should be provided, for "expected" output, and for any
|
* Two streams should be provided, for "expected" output, and for any
|
||||||
* error messages. If it is not necessary to distinguish the output,
|
* error messages. If it is not necessary to distinguish the output,
|
||||||
* the same stream may be used for both.
|
* the same stream may be used for both.
|
||||||
*
|
*
|
||||||
* @apiNote The interpretation of the arguments will be specific to
|
* @apiNote The interpretation of the arguments will be specific to
|
||||||
* each tool.
|
* each tool.
|
||||||
*
|
*
|
||||||
* @param out a stream to which "expected" output should be written
|
* @param out a stream to which "expected" output should be written
|
||||||
*
|
*
|
||||||
@ -81,12 +82,13 @@ public interface ToolProvider {
|
|||||||
* @param args the command-line arguments for the tool
|
* @param args the command-line arguments for the tool
|
||||||
*
|
*
|
||||||
* @return the result of executing the tool.
|
* @return the result of executing the tool.
|
||||||
* A return value of 0 means the tool did not encounter any errors;
|
* A return value of 0 means the tool did not encounter any errors;
|
||||||
* any other value indicates that at least one error occurred during
|
* any other value indicates that at least one error occurred
|
||||||
* execution.
|
* during execution.
|
||||||
*
|
*
|
||||||
* @throws NullPointerException if any of the arguments are {@code null},
|
* @throws NullPointerException if any of the arguments are {@code null},
|
||||||
* or if there are any {@code null} values in the {@code args} array
|
* or if there are any {@code null} values in the {@code args}
|
||||||
|
* array
|
||||||
*/
|
*/
|
||||||
int run(PrintWriter out, PrintWriter err, String... args);
|
int run(PrintWriter out, PrintWriter err, String... args);
|
||||||
|
|
||||||
@ -94,16 +96,17 @@ public interface ToolProvider {
|
|||||||
* Runs an instance of the tool, returning zero for a successful run.
|
* Runs an instance of the tool, returning zero for a successful run.
|
||||||
* Any non-zero return value indicates a tool-specific error during the
|
* Any non-zero return value indicates a tool-specific error during the
|
||||||
* execution.
|
* execution.
|
||||||
|
*
|
||||||
* Two streams should be provided, for "expected" output, and for any
|
* Two streams should be provided, for "expected" output, and for any
|
||||||
* error messages. If it is not necessary to distinguish the output,
|
* error messages. If it is not necessary to distinguish the output,
|
||||||
* the same stream may be used for both.
|
* the same stream may be used for both.
|
||||||
*
|
*
|
||||||
* @apiNote The interpretation of the arguments will be specific to
|
* @apiNote The interpretation of the arguments will be specific to
|
||||||
* each tool.
|
* each tool.
|
||||||
*
|
*
|
||||||
* @implNote This implementation wraps the {@code out} and {@code err}
|
* @implNote This implementation wraps the {@code out} and {@code err}
|
||||||
* streams within {@link PrintWriter}s, and then calls
|
* streams within {@link PrintWriter}s, and then calls
|
||||||
* {@link run(PrintWriter, PrintWriter, String[])}.
|
* {@link #run(PrintWriter, PrintWriter, String[])}.
|
||||||
*
|
*
|
||||||
* @param out a stream to which "expected" output should be written
|
* @param out a stream to which "expected" output should be written
|
||||||
*
|
*
|
||||||
@ -112,12 +115,13 @@ public interface ToolProvider {
|
|||||||
* @param args the command-line arguments for the tool
|
* @param args the command-line arguments for the tool
|
||||||
*
|
*
|
||||||
* @return the result of executing the tool.
|
* @return the result of executing the tool.
|
||||||
* A return value of 0 means the tool did not encounter any errors;
|
* A return value of 0 means the tool did not encounter any errors;
|
||||||
* any other value indicates that at least one error occurred during
|
* any other value indicates that at least one error occurred
|
||||||
* execution.
|
* during execution.
|
||||||
*
|
*
|
||||||
* @throws NullPointerException if any of the arguments are {@code null},
|
* @throws NullPointerException if any of the arguments are {@code null},
|
||||||
* or if there are any {@code null} values in the {@code args} array
|
* or if there are any {@code null} values in the {@code args}
|
||||||
|
* array
|
||||||
*/
|
*/
|
||||||
default int run(PrintStream out, PrintStream err, String... args) {
|
default int run(PrintStream out, PrintStream err, String... args) {
|
||||||
Objects.requireNonNull(out);
|
Objects.requireNonNull(out);
|
||||||
|
@ -26,5 +26,7 @@
|
|||||||
module jdk.jartool {
|
module jdk.jartool {
|
||||||
exports com.sun.jarsigner;
|
exports com.sun.jarsigner;
|
||||||
exports jdk.security.jarsigner;
|
exports jdk.security.jarsigner;
|
||||||
|
|
||||||
|
provides java.util.spi.ToolProvider with sun.tools.jar.JarToolProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ package sun.tools.jar;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.lang.module.ModuleFinder;
|
import java.lang.module.ModuleFinder;
|
||||||
import java.lang.module.ModuleDescriptor.Version;
|
import java.lang.module.ModuleDescriptor.Version;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@ -289,7 +290,7 @@ class GNUStyleOptions {
|
|||||||
throw new BadArgs("error.unrecognized.option", name).showUsage(true);
|
throw new BadArgs("error.unrecognized.option", name).showUsage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printHelp(PrintStream out) {
|
static void printHelp(PrintWriter out) {
|
||||||
out.format("%s%n", Main.getMsg("main.help.preopt"));
|
out.format("%s%n", Main.getMsg("main.help.preopt"));
|
||||||
for (OptionType type : OptionType.values()) {
|
for (OptionType type : OptionType.values()) {
|
||||||
boolean typeHeadingWritten = false;
|
boolean typeHeadingWritten = false;
|
||||||
@ -312,16 +313,16 @@ class GNUStyleOptions {
|
|||||||
out.format("%n%s%n%n", Main.getMsg("main.help.postopt"));
|
out.format("%n%s%n%n", Main.getMsg("main.help.postopt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printCompatHelp(PrintStream out) {
|
static void printCompatHelp(PrintWriter out) {
|
||||||
out.format("%s%n", Main.getMsg("usage.compat"));
|
out.format("%s%n", Main.getMsg("usage.compat"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printUsageSummary(PrintStream out) {
|
static void printUsageSummary(PrintWriter out) {
|
||||||
out.format("%s%n", Main.getMsg("main.usage.summary"));
|
out.format("%s%n", Main.getMsg("main.usage.summary"));
|
||||||
out.format("%s%n", Main.getMsg("main.usage.summary.try"));
|
out.format("%s%n", Main.getMsg("main.usage.summary.try"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printVersion(PrintStream out) {
|
static void printVersion(PrintWriter out) {
|
||||||
out.format("%s %s%n", "jar", System.getProperty("java.version"));
|
out.format("%s %s%n", "jar", System.getProperty("java.version"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* 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 sun.tools.jar;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
|
public class JarToolProvider implements ToolProvider {
|
||||||
|
public String name() {
|
||||||
|
return "jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int run(PrintWriter out, PrintWriter err, String... args) {
|
||||||
|
boolean ok = new Main(out, err, name()).run(args);
|
||||||
|
return ok ? 0 : 1;
|
||||||
|
}
|
||||||
|
}
|
@ -76,7 +76,7 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
|||||||
public
|
public
|
||||||
class Main {
|
class Main {
|
||||||
String program;
|
String program;
|
||||||
PrintStream out, err;
|
PrintWriter out, err;
|
||||||
String fname, mname, ename;
|
String fname, mname, ename;
|
||||||
String zname = "";
|
String zname = "";
|
||||||
String rootjar = null;
|
String rootjar = null;
|
||||||
@ -189,9 +189,9 @@ class Main {
|
|||||||
USAGE_SUMMARY(GNUStyleOptions::printUsageSummary),
|
USAGE_SUMMARY(GNUStyleOptions::printUsageSummary),
|
||||||
VERSION(GNUStyleOptions::printVersion);
|
VERSION(GNUStyleOptions::printVersion);
|
||||||
|
|
||||||
private Consumer<PrintStream> printFunction;
|
private Consumer<PrintWriter> printFunction;
|
||||||
Info(Consumer<PrintStream> f) { this.printFunction = f; }
|
Info(Consumer<PrintWriter> f) { this.printFunction = f; }
|
||||||
void print(PrintStream out) { printFunction.accept(out); }
|
void print(PrintWriter out) { printFunction.accept(out); }
|
||||||
};
|
};
|
||||||
Info info;
|
Info info;
|
||||||
|
|
||||||
@ -252,6 +252,12 @@ class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Main(PrintStream out, PrintStream err, String program) {
|
public Main(PrintStream out, PrintStream err, String program) {
|
||||||
|
this.out = new PrintWriter(out, true);
|
||||||
|
this.err = new PrintWriter(err, true);
|
||||||
|
this.program = program;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Main(PrintWriter out, PrintWriter err, String program) {
|
||||||
this.out = out;
|
this.out = out;
|
||||||
this.err = err;
|
this.err = err;
|
||||||
this.program = program;
|
this.program = program;
|
||||||
|
@ -153,7 +153,7 @@ public class JlinkTask {
|
|||||||
= taskHelper.newOptionsHelper(JlinkTask.class, recognizedOptions);
|
= taskHelper.newOptionsHelper(JlinkTask.class, recognizedOptions);
|
||||||
private PrintWriter log;
|
private PrintWriter log;
|
||||||
|
|
||||||
void setLog(PrintWriter out) {
|
void setLog(PrintWriter out, PrintWriter err) {
|
||||||
log = out;
|
log = out;
|
||||||
taskHelper.setLog(log);
|
taskHelper.setLog(log);
|
||||||
}
|
}
|
||||||
@ -182,7 +182,8 @@ public class JlinkTask {
|
|||||||
|
|
||||||
int run(String[] args) {
|
int run(String[] args) {
|
||||||
if (log == null) {
|
if (log == null) {
|
||||||
setLog(new PrintWriter(System.out, true));
|
setLog(new PrintWriter(System.out, true),
|
||||||
|
new PrintWriter(System.err, true));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
optionsHelper.handleOptions(this, args);
|
optionsHelper.handleOptions(this, args);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package jdk.tools.jlink.internal;
|
package jdk.tools.jlink.internal;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
@ -34,17 +35,27 @@ public class Main {
|
|||||||
System.exit(rc);
|
System.exit(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point that does <i>not</i> call System.exit.
|
* Entry point that does <i>not</i> call System.exit.
|
||||||
*
|
*
|
||||||
* @param args command line arguments
|
|
||||||
* @param out output stream
|
* @param out output stream
|
||||||
|
* @param err error output stream
|
||||||
|
* @param args command line arguments
|
||||||
* @return an exit code. 0 means success, non-zero means an error occurred.
|
* @return an exit code. 0 means success, non-zero means an error occurred.
|
||||||
*/
|
*/
|
||||||
public static int run(String[] args, PrintWriter out) {
|
public static int run(PrintWriter out, PrintWriter err, String... args) {
|
||||||
JlinkTask t = new JlinkTask();
|
JlinkTask t = new JlinkTask();
|
||||||
t.setLog(out);
|
t.setLog(out, err);
|
||||||
return t.run(args);
|
return t.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class JlinkToolProvider implements ToolProvider {
|
||||||
|
public String name() {
|
||||||
|
return "jlink";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int run(PrintWriter out, PrintWriter err, String... args) {
|
||||||
|
return Main.run(out, err, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.lang.module.Configuration;
|
import java.lang.module.Configuration;
|
||||||
import java.lang.module.ModuleReader;
|
import java.lang.module.ModuleReader;
|
||||||
@ -136,8 +137,8 @@ public class JmodTask {
|
|||||||
private static final String MODULE_INFO = "module-info.class";
|
private static final String MODULE_INFO = "module-info.class";
|
||||||
|
|
||||||
private Options options;
|
private Options options;
|
||||||
private PrintStream out = System.out;
|
private PrintWriter out = new PrintWriter(System.out, true);
|
||||||
void setLog(PrintStream out) {
|
void setLog(PrintWriter out, PrintWriter err) {
|
||||||
this.out = out;
|
this.out = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package jdk.tools.jmod;
|
package jdk.tools.jmod;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
@ -37,13 +38,24 @@ public class Main {
|
|||||||
/**
|
/**
|
||||||
* Entry point that does <i>not</i> call System.exit.
|
* Entry point that does <i>not</i> call System.exit.
|
||||||
*
|
*
|
||||||
* @param args command line arguments
|
|
||||||
* @param out output stream
|
* @param out output stream
|
||||||
|
* @param err error output stream
|
||||||
|
* @param args command line arguments
|
||||||
* @return an exit code. 0 means success, non-zero means an error occurred.
|
* @return an exit code. 0 means success, non-zero means an error occurred.
|
||||||
*/
|
*/
|
||||||
public static int run(String[] args, PrintStream out) {
|
public static int run(PrintWriter out, PrintWriter err, String... args) {
|
||||||
JmodTask t = new JmodTask();
|
JmodTask t = new JmodTask();
|
||||||
t.setLog(out);
|
t.setLog(out, err);
|
||||||
return t.run(args);
|
return t.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class JmodToolProvider implements ToolProvider {
|
||||||
|
public String name() {
|
||||||
|
return "jmod";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int run(PrintWriter out, PrintWriter err, String... args) {
|
||||||
|
return Main.run(out, err, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ module jdk.jlink {
|
|||||||
|
|
||||||
uses jdk.tools.jlink.plugin.Plugin;
|
uses jdk.tools.jlink.plugin.Plugin;
|
||||||
|
|
||||||
|
provides java.util.spi.ToolProvider with jdk.tools.jmod.Main.JmodToolProvider;
|
||||||
|
provides java.util.spi.ToolProvider with jdk.tools.jlink.internal.Main.JlinkToolProvider;
|
||||||
|
|
||||||
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin;
|
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin;
|
||||||
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin;
|
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin;
|
||||||
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludePlugin;
|
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludePlugin;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
* @test
|
* @test
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @modules java.base/jdk.internal.module
|
* @modules java.base/jdk.internal.module
|
||||||
* jdk.jlink/jdk.tools.jmod
|
|
||||||
* jdk.compiler
|
* jdk.compiler
|
||||||
|
* jdk.jlink
|
||||||
* @build ModuleReaderTest CompilerUtils JarUtils
|
* @build ModuleReaderTest CompilerUtils JarUtils
|
||||||
* @run testng ModuleReaderTest
|
* @run testng ModuleReaderTest
|
||||||
* @summary Basic tests for java.lang.module.ModuleReader
|
* @summary Basic tests for java.lang.module.ModuleReader
|
||||||
@ -48,6 +48,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
import jdk.internal.module.ConfigurableModuleFinder;
|
import jdk.internal.module.ConfigurableModuleFinder;
|
||||||
import jdk.internal.module.ConfigurableModuleFinder.Phase;
|
import jdk.internal.module.ConfigurableModuleFinder.Phase;
|
||||||
@ -196,8 +197,11 @@ public class ModuleReaderTest {
|
|||||||
String cp = MODS_DIR.resolve(TEST_MODULE).toString();
|
String cp = MODS_DIR.resolve(TEST_MODULE).toString();
|
||||||
String jmod = dir.resolve("m.jmod").toString();
|
String jmod = dir.resolve("m.jmod").toString();
|
||||||
String[] args = { "create", "--class-path", cp, jmod };
|
String[] args = { "create", "--class-path", cp, jmod };
|
||||||
jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask();
|
ToolProvider jmodTool = ToolProvider.findFirst("jmod")
|
||||||
assertEquals(task.run(args), 0);
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jmod tool not found")
|
||||||
|
);
|
||||||
|
assertEquals(jmodTool.run(System.out, System.out, args), 0);
|
||||||
|
|
||||||
test(dir);
|
test(dir);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 4806786 8023113
|
* @bug 4806786 8023113
|
||||||
* @modules jdk.jartool/sun.tools.jar
|
* @modules jdk.jartool
|
||||||
* @summary jar -C doesn't ignore multiple // in path
|
* @summary jar -C doesn't ignore multiple // in path
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -32,10 +32,15 @@ import java.io.*;
|
|||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.jar.*;
|
import java.util.jar.*;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import sun.tools.jar.Main;
|
|
||||||
|
|
||||||
public class ChangeDir {
|
public class ChangeDir {
|
||||||
|
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
private final static String jarName = "test.jar";
|
private final static String jarName = "test.jar";
|
||||||
private final static String fileName = "hello.txt";
|
private final static String fileName = "hello.txt";
|
||||||
|
|
||||||
@ -88,8 +93,9 @@ public class ChangeDir {
|
|||||||
argList.add(topDir.toString() + sep + "a" + sep + sep + "b"); // Note double 'sep' is intentional
|
argList.add(topDir.toString() + sep + "a" + sep + sep + "b"); // Note double 'sep' is intentional
|
||||||
argList.add(fileName);
|
argList.add(fileName);
|
||||||
|
|
||||||
Main jarTool = new Main(System.out, System.err, "jar");
|
int rc = JAR_TOOL.run(System.out, System.err,
|
||||||
if (!jarTool.run(argList.toArray(new String[argList.size()]))) {
|
argList.toArray(new String[argList.size()]));
|
||||||
|
if (rc != 0) {
|
||||||
fail("Could not create jar file.");
|
fail("Could not create jar file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* duplicates that sometimes cause exceptions and other times do not,
|
* duplicates that sometimes cause exceptions and other times do not,
|
||||||
* demonstrating identical behavior to JDK 8 jar tool.
|
* demonstrating identical behavior to JDK 8 jar tool.
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @modules jdk.jartool/sun.tools.jar
|
* @modules jdk.jartool
|
||||||
* @build jdk.testlibrary.FileUtils
|
* @build jdk.testlibrary.FileUtils
|
||||||
* @run testng InputFilesTest
|
* @run testng InputFilesTest
|
||||||
*/
|
*/
|
||||||
@ -47,12 +47,18 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.zip.ZipException;
|
import java.util.zip.ZipException;
|
||||||
|
|
||||||
import jdk.testlibrary.FileUtils;
|
import jdk.testlibrary.FileUtils;
|
||||||
|
|
||||||
public class InputFilesTest {
|
public class InputFilesTest {
|
||||||
|
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
private final String nl = System.lineSeparator();
|
private final String nl = System.lineSeparator();
|
||||||
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
private final PrintStream out = new PrintStream(baos);
|
private final PrintStream out = new PrintStream(baos);
|
||||||
@ -195,9 +201,9 @@ public class InputFilesTest {
|
|||||||
PrintStream err = new PrintStream(baes);
|
PrintStream err = new PrintStream(baes);
|
||||||
PrintStream saveErr = System.err;
|
PrintStream saveErr = System.err;
|
||||||
System.setErr(err);
|
System.setErr(err);
|
||||||
boolean ok = new sun.tools.jar.Main(out, err, "jar").run(cmdline.split(" +"));
|
int rc = JAR_TOOL.run(out, err, cmdline.split(" +"));
|
||||||
System.setErr(saveErr);
|
System.setErr(saveErr);
|
||||||
if (!ok) {
|
if (rc != 0) {
|
||||||
String s = baes.toString();
|
String s = baes.toString();
|
||||||
if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) {
|
if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) {
|
||||||
throw new ZipException(s);
|
throw new ZipException(s);
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 7201156
|
* @bug 7201156
|
||||||
* @modules jdk.jartool/sun.tools.jar
|
* @modules jdk.jartool
|
||||||
* @summary jar tool fails to convert file separation characters for list and extract
|
* @summary jar tool fails to convert file separation characters for list and extract
|
||||||
* @author Sean Chou
|
* @author Sean Chou
|
||||||
*/
|
*/
|
||||||
@ -43,10 +43,13 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
import sun.tools.jar.Main;
|
|
||||||
|
|
||||||
public class JarBackSlash {
|
public class JarBackSlash {
|
||||||
|
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
// used construct an entry JarBackSlash/dir/file.txt
|
// used construct an entry JarBackSlash/dir/file.txt
|
||||||
private static String JARBACKSLASH = "JarBackSlash";
|
private static String JARBACKSLASH = "JarBackSlash";
|
||||||
@ -78,8 +81,8 @@ public class JarBackSlash {
|
|||||||
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
|
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
|
||||||
PrintStream out = new PrintStream(pipedOutput);
|
PrintStream out = new PrintStream(pipedOutput);
|
||||||
|
|
||||||
Main jarTool = new Main(out, System.err, "jar");
|
int rc = JAR_TOOL.run(out, System.err, jarArgs);
|
||||||
if (!jarTool.run(jarArgs)) {
|
if (rc != 0) {
|
||||||
fail("Could not list jar file.");
|
fail("Could not list jar file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +104,8 @@ public class JarBackSlash {
|
|||||||
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
|
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
|
||||||
PrintStream out = new PrintStream(pipedOutput);
|
PrintStream out = new PrintStream(pipedOutput);
|
||||||
|
|
||||||
Main jarTool = new Main(out, System.err, "jar");
|
int rc = JAR_TOOL.run(out, System.err, jarArgs);
|
||||||
if (!jarTool.run(jarArgs)) {
|
if (rc != 0) {
|
||||||
fail("Could not list jar file.");
|
fail("Could not list jar file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 4225317 6969651
|
* @bug 4225317 6969651
|
||||||
* @modules jdk.jartool/sun.tools.jar
|
* @modules jdk.jartool
|
||||||
* @summary Check extracted files have date as per those in the .jar file
|
* @summary Check extracted files have date as per those in the .jar file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -33,9 +33,14 @@ import java.io.PrintWriter;
|
|||||||
import java.nio.file.attribute.FileTime;
|
import java.nio.file.attribute.FileTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import sun.tools.jar.Main;
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
public class JarEntryTime {
|
public class JarEntryTime {
|
||||||
|
static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// ZipEntry's mod date has 2 seconds precision: give extra time to
|
// ZipEntry's mod date has 2 seconds precision: give extra time to
|
||||||
// allow for e.g. rounding/truncation and networked/samba drives.
|
// allow for e.g. rounding/truncation and networked/samba drives.
|
||||||
@ -114,10 +119,8 @@ public class JarEntryTime {
|
|||||||
check(fileInner.setLastModified(earlier));
|
check(fileInner.setLastModified(earlier));
|
||||||
|
|
||||||
// Make a jar file from that directory structure
|
// Make a jar file from that directory structure
|
||||||
Main jartool = new Main(System.out, System.err, "jar");
|
check(JAR_TOOL.run(System.out, System.err,
|
||||||
check(jartool.run(new String[] {
|
"cf", jarFile.getName(), dirOuter.getName()) == 0);
|
||||||
"cf",
|
|
||||||
jarFile.getName(), dirOuter.getName() } ));
|
|
||||||
check(jarFile.exists());
|
check(jarFile.exists());
|
||||||
|
|
||||||
check(cleanup(dirInner));
|
check(cleanup(dirInner));
|
||||||
@ -142,7 +145,6 @@ public class JarEntryTime {
|
|||||||
final long start = testFile.lastModified();
|
final long start = testFile.lastModified();
|
||||||
|
|
||||||
// Extract and check the last modified values are the current times.
|
// Extract and check the last modified values are the current times.
|
||||||
// See sun.tools.jar.Main
|
|
||||||
extractJar(jarFile, true);
|
extractJar(jarFile, true);
|
||||||
|
|
||||||
try (PrintWriter pw = new PrintWriter(testFile)) {
|
try (PrintWriter pw = new PrintWriter(testFile)) {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 7175845
|
* @bug 7175845
|
||||||
* @modules jdk.jartool/sun.tools.jar
|
* @modules jdk.jartool
|
||||||
* @summary jar -uf should not change file permission
|
* @summary jar -uf should not change file permission
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -32,9 +32,13 @@ import java.io.*;
|
|||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.nio.file.attribute.*;
|
import java.nio.file.attribute.*;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import sun.tools.jar.Main;
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
public class UpdateJar {
|
public class UpdateJar {
|
||||||
|
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
private static void cleanup(String... fnames) throws Throwable {
|
private static void cleanup(String... fnames) throws Throwable {
|
||||||
for (String fname : fnames) {
|
for (String fname : fnames) {
|
||||||
@ -55,12 +59,12 @@ public class UpdateJar {
|
|||||||
fos1.write(0);
|
fos1.write(0);
|
||||||
}
|
}
|
||||||
String[] jarArgs = new String[] {"cfM0", jar, e0};
|
String[] jarArgs = new String[] {"cfM0", jar, e0};
|
||||||
if (!new Main(System.out, System.err, "jar").run(jarArgs)) {
|
if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) {
|
||||||
fail("Could not create jar file.");
|
fail("Could not create jar file.");
|
||||||
}
|
}
|
||||||
Set<PosixFilePermission> pm = Files.getPosixFilePermissions(Paths.get(jar));
|
Set<PosixFilePermission> pm = Files.getPosixFilePermissions(Paths.get(jar));
|
||||||
jarArgs = new String[] {"uf", jar, e1};
|
jarArgs = new String[] {"uf", jar, e1};
|
||||||
if (!new Main(System.out, System.err, "jar").run(jarArgs)) {
|
if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) {
|
||||||
fail("Could not create jar file.");
|
fail("Could not create jar file.");
|
||||||
}
|
}
|
||||||
equal(pm, Files.getPosixFilePermissions(Paths.get(jar)));
|
equal(pm, Files.getPosixFilePermissions(Paths.get(jar)));
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 6434207 6442687 6984046
|
* @bug 6434207 6442687 6984046
|
||||||
* @modules jdk.jartool/sun.tools.jar
|
* @modules jdk.jartool
|
||||||
* @summary Ensure that jar ufm actually updates the
|
* @summary Ensure that jar ufm actually updates the
|
||||||
* existing jar file's manifest with contents of the
|
* existing jar file's manifest with contents of the
|
||||||
* manifest file.
|
* manifest file.
|
||||||
@ -32,14 +32,19 @@
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.zip.*;
|
import java.util.zip.*;
|
||||||
import sun.tools.jar.Main;
|
|
||||||
|
|
||||||
public class UpdateManifest {
|
public class UpdateManifest {
|
||||||
static PrintStream out = System.out;
|
static PrintStream out = System.out;
|
||||||
static PrintStream err = System.err;
|
static PrintStream err = System.err;
|
||||||
static boolean debug = true;
|
static boolean debug = true;
|
||||||
|
|
||||||
|
static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
static final Logger JAR_LOGGER = Logger.getLogger("java.util.jar");
|
static final Logger JAR_LOGGER = Logger.getLogger("java.util.jar");
|
||||||
|
|
||||||
public static void realMain(String[] args) throws Throwable {
|
public static void realMain(String[] args) throws Throwable {
|
||||||
@ -64,17 +69,14 @@ public class UpdateManifest {
|
|||||||
// Create a jar file, specifying a Main-Class
|
// Create a jar file, specifying a Main-Class
|
||||||
final String jarFileName = "um-existence.jar";
|
final String jarFileName = "um-existence.jar";
|
||||||
new File(jarFileName).delete(); // remove pre-existing first!
|
new File(jarFileName).delete(); // remove pre-existing first!
|
||||||
Main jartool = new Main(out, err, "jar");
|
int status = JAR_TOOL.run(out, err, "cfe", jarFileName,
|
||||||
boolean status = jartool.run(
|
"Hello", existence.getPath());
|
||||||
new String[] { "cfe", jarFileName, "Hello", existence.getPath() });
|
check(status == 0);
|
||||||
check(status);
|
|
||||||
checkManifest(jarFileName, "Hello");
|
checkManifest(jarFileName, "Hello");
|
||||||
|
|
||||||
// Update that jar file by changing the Main-Class
|
// Update that jar file by changing the Main-Class
|
||||||
jartool = new Main(out, err, "jar");
|
status = JAR_TOOL.run(out, err, "ufe", jarFileName, "Bye");
|
||||||
status = jartool.run(
|
check(status == 0);
|
||||||
new String[] { "ufe", jarFileName, "Bye" });
|
|
||||||
check(status);
|
|
||||||
checkManifest(jarFileName, "Bye");
|
checkManifest(jarFileName, "Bye");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,11 +103,9 @@ public class UpdateManifest {
|
|||||||
// Create a jar file
|
// Create a jar file
|
||||||
final String jarFileName = "um-test.jar";
|
final String jarFileName = "um-test.jar";
|
||||||
new File(jarFileName).delete(); // remove pre-existing first!
|
new File(jarFileName).delete(); // remove pre-existing first!
|
||||||
Main jartool = new Main(out, err, "jar");
|
int status = JAR_TOOL.run(out, err, "cfm", jarFileName,
|
||||||
boolean status = jartool.run(
|
manifestOrig.getPath(), hello.getPath());
|
||||||
new String[] {"cfm", jarFileName,
|
check(status == 0);
|
||||||
manifestOrig.getPath(), hello.getPath() });
|
|
||||||
check(status);
|
|
||||||
|
|
||||||
// Create a new manifest, to use in updating the jar file.
|
// Create a new manifest, to use in updating the jar file.
|
||||||
File manifestUpdate = File.createTempFile("manifestUpdate", ".txt");
|
File manifestUpdate = File.createTempFile("manifestUpdate", ".txt");
|
||||||
@ -122,10 +122,9 @@ public class UpdateManifest {
|
|||||||
pw.close();
|
pw.close();
|
||||||
|
|
||||||
// Update jar file with manifest
|
// Update jar file with manifest
|
||||||
jartool = new Main(out, err, "jar");
|
status = JAR_TOOL.run(out, err, "ufm",
|
||||||
status = jartool.run(
|
jarFileName, manifestUpdate.getPath());
|
||||||
new String[] { "ufm", jarFileName, manifestUpdate.getPath() });
|
check(status == 0);
|
||||||
check(status);
|
|
||||||
|
|
||||||
// Extract jar, and verify contents of manifest file
|
// Extract jar, and verify contents of manifest file
|
||||||
File f = new File(jarFileName);
|
File f = new File(jarFileName);
|
||||||
|
@ -24,17 +24,21 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4408526 6854795
|
* @bug 4408526 6854795
|
||||||
* @modules jdk.jartool/sun.tools.jar
|
* @modules jdk.jartool
|
||||||
* @summary Index the non-meta files in META-INF, such as META-INF/services.
|
* @summary Index the non-meta files in META-INF, such as META-INF/services.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.jar.*;
|
import java.util.jar.*;
|
||||||
import sun.tools.jar.Main;
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
public class MetaInf {
|
public class MetaInf {
|
||||||
|
static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
static String jarName = "a.jar";
|
static String jarName = "a.jar";
|
||||||
static String INDEX = "META-INF/INDEX.LIST";
|
static String INDEX = "META-INF/INDEX.LIST";
|
||||||
@ -43,7 +47,7 @@ public class MetaInf {
|
|||||||
System.getProperty("test.src") + File.separatorChar + "jarcontents";
|
System.getProperty("test.src") + File.separatorChar + "jarcontents";
|
||||||
|
|
||||||
static void run(String ... args) {
|
static void run(String ... args) {
|
||||||
if (! new Main(System.out, System.err, "jar").run(args))
|
if (JAR_TOOL.run(System.out, System.err, args) != 0)
|
||||||
throw new Error("jar failed: args=" + Arrays.toString(args));
|
throw new Error("jar failed: args=" + Arrays.toString(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ import java.nio.file.Paths;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import jdk.tools.jlink.plugin.Plugin;
|
import jdk.tools.jlink.plugin.Plugin;
|
||||||
import jdk.tools.jlink.internal.PluginRepository;
|
import jdk.tools.jlink.internal.PluginRepository;
|
||||||
import tests.Helper;
|
import tests.Helper;
|
||||||
import tests.JImageGenerator;
|
import tests.JImageGenerator;
|
||||||
import tests.JImageGenerator.InMemoryFile;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
@ -48,13 +48,17 @@ import tests.JImageGenerator.InMemoryFile;
|
|||||||
* @modules java.base/jdk.internal.jimage
|
* @modules java.base/jdk.internal.jimage
|
||||||
* jdk.jdeps/com.sun.tools.classfile
|
* jdk.jdeps/com.sun.tools.classfile
|
||||||
* jdk.jlink/jdk.tools.jlink.internal
|
* jdk.jlink/jdk.tools.jlink.internal
|
||||||
* jdk.jlink/jdk.tools.jmod
|
|
||||||
* jdk.jlink/jdk.tools.jimage
|
* jdk.jlink/jdk.tools.jimage
|
||||||
* jdk.compiler
|
* jdk.compiler
|
||||||
* @build tests.*
|
* @build tests.*
|
||||||
* @run main/othervm -Xmx1g JLinkTest
|
* @run main/othervm -Xmx1g JLinkTest
|
||||||
*/
|
*/
|
||||||
public class JLinkTest {
|
public class JLinkTest {
|
||||||
|
static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jlink tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
// number of built-in plugins from jdk.jlink module
|
// number of built-in plugins from jdk.jlink module
|
||||||
private static int getNumJlinkPlugins() {
|
private static int getNumJlinkPlugins() {
|
||||||
ModuleDescriptor desc = Plugin.class.getModule().getDescriptor();
|
ModuleDescriptor desc = Plugin.class.getModule().getDescriptor();
|
||||||
@ -180,7 +184,8 @@ public class JLinkTest {
|
|||||||
{
|
{
|
||||||
// Help
|
// Help
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
jdk.tools.jlink.internal.Main.run(new String[]{"--help"}, new PrintWriter(writer));
|
PrintWriter pw = new PrintWriter(writer);
|
||||||
|
JLINK_TOOL.run(pw, pw, "--help");
|
||||||
String output = writer.toString();
|
String output = writer.toString();
|
||||||
if (output.split("\n").length < 10) {
|
if (output.split("\n").length < 10) {
|
||||||
System.err.println(output);
|
System.err.println(output);
|
||||||
@ -202,7 +207,9 @@ public class JLinkTest {
|
|||||||
{
|
{
|
||||||
// List plugins
|
// List plugins
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
jdk.tools.jlink.internal.Main.run(new String[]{"--list-plugins"}, new PrintWriter(writer));
|
PrintWriter pw = new PrintWriter(writer);
|
||||||
|
|
||||||
|
JLINK_TOOL.run(pw, pw, "--list-plugins");
|
||||||
String output = writer.toString();
|
String output = writer.toString();
|
||||||
long number = Stream.of(output.split("\\R"))
|
long number = Stream.of(output.split("\\R"))
|
||||||
.filter((s) -> s.matches("Plugin Name:.*"))
|
.filter((s) -> s.matches("Plugin Name:.*"))
|
||||||
|
@ -27,8 +27,7 @@
|
|||||||
* @author Andrei Eremeev
|
* @author Andrei Eremeev
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @modules java.base/jdk.internal.module
|
* @modules java.base/jdk.internal.module
|
||||||
* jdk.jlink/jdk.tools.jlink.internal
|
* jdk.jlink
|
||||||
* jdk.jlink/jdk.tools.jmod
|
|
||||||
* jdk.compiler
|
* jdk.compiler
|
||||||
* @build jdk.testlibrary.ProcessTools
|
* @build jdk.testlibrary.ProcessTools
|
||||||
* jdk.testlibrary.OutputAnalyzer
|
* jdk.testlibrary.OutputAnalyzer
|
||||||
@ -44,11 +43,21 @@ import java.nio.file.Paths;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
import jdk.testlibrary.OutputAnalyzer;
|
import jdk.testlibrary.OutputAnalyzer;
|
||||||
import jdk.testlibrary.ProcessTools;
|
import jdk.testlibrary.ProcessTools;
|
||||||
|
|
||||||
public class BasicTest {
|
public class BasicTest {
|
||||||
|
static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jmod tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
|
static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jlink tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
private final Path jdkHome = Paths.get(System.getProperty("test.jdk"));
|
private final Path jdkHome = Paths.get(System.getProperty("test.jdk"));
|
||||||
private final Path jdkMods = jdkHome.resolve("jmods");
|
private final Path jdkMods = jdkHome.resolve("jmods");
|
||||||
@ -110,20 +119,22 @@ public class BasicTest {
|
|||||||
"--add-modules", modName,
|
"--add-modules", modName,
|
||||||
"--output", image.toString());
|
"--output", image.toString());
|
||||||
Collections.addAll(args, options);
|
Collections.addAll(args, options);
|
||||||
int rc = jdk.tools.jlink.internal.Main.run(args.toArray(new String[args.size()]), new PrintWriter(System.out));
|
|
||||||
|
PrintWriter pw = new PrintWriter(System.out);
|
||||||
|
int rc = JLINK_TOOL.run(pw, pw, args.toArray(new String[args.size()]));
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
throw new AssertionError("Jlink failed: rc = " + rc);
|
throw new AssertionError("Jlink failed: rc = " + rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runJmod(String cp, String modName) {
|
private void runJmod(String cp, String modName) {
|
||||||
int rc = jdk.tools.jmod.Main.run(new String[] {
|
int rc = JMOD_TOOL.run(System.out, System.out, new String[] {
|
||||||
"create",
|
"create",
|
||||||
"--class-path", cp,
|
"--class-path", cp,
|
||||||
"--module-version", "1.0",
|
"--module-version", "1.0",
|
||||||
"--main-class", "jdk.test.Test",
|
"--main-class", "jdk.test.Test",
|
||||||
jmods.resolve(modName + ".jmod").toString(),
|
jmods.resolve(modName + ".jmod").toString(),
|
||||||
}, System.out);
|
});
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
throw new AssertionError("Jmod failed: rc = " + rc);
|
throw new AssertionError("Jmod failed: rc = " + rc);
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @modules jdk.jlink/jdk.tools.jmod
|
* @modules jdk.compiler
|
||||||
* jdk.compiler
|
* jdk.jlink
|
||||||
* @build jdk.testlibrary.FileUtils CompilerUtils
|
* @build jdk.testlibrary.FileUtils CompilerUtils
|
||||||
* @run testng JmodNegativeTest
|
* @run testng JmodNegativeTest
|
||||||
* @summary Negative tests for jmod
|
* @summary Negative tests for jmod
|
||||||
@ -39,6 +39,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
import jdk.testlibrary.FileUtils;
|
import jdk.testlibrary.FileUtils;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
@ -51,6 +52,11 @@ import static org.testng.Assert.assertTrue;
|
|||||||
|
|
||||||
public class JmodNegativeTest {
|
public class JmodNegativeTest {
|
||||||
|
|
||||||
|
static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jmod tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
static final String TEST_SRC = System.getProperty("test.src", ".");
|
static final String TEST_SRC = System.getProperty("test.src", ".");
|
||||||
static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
|
static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
|
||||||
static final Path EXPLODED_DIR = Paths.get("build");
|
static final Path EXPLODED_DIR = Paths.get("build");
|
||||||
@ -515,7 +521,7 @@ public class JmodNegativeTest {
|
|||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
PrintStream ps = new PrintStream(baos);
|
PrintStream ps = new PrintStream(baos);
|
||||||
System.out.println("jmod " + Arrays.asList(args));
|
System.out.println("jmod " + Arrays.asList(args));
|
||||||
int ec = jdk.tools.jmod.Main.run(args, ps);
|
int ec = JMOD_TOOL.run(ps, ps, args);
|
||||||
return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
|
return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @modules jdk.jlink/jdk.tools.jmod
|
* @modules jdk.compiler
|
||||||
* jdk.compiler
|
* jdk.jlink
|
||||||
* @build jdk.testlibrary.FileUtils CompilerUtils
|
* @build jdk.testlibrary.FileUtils CompilerUtils
|
||||||
* @run testng JmodTest
|
* @run testng JmodTest
|
||||||
* @summary Basic test for jmod
|
* @summary Basic test for jmod
|
||||||
@ -38,6 +38,7 @@ import java.nio.file.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.testlibrary.FileUtils;
|
import jdk.testlibrary.FileUtils;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
@ -51,6 +52,11 @@ import static org.testng.Assert.*;
|
|||||||
|
|
||||||
public class JmodTest {
|
public class JmodTest {
|
||||||
|
|
||||||
|
static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jmod tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
static final String TEST_SRC = System.getProperty("test.src", ".");
|
static final String TEST_SRC = System.getProperty("test.src", ".");
|
||||||
static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
|
static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
|
||||||
static final Path EXPLODED_DIR = Paths.get("build");
|
static final Path EXPLODED_DIR = Paths.get("build");
|
||||||
@ -479,7 +485,7 @@ public class JmodTest {
|
|||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
PrintStream ps = new PrintStream(baos);
|
PrintStream ps = new PrintStream(baos);
|
||||||
System.out.println("jmod " + Arrays.asList(args));
|
System.out.println("jmod " + Arrays.asList(args));
|
||||||
int ec = jdk.tools.jmod.Main.run(args, ps);
|
int ec = JMOD_TOOL.run(ps, ps, args);
|
||||||
return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
|
return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@
|
|||||||
* @author Andrei Eremeev
|
* @author Andrei Eremeev
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @modules java.base/jdk.internal.module
|
* @modules java.base/jdk.internal.module
|
||||||
* jdk.jlink/jdk.tools.jlink.internal
|
* jdk.jlink
|
||||||
* jdk.jlink/jdk.tools.jmod
|
|
||||||
* jdk.compiler
|
* jdk.compiler
|
||||||
* @build CompilerUtils
|
* @build CompilerUtils
|
||||||
* @run testng HashesTest
|
* @run testng HashesTest
|
||||||
@ -53,6 +52,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import jdk.internal.module.ConfigurableModuleFinder;
|
import jdk.internal.module.ConfigurableModuleFinder;
|
||||||
@ -63,6 +63,10 @@ import org.testng.annotations.Test;
|
|||||||
import static org.testng.Assert.*;
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
public class HashesTest {
|
public class HashesTest {
|
||||||
|
static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jmod tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
private final Path testSrc = Paths.get(System.getProperty("test.src"));
|
private final Path testSrc = Paths.get(System.getProperty("test.src"));
|
||||||
private final Path modSrc = testSrc.resolve("src");
|
private final Path modSrc = testSrc.resolve("src");
|
||||||
@ -204,7 +208,7 @@ public class HashesTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void runJmod(List<String> args) {
|
private void runJmod(List<String> args) {
|
||||||
int rc = jdk.tools.jmod.Main.run(args.toArray(new String[args.size()]), System.out);
|
int rc = JMOD_TOOL.run(System.out, System.out, args.toArray(new String[args.size()]));
|
||||||
System.out.println("jmod options: " + args.stream().collect(Collectors.joining(" ")));
|
System.out.println("jmod options: " + args.stream().collect(Collectors.joining(" ")));
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
throw new AssertionError("Jmod failed: rc = " + rc);
|
throw new AssertionError("Jmod failed: rc = " + rc);
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @modules jdk.jartool/sun.tools.jar
|
* @modules jdk.compiler
|
||||||
* jdk.jlink/jdk.tools.jmod
|
* jdk.jartool
|
||||||
* jdk.compiler
|
* jdk.jlink
|
||||||
* @build BasicTest CompilerUtils jdk.testlibrary.*
|
* @build BasicTest CompilerUtils jdk.testlibrary.*
|
||||||
* @run testng BasicTest
|
* @run testng BasicTest
|
||||||
* @summary Basic test of starting an application as a module
|
* @summary Basic test of starting an application as a module
|
||||||
@ -36,6 +36,7 @@ import java.io.File;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
import jdk.testlibrary.ProcessTools;
|
import jdk.testlibrary.ProcessTools;
|
||||||
|
|
||||||
@ -46,6 +47,14 @@ import static org.testng.Assert.*;
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public class BasicTest {
|
public class BasicTest {
|
||||||
|
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
private static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jmod tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
|
private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
|
||||||
|
|
||||||
@ -132,10 +141,8 @@ public class BasicTest {
|
|||||||
"--main-class=" + MAIN_CLASS,
|
"--main-class=" + MAIN_CLASS,
|
||||||
"-C", classes, "."
|
"-C", classes, "."
|
||||||
};
|
};
|
||||||
boolean success
|
int rc = JAR_TOOL.run(System.out, System.out, args);
|
||||||
= new sun.tools.jar.Main(System.out, System.out, "jar")
|
assertTrue(rc == 0);
|
||||||
.run(args);
|
|
||||||
assertTrue(success);
|
|
||||||
|
|
||||||
// java --module-path mlib -module $TESTMODULE
|
// java --module-path mlib -module $TESTMODULE
|
||||||
int exitValue = exec("--module-path", dir.toString(),
|
int exitValue = exec("--module-path", dir.toString(),
|
||||||
@ -164,8 +171,8 @@ public class BasicTest {
|
|||||||
"--main-class", MAIN_CLASS,
|
"--main-class", MAIN_CLASS,
|
||||||
jmod
|
jmod
|
||||||
};
|
};
|
||||||
jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask();
|
|
||||||
assertEquals(task.run(args), 0);
|
assertEquals(JMOD_TOOL.run(System.out, System.out, args), 0);
|
||||||
|
|
||||||
// java --module-path mods --module $TESTMODULE
|
// java --module-path mods --module $TESTMODULE
|
||||||
int exitValue = exec("--module-path", dir.toString(),
|
int exitValue = exec("--module-path", dir.toString(),
|
||||||
@ -229,10 +236,8 @@ public class BasicTest {
|
|||||||
"--file=" + jar,
|
"--file=" + jar,
|
||||||
"-C", classes, "."
|
"-C", classes, "."
|
||||||
};
|
};
|
||||||
boolean success
|
int rc = JAR_TOOL.run(System.out, System.out, args);
|
||||||
= new sun.tools.jar.Main(System.out, System.out, "jar")
|
assertTrue(rc == 0);
|
||||||
.run(args);
|
|
||||||
assertTrue(success);
|
|
||||||
|
|
||||||
// java --module-path mods -m $TESTMODULE
|
// java --module-path mods -m $TESTMODULE
|
||||||
int exitValue = exec("--module-path", dir.toString(), "-m", TEST_MODULE);
|
int exitValue = exec("--module-path", dir.toString(), "-m", TEST_MODULE);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* @bug 8159596
|
* @bug 8159596
|
||||||
* @library /lib/testlibrary
|
* @library /lib/testlibrary
|
||||||
* @modules jdk.compiler
|
* @modules jdk.compiler
|
||||||
* jdk.jartool/sun.tools.jar
|
* jdk.jartool
|
||||||
* @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools
|
* @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools
|
||||||
* @run testng DryRunTest
|
* @run testng DryRunTest
|
||||||
* @summary Test java --dry-run
|
* @summary Test java --dry-run
|
||||||
@ -37,6 +37,7 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.spi.ToolProvider;
|
||||||
|
|
||||||
import jdk.testlibrary.ProcessTools;
|
import jdk.testlibrary.ProcessTools;
|
||||||
|
|
||||||
@ -78,8 +79,8 @@ public class DryRunTest {
|
|||||||
Files.createDirectories(LIBS_DIR);
|
Files.createDirectories(LIBS_DIR);
|
||||||
|
|
||||||
// create JAR files with no module-info.class
|
// create JAR files with no module-info.class
|
||||||
assertTrue(jar(M_MODULE, "p/Lib.class"));
|
assertTrue(jar(M_MODULE, "p/Lib.class") == 0);
|
||||||
assertTrue(jar(TEST_MODULE, "jdk/test/Main.class"));
|
assertTrue(jar(TEST_MODULE, "jdk/test/Main.class") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,7 +198,12 @@ public class DryRunTest {
|
|||||||
assertTrue(exitValue != 0);
|
assertTrue(exitValue != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean jar(String name, String entries) throws IOException {
|
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||||
|
.orElseThrow(() ->
|
||||||
|
new RuntimeException("jar tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
|
private static int jar(String name, String entries) throws IOException {
|
||||||
Path jar = LIBS_DIR.resolve(name + ".jar");
|
Path jar = LIBS_DIR.resolve(name + ".jar");
|
||||||
|
|
||||||
// jar --create ...
|
// jar --create ...
|
||||||
@ -207,8 +213,6 @@ public class DryRunTest {
|
|||||||
"--file=" + jar,
|
"--file=" + jar,
|
||||||
"-C", classes, entries
|
"-C", classes, entries
|
||||||
};
|
};
|
||||||
boolean success
|
return JAR_TOOL.run(System.out, System.out, args);
|
||||||
= new sun.tools.jar.Main(System.out, System.out, "jar").run(args);
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,6 +338,10 @@ public class JImageGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class JModTask {
|
public static class JModTask {
|
||||||
|
static final java.util.spi.ToolProvider JMOD_TOOL =
|
||||||
|
java.util.spi.ToolProvider.findFirst("jmod").orElseThrow(() ->
|
||||||
|
new RuntimeException("jmod tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
private final List<Path> classpath = new ArrayList<>();
|
private final List<Path> classpath = new ArrayList<>();
|
||||||
private final List<Path> libs = new ArrayList<>();
|
private final List<Path> libs = new ArrayList<>();
|
||||||
@ -477,7 +481,8 @@ public class JImageGenerator {
|
|||||||
String[] args = optionsJMod(cmd);
|
String[] args = optionsJMod(cmd);
|
||||||
System.err.println("jmod options: " + optionsPrettyPrint(args));
|
System.err.println("jmod options: " + optionsPrettyPrint(args));
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
int exitCode = jdk.tools.jmod.Main.run(args, new PrintStream(baos));
|
PrintStream ps = new PrintStream(baos);
|
||||||
|
int exitCode = JMOD_TOOL.run(ps, ps, args);
|
||||||
String msg = new String(baos.toByteArray());
|
String msg = new String(baos.toByteArray());
|
||||||
return new Result(exitCode, msg, output);
|
return new Result(exitCode, msg, output);
|
||||||
}
|
}
|
||||||
@ -556,6 +561,10 @@ public class JImageGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class JLinkTask {
|
public static class JLinkTask {
|
||||||
|
static final java.util.spi.ToolProvider JLINK_TOOL =
|
||||||
|
java.util.spi.ToolProvider.findFirst("jlink").orElseThrow(() ->
|
||||||
|
new RuntimeException("jlink tool not found")
|
||||||
|
);
|
||||||
|
|
||||||
private final List<Path> jars = new ArrayList<>();
|
private final List<Path> jars = new ArrayList<>();
|
||||||
private final List<Path> jmods = new ArrayList<>();
|
private final List<Path> jmods = new ArrayList<>();
|
||||||
@ -691,7 +700,8 @@ public class JImageGenerator {
|
|||||||
String[] args = optionsJLink();
|
String[] args = optionsJLink();
|
||||||
System.err.println("jlink options: " + optionsPrettyPrint(args));
|
System.err.println("jlink options: " + optionsPrettyPrint(args));
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer));
|
PrintWriter pw = new PrintWriter(writer);
|
||||||
|
int exitCode = JLINK_TOOL.run(pw, pw, args);
|
||||||
return new Result(exitCode, writer.toString(), output);
|
return new Result(exitCode, writer.toString(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +709,8 @@ public class JImageGenerator {
|
|||||||
String[] args = optionsPostProcessJLink();
|
String[] args = optionsPostProcessJLink();
|
||||||
System.err.println("jlink options: " + optionsPrettyPrint(args));
|
System.err.println("jlink options: " + optionsPrettyPrint(args));
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer));
|
PrintWriter pw = new PrintWriter(writer);
|
||||||
|
int exitCode = JLINK_TOOL.run(pw, pw, args);
|
||||||
return new Result(exitCode, writer.toString(), output);
|
return new Result(exitCode, writer.toString(), output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user