JDK-4684386 : TTY: jdb throwing IllegalArgumentException while parsing commandline args
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 1.4.1
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_1
  • CPU: sparc
  • Submitted: 2002-05-14
  • Updated: 2003-04-12
  • Resolved: 2002-09-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Related Reports
Relates :  
Description
jdb is throwing an illegal argument exception while passing a commandline argument seperated by comma.

eg: jdb Server -ORBDebug subcontract,shutdown,transport


bash-2.04$ /java/re/jdk/1.4.1/promoted/latest/binaries/solaris-sparc/bin/java -version
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b11)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b11, mixed mode)
bash-2.04$ 
bash-2.04$ more Server.java
import org.omg.CORBA.*;

public class Server {
    public static void main(String[] args) {
        try {
            ORB orb = ORB.init(args, System.getProperties());
            System.out.println("Server ready ....");
            orb.run();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
bash-2.04$ /java/re/jdk/1.4.1/promoted/latest/binaries/solaris-sparc/bin/javac Server.java
bash-2.04$ /java/re/jdk/1.4.1/promoted/latest/binaries/solaris-sparc/bin/jdb Server -ORBDebug subcontract,transport,shutdown
Internal exception:
java.lang.IllegalArgumentException: Illegal connector argument: transport,shutdown,
        at com.sun.tools.example.debug.tty.VMConnection.parseConnectorArgs(VMConnection.java:136)
        at com.sun.tools.example.debug.tty.VMConnection.<init>(VMConnection.java:160)
        at com.sun.tools.example.debug.tty.Env.init(Env.java:61)
        at com.sun.tools.example.debug.tty.TTY.main(TTY.java:829)
bash-2.04$ /java/re/jdk/1.4.1/promoted/latest/binaries/solaris-sparc/bin/jdb Server -ORBDebug subcontract                   
Initializing jdb ...
*** Reading commands from /home/sm122304/.jdbrc
Deferring breakpoint com.sun.corba.se.internal.POA.POAImpl:1048.
It will be set after the class is loaded.
> > run
run Server -ORBDebug subcontract
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
> 
VM Started: Server ready ....

> quit

Fatal error:
Failed reading output of child java interpreter.

Fatal error:
Failed reading output of child java interpreter.
bash-2.04$ 


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis mantis-b02 FIXED IN: mantis mantis-b02 INTEGRATED IN: mantis mantis-b02
14-06-2004

WORK AROUND ###@###.### 2002-05-13 1) Enclose the application arg string in double quotes: % jdb Server "-ORBDebug subcontract,shutdown,transport" Initializing jdb ... > run run Server "-ORBDebug subcontract,shutdown,transport" Set uncaught java.lang.Throwable Set deferred uncaught java.lang.Throwable > VM Started: Server ready .... 2) Start jdb first, then supply the application arguments as part of the run command: % jdb Initializing jdb ... > run Server -ORBDebug subcontract,shutdown,transport run Server -ORBDebug subcontract,shutdown,transport Set uncaught java.lang.Throwable Set deferred uncaught java.lang.Throwable > VM Started: Server ready .... 3) Separate debugger and debugee, as follows: Start the debugee program in one command window: % java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=4571 Server -ORBDebug subcontract,shutdown,transport In another window, attach your debugger (jdb in this example) to the debugee via a socket: jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=4571 You may also use the shared memory transport if you are on a win32 platform, as follows: In one command window: java -Xdebug -Xrunjdwp:transport=dt_shmem,server=y,address=mine Server -ORBDebug subcontract,shutdown,transport In a second command window (again using jdb as an example): jdb -connect com.sun.jdi.SharedMemoryAttach:name=mine
11-06-2004

PUBLIC COMMENTS .
10-06-2004

SUGGESTED FIX Name: suvasis Date: 07/17/02 diff : *** /export/mantis_sdk1/webrevs/webrev-2002.07.17/src/share/classes/com/sun/tools/example/debug/tty/TTY.java- Wed Jul 17 17:27:13 2002 --- TTY.java Wed Jul 17 17:24:43 2002 *** 610,620 **** } return false; } private static String addArgument(String string, String argument) { ! if (hasWhitespace(argument)) { // Quotes were stripped out for this argument, add 'em back. StringBuffer buffer = new StringBuffer(string); buffer.append('"'); for (int i = 0; i < argument.length(); i++) { char c = argument.charAt(i); --- 610,620 ---- } return false; } private static String addArgument(String string, String argument) { ! if (hasWhitespace(argument) || argument.indexOf(',') != -1) { // Quotes were stripped out for this argument, add 'em back. StringBuffer buffer = new StringBuffer(string); buffer.append('"'); for (int i = 0; i < argument.length(); i++) { char c = argument.charAt(i); *** 797,806 **** --- 797,808 ---- /* * Unless otherwise specified, set the default connect spec. */ if (connectSpec == null) { connectSpec = "com.sun.jdi.CommandLineLaunch:"; + } else if (!connectSpec.endsWith(",") && !connectSpec.endsWith(":")) { + connectSpec += ","; // (Bug ID 4285874) } cmdLine = cmdLine.trim(); javaArgs = javaArgs.trim(); Also wrote a regression test to test this bug. JdbArgTest.sh passed successfully in solaris and windows env. ###@###.### 2002-07-23
23-07-2002

EVALUATION Name : suvasis Date : 07/18/02 The jdb command line parser in TTY.java looks for blanks in the string after the class name and quotes the string if it finds them. But, it didn't do this if commas appeared in this string. These unquoted commas caused later code in VMConnection.java to think there were multiple name=value pairs in the connection spec. The fix is to quote the string if contains either blanks or commas. In the src/share/classes/com/sun/tools/example/debug/tty/TTY.java file modified the addArgument method line 615 and added if (hasWhitespace(argument) || argument.indexOf(',') != -1). Here the comma in the argument is taken care of. Without this change unquoted commas caused later code in VMConnection.java to think there were multiple name=value pairs in the connection spec. Wrote a regression test JdbArgTest.sh to test this bug. The test passes successfully. ###@###.### 2002-07-18
18-07-2002