⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tty.java

📁 jpda例子文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            }        }        // not found        throw new IllegalArgumentException(MessageOutput.format("Invalid transport name:",                                                                transportName));    }    private static boolean supportsSharedMemory() {        List connectors = Bootstrap.virtualMachineManager().allConnectors();        Iterator iter = connectors.iterator();        while (iter.hasNext()) {            Connector connector = (Connector)iter.next();            if (connector.transport().name().equals("dt_shmem")) {                return true;            }        }        return false;    }    private static String addressToSocketArgs(String address) {        int index = address.indexOf(':');        if (index != -1) {            String hostString = address.substring(0, index);            String portString = address.substring(index + 1);            return "hostname=" + hostString + ",port=" + portString;        } else {            return "port=" + address;        }    }    private static boolean hasWhitespace(String string) {        int length = string.length();        for (int i = 0; i < length; i++) {            if (Character.isWhitespace(string.charAt(i))) {                return true;            }        }        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);                if (c == '"') {                    buffer.append('\\');                }                buffer.append(c);            }            buffer.append("\" ");            return buffer.toString();        } else {            return string + argument + ' ';        }    }    public static void main(String argv[]) throws MissingResourceException {        String cmdLine = "";        String javaArgs = "";        int traceFlags = VirtualMachine.TRACE_NONE;        boolean launchImmediately = false;        String connectSpec = null;                MessageOutput.textResources = ResourceBundle.getBundle            ("com.sun.tools.example.debug.tty.TTYResources",             Locale.getDefault());        for (int i = 0; i < argv.length; i++) {            String token = argv[i];            if (token.equals("-dbgtrace")) {                if ((i == argv.length - 1) ||                    ! Character.isDigit(argv[i+1].charAt(0))) {                    traceFlags = VirtualMachine.TRACE_ALL;                } else {                    String flagStr = "";                    try {                        flagStr = argv[++i];                        traceFlags = Integer.decode(flagStr).intValue();                    } catch (NumberFormatException nfe) {                        usageError("dbgtrace flag value must be an integer:",                                   flagStr);                        return;                                    }                }            } else if (token.equals("-X")) {                usageError("Use java minus X to see");                return;            } else if (                   // Standard VM options passed on                   token.equals("-v") || token.startsWith("-v:") ||  // -v[:...]                   token.startsWith("-verbose") ||                  // -verbose[:...]                   token.startsWith("-D") ||                   // -classpath handled below                   // NonStandard options passed on                   token.startsWith("-X") ||                   // Old-style options (These should remain in place as long as                   //  the standard VM accepts them)                   token.equals("-noasyncgc") || token.equals("-prof") ||                   token.equals("-verify") || token.equals("-noverify") ||                   token.equals("-verifyremote") ||                   token.equals("-verbosegc") ||                   token.startsWith("-ms") || token.startsWith("-mx") ||                   token.startsWith("-ss") || token.startsWith("-oss") ) {                javaArgs = addArgument(javaArgs, token);            } else if (token.equals("-tclassic")) {                usageError("Classic VM no longer supported.");                return;            } else if (token.equals("-tclient")) {                // -client must be the first one                javaArgs = "-client " + javaArgs;            } else if (token.equals("-tserver")) {                // -server must be the first one                javaArgs = "-server " + javaArgs;            } else if (token.equals("-sourcepath")) {                if (i == (argv.length - 1)) {                    usageError("No sourcepath specified.");                    return;                }                Env.setSourcePath(argv[++i]);            } else if (token.equals("-classpath")) {                if (i == (argv.length - 1)) {                    usageError("No classpath specified.");                    return;                }                javaArgs = addArgument(javaArgs, token);                javaArgs = addArgument(javaArgs, argv[++i]);            } else if (token.equals("-attach")) {                if (connectSpec != null) {                    usageError("cannot redefine existing connection", token);                    return;                }                if (i == (argv.length - 1)) {                    usageError("No attach address specified.");                    return;                }                String address = argv[++i];                /*                 * -attach is shorthand for one of the reference implementation's                 * attaching connectors. Use the shared memory attach if it's                 * available; otherwise, use sockets. Build a connect                  * specification string based on this decision.                 */                if (supportsSharedMemory()) {                    connectSpec = "com.sun.jdi.SharedMemoryAttach:name=" +                                    address;                } else {                    String suboptions = addressToSocketArgs(address);                    connectSpec = "com.sun.jdi.SocketAttach:" + suboptions;                }            } else if (token.equals("-listen") || token.equals("-listenany")) {                if (connectSpec != null) {                    usageError("cannot redefine existing connection", token);                    return;                }                String address = null;                if (token.equals("-listen")) {                    if (i == (argv.length - 1)) {                        usageError("No attach address specified.");                        return;                    }                    address = argv[++i];                }                /*                 * -listen[any] is shorthand for one of the reference implementation's                 * listening connectors. Use the shared memory listen if it's                 * available; otherwise, use sockets. Build a connect                  * specification string based on this decision.                 */                if (supportsSharedMemory()) {                    connectSpec = "com.sun.jdi.SharedMemoryListen";                    if (address != null) {                        connectSpec += (":name=" + address);                    }                } else {                    String suboptions = addressToSocketArgs(address);                    connectSpec = "com.sun.jdi.SocketListen";                    if (address != null) {                        connectSpec += (":port=" + address);                    }                }            } else if (token.equals("-launch")) {                launchImmediately = true;            } else if (token.equals("-connect")) {                /*                 * -connect allows the user to pick the connector                 * used in bringing up the target VM. This allows                  * use of connectors other than those in the reference                 * implementation.                 */                if (connectSpec != null) {                    usageError("cannot redefine existing connection", token);                    return;                }                if (i == (argv.length - 1)) {                    usageError("No connect specification.");                    return;                }                connectSpec = argv[++i];            } else if (token.equals("-help")) {                usage();            } else if (token.equals("-version")) {                Commands evaluator = new Commands();                                evaluator.commandVersion(progname, version);                System.exit(0);            } else if (token.startsWith("-")) {                usageError("invalid option", token);                return;            } else {                // Everything from here is part of the command line                cmdLine = addArgument("", token);                for (i++; i < argv.length; i++) {                    cmdLine = addArgument(cmdLine, argv[i]);                }                break;            }        }        /*         * Unless otherwise specified, set the default connect spec.	 */        /*         * Here are examples of jdb command lines and how the options	 * are interpreted as arguments to the program being debugged.	 * arg1       arg2	 * ----       ----	 * jdb hello a b       a          b	 * jdb hello "a b"     a b	 * jdb hello a,b       a,b	 * jdb hello a, b      a,         b	 * jdb hello "a, b"    a, b	 * jdb -connect "com.sun.jdi.CommandLineLaunch:main=hello  a,b"   illegal	 * jdb -connect  com.sun.jdi.CommandLineLaunch:main=hello "a,b"   illegal	 * jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a,b"'  arg1 = a,b	 * jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a b"'  arg1 = a b	 * jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello  a b'   arg1 = a  arg2 = b	 * jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a," b' arg1 = a, arg2 = b	 */        if (connectSpec == null) {            connectSpec = "com.sun.jdi.CommandLineLaunch:";        } else if (!connectSpec.endsWith(",") && !connectSpec.endsWith(":")) {            connectSpec += ","; // (Bug ID 4285874)        }         cmdLine = cmdLine.trim();        javaArgs = javaArgs.trim();        if (cmdLine.length() > 0) {            if (!connectSpec.startsWith("com.sun.jdi.CommandLineLaunch:")) {                usageError("Cannot specify command line with connector:",                           connectSpec);                return;            }            connectSpec += "main=" + cmdLine + ",";        }         if (javaArgs.length() > 0) {            if (!connectSpec.startsWith("com.sun.jdi.CommandLineLaunch:")) {                usageError("Cannot specify target vm arguments with connector:",                           connectSpec);                return;            }            connectSpec += "options=" + javaArgs + ",";        }         try {            if (! connectSpec.endsWith(",")) {                connectSpec += ","; // (Bug ID 4285874)            }            Env.init(connectSpec, launchImmediately, traceFlags);            new TTY();        } catch(Exception e) {                            MessageOutput.printException("Internal exception:", e);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -