Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4672990

Command line argument outcome is strange when passed asterisk(*)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • None
    • 1.4.0
    • docs
    • x86
    • windows_xp

    Description

      Name: rmT116609 Date: 04/23/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION : Windows XP

      A DESCRIPTION OF THE PROBLEM :
      If the argument * is given, the outcome of the argument-array is strange.
      trye args.length and you'll be suprised.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile given source
      2. Use 1 argument: okay (The outcome should be 1 and that's good)
      3. Use 2 arguments : okay * (The outcome should be 2 but is something weird)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      See reproducing steps.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Test
      {
      public static void main( String[] args )
      {

      System.out.println("Len: " + args.length);
      System.out.println("args: " + args);
      System.out.println("args[ 0 ]: " + args[ 0 ]);
      System.out.println("args[ 1 ]: " + args[ 1 ]);
      }

      }// end of class: Test
      ---------- END SOURCE ----------
      Output:


      C:\> java Test okay *
      Len: 562
      args: [Ljava.lang.String;@765291
      args[ 0 ]: okay
      args[ 1 ]: 132003

      Workaround:

      C:\> java Test okay "*"
      Len: 2
      args: [Ljava.lang.String;@eee36c
      args[ 0 ]: okay
      args[ 1 ]: *

      I think the work around is no good since I'm not able to test if the end user used quotations are not.

      According to the doc's, the arguments passed via the command line are strings.
      (see : http://java.sun.com/docs/books/tutorial/essential/attributes/cmdLineArgs.html
      )

      There is no mentioning the quotation or the issue with the asterisk.


      (Review ID: 145719)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              shommel Scott Hommel (Inactive)
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: