< prev index next >

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

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

@@ -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 planned to be removed 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 >