< prev index next >

src/jdk.pack/share/native/unpack200/main.cpp

Print this page
rev 50498 : 8199871: Deprecate pack200 and unpack200 tools
Reviewed-by:

@@ -137,11 +137,11 @@
   gunzip* gzin = NEW(gunzip, 1);
   gzin->init(u);
 }
 
 static const char* nbasename(const char* progname) {
-  const char* slash = strrchr(progname, '/');
+  const char* slash = strrchr(progname, PATH_SEPARATOR);
   if (slash != null)  progname = ++slash;
   return progname;
 }
 
 #define USAGE_HEADER "Usage:  %s [-opt... | --option=value]... x.pack[.gz] y.jar\n"

@@ -159,10 +159,17 @@
     "  -V, --version                 print program version\n" \
     "\n" \
     "Exit Status:\n" \
     "  0 if successful, >0 if an error occurred\n"
 
+#define DEPRECATE_WARNING \
+    "\nWarning: The %s tool is deprecated, and is planned for removal in a future JDK release.\n\n"
+
+#define SUPPRESS_DEPRECATE_MSG "-XDsuppress-tool-removal-message"
+
+static bool suppress_warning = false;
+
 static void usage(unpacker* u, const char* progname, bool full = false) {
   // WinMain does not set argv[0] to the progrname
   progname = (progname != null) ? nbasename(progname) : "unpack200";
 
   fprintf(u->errstrm, USAGE_HEADER, progname);

@@ -180,24 +187,32 @@
   envargs.init();
   if (env != null) {
     char* buf = (char*) strdup(env);
     const char* delim = "\n\t ";
     for (char* p = strtok(buf, delim); p != null; p = strtok(null, delim)) {
+      if (!strcmp(p, SUPPRESS_DEPRECATE_MSG)) {
+        suppress_warning = true;
+      } else {
       envargs.add(p);
     }
   }
+  }
   // allocate extra margin at both head and tail
   char** argp = NEW(char*, envargs.length()+argc+1);
   char** argp0 = argp;
   int i;
   for (i = 0; i < envargs.length(); i++) {
     *argp++ = (char*) envargs.get(i);
   }
   for (i = 1; i < argc; i++) {
     // note: skip argv[0] (program name)
+    if (!strcmp(argv[i], SUPPRESS_DEPRECATE_MSG)) {
+      suppress_warning = true;
+    } else {
     *argp++ = (char*) strdup(argv[i]);  // make a scratch copy
   }
+  }
   *argp = null; // sentinel
   envargc = envargs.length();  // report this count to next_arg
   envargs.free();
   return argp0;
 }

@@ -291,10 +306,14 @@
   char** argp = argbuf;
 
   int verbose = 0;
   char* logfile = null;
 
+  if (!suppress_warning) {
+      fprintf(u.errstrm, DEPRECATE_WARNING, nbasename(argv[0]));
+  }
+
   for (;;) {
     const char* arg = (*argp == null)? "": u.saveStr(*argp);
     bool isenvarg = (argp < arg0);
     int ach = next_arg(argp);
     bool hasoptarg = (ach != 0 && strchr(string_opts, ach) != null);
< prev index next >