Source Code Cross Referenced for VerbosePacketStream.java in  » IDE-Eclipse » jdt » org » eclipse » jdi » internal » spy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdi.internal.spy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*******************************************************************************
0002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
0003:         * All rights reserved. This program and the accompanying materials
0004:         * are made available under the terms of the Eclipse Public License v1.0
0005:         * which accompanies this distribution, and is available at
0006:         * http://www.eclipse.org/legal/epl-v10.html
0007:         *
0008:         * Contributors:
0009:         *     IBM Corporation - initial API and implementation
0010:         *     Keith Seitz - Bug 165988
0011:         *******************************************************************************/package org.eclipse.jdi.internal.spy;
0012:
0013:        import java.io.ByteArrayInputStream;
0014:        import java.io.DataInputStream;
0015:        import java.io.IOException;
0016:        import java.io.OutputStream;
0017:        import java.io.PrintStream;
0018:        import java.io.UTFDataFormatException;
0019:        import com.ibm.icu.text.MessageFormat;
0020:        import java.util.Arrays;
0021:
0022:        /**
0023:         * The <code>VerbosePacketWriter</code> is responsible for writing
0024:         * out JdwpPacket data in human readable form.
0025:         */
0026:        public class VerbosePacketStream extends PrintStream {
0027:            /** Tag Constants. */
0028:            //	public static final byte NULL_TAG = 91;			// Used for tagged null values.	
0029:            public static final byte ARRAY_TAG = 91; // '[' - an array object (objectID size).	
0030:            public static final byte BYTE_TAG = 66; // 'B' - a byte value (1 byte).	
0031:            public static final byte CHAR_TAG = 67; // 'C' - a character value (2 bytes).	
0032:            public static final byte OBJECT_TAG = 76; // 'L' - an object (objectID size).	
0033:            public static final byte FLOAT_TAG = 70; // 'F' - a float value (4 bytes).	
0034:            public static final byte DOUBLE_TAG = 68; // 'D' - a double value (8 bytes).	
0035:            public static final byte INT_TAG = 73; // 'I' - an int value (4 bytes).	
0036:            public static final byte LONG_TAG = 74; // 'J' - a long value (8 bytes).	
0037:            public static final byte SHORT_TAG = 83; // 'S' - a short value (2 bytes).	
0038:            public static final byte VOID_TAG = 86; // 'V' - a void value (no bytes).	
0039:            public static final byte BOOLEAN_TAG = 90; // 'Z' - a boolean value (1 byte).	
0040:            public static final byte STRING_TAG = 115; // 's' - a String object (objectID size).	
0041:            public static final byte THREAD_TAG = 116; // 't' - a Thread object (objectID size).	
0042:            public static final byte THREAD_GROUP_TAG = 103; // 'g' - a ThreadGroup object (objectID size).	
0043:            public static final byte CLASS_LOADER_TAG = 108; // 'l' - a ClassLoader object (objectID size).	
0044:            public static final byte CLASS_OBJECT_TAG = 99; // 'c' - a class object object (objectID size).	
0045:
0046:            /** TypeTag Constants. */
0047:            public static final byte TYPE_TAG_CLASS = 1; // ReferenceType is a class.	
0048:            public static final byte TYPE_TAG_INTERFACE = 2; // ReferenceType is an interface.	
0049:            public static final byte TYPE_TAG_ARRAY = 3; // ReferenceType is an array.	
0050:
0051:            /** ClassStatus Constants. */
0052:            public static final int JDWP_CLASS_STATUS_VERIFIED = 1;
0053:            public static final int JDWP_CLASS_STATUS_PREPARED = 2;
0054:            public static final int JDWP_CLASS_STATUS_INITIALIZED = 4;
0055:            public static final int JDWP_CLASS_STATUS_ERROR = 8;
0056:
0057:            /** access_flags Constants */
0058:            public static final int ACC_PUBLIC = 0x0001;
0059:            public static final int ACC_PRIVATE = 0x0002;
0060:            public static final int ACC_PROTECTED = 0x0004;
0061:            public static final int ACC_STATIC = 0x0008;
0062:            public static final int ACC_FINAL = 0x0010;
0063:            public static final int ACC_SUPER = 0x0020;
0064:            public static final int ACC_VOLATILE = 0x0040;
0065:            public static final int ACC_TRANSIENT = 0x0080;
0066:            public static final int ACC_NATIVE = 0x0100;
0067:            public static final int ACC_INTERFACE = 0x0200;
0068:            public static final int ACC_ABSTRACT = 0x0400;
0069:            public static final int ACC_STRICT = 0x0800;
0070:            public static final int ACC_ENUM = 0x0100;
0071:            public static final int ACC_VARARGS = 0x0080;
0072:            public static final int ACC_BRIDGE = 0x0040;
0073:            public static final int ACC_SYNTHETIC = 0x1000;
0074:            public static final int ACC_SYNCHRONIZED = 0x0020;
0075:
0076:            public static final int ACC_EXT_SYNTHETIC = 0xf0000000;
0077:
0078:            /** Invoke options constants */
0079:            public static final int INVOKE_SINGLE_THREADED = 0x01;
0080:            public static final int INVOKE_NONVIRTUAL = 0x02;
0081:
0082:            /** ThreadStatus Constants */
0083:            public static final int THREAD_STATUS_ZOMBIE = 0;
0084:            public static final int THREAD_STATUS_RUNNING = 1;
0085:            public static final int THREAD_STATUS_SLEEPING = 2;
0086:            public static final int THREAD_STATUS_MONITOR = 3;
0087:            public static final int THREAD_STATUS_WAIT = 4;
0088:
0089:            /** EventKind Constants */
0090:            public static final int EVENTKIND_SINGLE_STEP = 1;
0091:            public static final int EVENTKIND_BREAKPOINT = 2;
0092:            public static final int EVENTKIND_FRAME_POP = 3;
0093:            public static final int EVENTKIND_EXCEPTION = 4;
0094:            public static final int EVENTKIND_USER_DEFINED = 5;
0095:            public static final int EVENTKIND_THREAD_START = 6;
0096:            public static final int EVENTKIND_THREAD_END = 7;
0097:            public static final int EVENTKIND_THREAD_DEATH = EVENTKIND_THREAD_END;
0098:            public static final int EVENTKIND_CLASS_PREPARE = 8;
0099:            public static final int EVENTKIND_CLASS_UNLOAD = 9;
0100:            public static final int EVENTKIND_CLASS_LOAD = 10;
0101:            public static final int EVENTKIND_FIELD_ACCESS = 20;
0102:            public static final int EVENTKIND_FIELD_MODIFICATION = 21;
0103:            public static final int EVENTKIND_EXCEPTION_CATCH = 30;
0104:            public static final int EVENTKIND_METHOD_ENTRY = 40;
0105:            public static final int EVENTKIND_METHOD_EXIT = 41;
0106:            public static final int EVENTKIND_VM_INIT = 90;
0107:            public static final int EVENTKIND_VM_START = EVENTKIND_VM_INIT;
0108:            public static final int EVENTKIND_VM_DEATH = 99;
0109:            public static final int EVENTKIND_VM_DISCONNECTED = 100;
0110:
0111:            /** SuspendStatus Constants */
0112:            public static final int SUSPEND_STATUS_SUSPENDED = 0x01;
0113:
0114:            /** SuspendPolicy Constants */
0115:            public static final int SUSPENDPOLICY_NONE = 0;
0116:            public static final int SUSPENDPOLICY_EVENT_THREAD = 1;
0117:            public static final int SUSPENDPOLICY_ALL = 2;
0118:
0119:            /** StepDepth Constants */
0120:            public static final int STEPDEPTH_INTO = 0;
0121:            public static final int STEPDEPTH_OVER = 1;
0122:            public static final int STEPDEPTH_OUT = 2;
0123:
0124:            /** StepSize Constants */
0125:            public static final int STEPSIZE_MIN = 0;
0126:            public static final int STEPSIZE_LINE = 1;
0127:
0128:            private static final byte[] padding;
0129:            static {
0130:                padding = new byte[256];
0131:                Arrays.fill(padding, (byte) ' ');
0132:            }
0133:
0134:            private static final String shift = new String(padding, 0, 32);
0135:
0136:            public VerbosePacketStream(OutputStream out) {
0137:                super (out);
0138:            }
0139:
0140:            private static final byte[] zeros;
0141:            static {
0142:                zeros = new byte[16];
0143:                Arrays.fill(zeros, (byte) '0');
0144:            }
0145:
0146:            public synchronized void print(JdwpPacket packet, boolean fromVM)
0147:                    throws IOException {
0148:                try {
0149:                    printHeader(packet, fromVM);
0150:                    printData(packet);
0151:                    println();
0152:                } catch (UnableToParseDataException e) {
0153:                    println("\n" + e.getMessage() + ':'); //$NON-NLS-1$
0154:                    printDescription("Remaining data:"); //$NON-NLS-1$
0155:                    byte[] data = e.getRemainingData();
0156:                    if (data == null) {
0157:                        printHex(packet.data());
0158:                    } else {
0159:                        printHex(e.getRemainingData());
0160:                    }
0161:                    println();
0162:                }
0163:            }
0164:
0165:            protected void printHeader(JdwpPacket packet, boolean fromVM)
0166:                    throws UnableToParseDataException {
0167:                if (fromVM) {
0168:                    println("From VM"); //$NON-NLS-1$
0169:                } else {
0170:                    println("From Debugger"); //$NON-NLS-1$
0171:                }
0172:
0173:                printDescription("Packet ID:"); //$NON-NLS-1$
0174:                printHex(packet.getId());
0175:                println();
0176:
0177:                printDescription("Length:"); //$NON-NLS-1$
0178:                print(packet.getLength());
0179:                println();
0180:
0181:                printDescription("Flags:"); //$NON-NLS-1$
0182:                byte flags = packet.getFlags();
0183:                printHex(flags);
0184:                if ((flags & JdwpPacket.FLAG_REPLY_PACKET) != 0) {
0185:                    print(MessageFormat
0186:                            .format(
0187:                                    " (REPLY to {0})", new String[] { (String) JdwpCommandPacket.commandMap().get(new Integer(TcpipSpy.getCommand(packet))) })); //$NON-NLS-1$
0188:                } else {
0189:                    print(" (COMMAND)"); //$NON-NLS-1$
0190:                }
0191:                println();
0192:
0193:                printSpecificHeaderFields(packet);
0194:            }
0195:
0196:            protected void printSpecificHeaderFields(JdwpPacket packet) {
0197:                if (packet instanceof  JdwpReplyPacket) {
0198:                    printError((JdwpReplyPacket) packet);
0199:                } else if (packet instanceof  JdwpCommandPacket) {
0200:                    printCommand((JdwpCommandPacket) packet);
0201:                }
0202:            }
0203:
0204:            protected void printCommand(JdwpCommandPacket commandPacket) {
0205:                printDescription("Command set:"); //$NON-NLS-1$
0206:                int commandAndSet = commandPacket.getCommand();
0207:                byte set = (byte) (commandAndSet >> 8);
0208:                byte command = (byte) commandAndSet;
0209:                printHex(set);
0210:                printParanthetical(set);
0211:                println();
0212:                printDescription("Command:"); //$NON-NLS-1$
0213:                printHex(command);
0214:                printParanthetical(command);
0215:                print(" ("); //$NON-NLS-1$
0216:                print(JdwpCommandPacket.commandMap().get(
0217:                        new Integer(commandAndSet)));
0218:                println(')');
0219:            }
0220:
0221:            protected void printError(JdwpReplyPacket reply) {
0222:                int error = reply.errorCode();
0223:
0224:                printDescription("Error:"); //$NON-NLS-1$
0225:                printHex(error);
0226:                if (error != 0) {
0227:                    print(" ("); //$NON-NLS-1$
0228:                    print(JdwpReplyPacket.errorMap().get(new Integer(error)));
0229:                    print(')');
0230:                }
0231:                println();
0232:            }
0233:
0234:            protected void printData(JdwpPacket packet) throws IOException,
0235:                    UnableToParseDataException {
0236:                if ((packet.getFlags() & JdwpPacket.FLAG_REPLY_PACKET) != 0) {
0237:                    printReplyData((JdwpReplyPacket) packet);
0238:                } else {
0239:                    printCommandData((JdwpCommandPacket) packet);
0240:                }
0241:            }
0242:
0243:            private void printCommandData(JdwpCommandPacket command)
0244:                    throws IOException, UnableToParseDataException {
0245:                byte[] data = command.data();
0246:                if (data == null)
0247:                    return;
0248:                DataInputStream in = new DataInputStream(
0249:                        new ByteArrayInputStream(data));
0250:                int commandId = command.getCommand();
0251:                switch (commandId) {
0252:                /** Commands VirtualMachine. */
0253:                case JdwpCommandPacket.VM_VERSION:
0254:                    // no data
0255:                    break;
0256:                case JdwpCommandPacket.VM_CLASSES_BY_SIGNATURE:
0257:                    printVmClassesBySignatureCommand(in);
0258:                    break;
0259:                case JdwpCommandPacket.VM_ALL_CLASSES:
0260:                    // no data
0261:                    break;
0262:                case JdwpCommandPacket.VM_ALL_THREADS:
0263:                    // no data
0264:                    break;
0265:                case JdwpCommandPacket.VM_TOP_LEVEL_THREAD_GROUPS:
0266:                    // no data
0267:                    break;
0268:                case JdwpCommandPacket.VM_DISPOSE:
0269:                    // no data
0270:                    break;
0271:                case JdwpCommandPacket.VM_ID_SIZES:
0272:                    // no data
0273:                    break;
0274:                case JdwpCommandPacket.VM_SUSPEND:
0275:                    // no data
0276:                    break;
0277:                case JdwpCommandPacket.VM_RESUME:
0278:                    // no data
0279:                    break;
0280:                case JdwpCommandPacket.VM_EXIT:
0281:                    printVmExitCommand(in);
0282:                    break;
0283:                case JdwpCommandPacket.VM_CREATE_STRING:
0284:                    printVmCreateStringCommand(in);
0285:                    break;
0286:                case JdwpCommandPacket.VM_CAPABILITIES:
0287:                    // no data
0288:                    break;
0289:                case JdwpCommandPacket.VM_CLASS_PATHS:
0290:                    // no data
0291:                    break;
0292:                case JdwpCommandPacket.VM_DISPOSE_OBJECTS:
0293:                    printVmDisposeObjectsCommand(in);
0294:                    break;
0295:                case JdwpCommandPacket.VM_HOLD_EVENTS:
0296:                    // no data
0297:                    break;
0298:                case JdwpCommandPacket.VM_RELEASE_EVENTS:
0299:                    // no data
0300:                    break;
0301:                case JdwpCommandPacket.VM_CAPABILITIES_NEW:
0302:                    // no data
0303:                    break;
0304:                case JdwpCommandPacket.VM_REDEFINE_CLASSES:
0305:                    printVmRedefineClassCommand(in);
0306:                    break;
0307:                case JdwpCommandPacket.VM_SET_DEFAULT_STRATUM:
0308:                    printVmSetDefaultStratumCommand(in);
0309:                    break;
0310:                case JdwpCommandPacket.VM_ALL_CLASSES_WITH_GENERIC:
0311:                    // no data
0312:                    break;
0313:
0314:                /** Commands ReferenceType. */
0315:                case JdwpCommandPacket.RT_SIGNATURE:
0316:                    printRtDefaultCommand(in);
0317:                    break;
0318:                case JdwpCommandPacket.RT_CLASS_LOADER:
0319:                    printRtDefaultCommand(in);
0320:                    break;
0321:                case JdwpCommandPacket.RT_MODIFIERS:
0322:                    printRtDefaultCommand(in);
0323:                    break;
0324:                case JdwpCommandPacket.RT_FIELDS:
0325:                    printRtDefaultCommand(in);
0326:                    break;
0327:                case JdwpCommandPacket.RT_METHODS:
0328:                    printRtDefaultCommand(in);
0329:                    break;
0330:                case JdwpCommandPacket.RT_GET_VALUES:
0331:                    printRtGetValuesCommand(in);
0332:                    break;
0333:                case JdwpCommandPacket.RT_SOURCE_FILE:
0334:                    printRtDefaultCommand(in);
0335:                    break;
0336:                case JdwpCommandPacket.RT_NESTED_TYPES:
0337:                    printRtDefaultCommand(in);
0338:                    break;
0339:                case JdwpCommandPacket.RT_STATUS:
0340:                    printRtDefaultCommand(in);
0341:                    break;
0342:                case JdwpCommandPacket.RT_INTERFACES:
0343:                    printRtDefaultCommand(in);
0344:                    break;
0345:                case JdwpCommandPacket.RT_CLASS_OBJECT:
0346:                    printRtDefaultCommand(in);
0347:                    break;
0348:                case JdwpCommandPacket.RT_SOURCE_DEBUG_EXTENSION:
0349:                    printRtDefaultCommand(in);
0350:                    break;
0351:                case JdwpCommandPacket.RT_SIGNATURE_WITH_GENERIC:
0352:                    printRtDefaultCommand(in);
0353:                    break;
0354:                case JdwpCommandPacket.RT_FIELDS_WITH_GENERIC:
0355:                    printRtDefaultCommand(in);
0356:                    break;
0357:                case JdwpCommandPacket.RT_METHODS_WITH_GENERIC:
0358:                    printRtDefaultCommand(in);
0359:                    break;
0360:
0361:                /** Commands ClassType. */
0362:                case JdwpCommandPacket.CT_SUPERCLASS:
0363:                    printCtSuperclassCommand(in);
0364:                    break;
0365:                case JdwpCommandPacket.CT_SET_VALUES:
0366:                    printCtSetValuesCommand(in);
0367:                    break;
0368:                case JdwpCommandPacket.CT_INVOKE_METHOD:
0369:                    printCtInvokeMethodCommand(in);
0370:                    break;
0371:                case JdwpCommandPacket.CT_NEW_INSTANCE:
0372:                    printCtNewInstanceCommand(in);
0373:                    break;
0374:
0375:                /** Commands ArrayType. */
0376:                case JdwpCommandPacket.AT_NEW_INSTANCE:
0377:                    printAtNewInstanceCommand(in);
0378:                    break;
0379:
0380:                /** Commands Method. */
0381:                case JdwpCommandPacket.M_LINE_TABLE:
0382:                    printMDefaultCommand(in);
0383:                    break;
0384:                case JdwpCommandPacket.M_VARIABLE_TABLE:
0385:                    printMDefaultCommand(in);
0386:                    break;
0387:                case JdwpCommandPacket.M_BYTECODES:
0388:                    printMDefaultCommand(in);
0389:                    break;
0390:                case JdwpCommandPacket.M_IS_OBSOLETE:
0391:                    printMDefaultCommand(in);
0392:                    break;
0393:                case JdwpCommandPacket.M_VARIABLE_TABLE_WITH_GENERIC:
0394:                    printMDefaultCommand(in);
0395:                    break;
0396:
0397:                /** Commands ObjectReference. */
0398:                case JdwpCommandPacket.OR_REFERENCE_TYPE:
0399:                    printOrDefaultCommand(in);
0400:                    break;
0401:                case JdwpCommandPacket.OR_GET_VALUES:
0402:                    printOrGetValuesCommand(in);
0403:                    break;
0404:                case JdwpCommandPacket.OR_SET_VALUES:
0405:                    printOrSetValuesCommand(in);
0406:                    break;
0407:                case JdwpCommandPacket.OR_MONITOR_INFO:
0408:                    printOrDefaultCommand(in);
0409:                    break;
0410:                case JdwpCommandPacket.OR_INVOKE_METHOD:
0411:                    printOrInvokeMethodCommand(in);
0412:                    break;
0413:                case JdwpCommandPacket.OR_DISABLE_COLLECTION:
0414:                    printOrDefaultCommand(in);
0415:                    break;
0416:                case JdwpCommandPacket.OR_ENABLE_COLLECTION:
0417:                    printOrDefaultCommand(in);
0418:                    break;
0419:                case JdwpCommandPacket.OR_IS_COLLECTED:
0420:                    printOrDefaultCommand(in);
0421:                    break;
0422:
0423:                /** Commands StringReference. */
0424:                case JdwpCommandPacket.SR_VALUE:
0425:                    printSrValueCommand(in);
0426:                    break;
0427:
0428:                /** Commands ThreadReference. */
0429:                case JdwpCommandPacket.TR_NAME:
0430:                    printTrDefaultCommand(in);
0431:                    break;
0432:                case JdwpCommandPacket.TR_SUSPEND:
0433:                    printTrDefaultCommand(in);
0434:                    break;
0435:                case JdwpCommandPacket.TR_RESUME:
0436:                    printTrDefaultCommand(in);
0437:                    break;
0438:                case JdwpCommandPacket.TR_STATUS:
0439:                    printTrDefaultCommand(in);
0440:                    break;
0441:                case JdwpCommandPacket.TR_THREAD_GROUP:
0442:                    printTrDefaultCommand(in);
0443:                    break;
0444:                case JdwpCommandPacket.TR_FRAMES:
0445:                    printTrFramesCommand(in);
0446:                    break;
0447:                case JdwpCommandPacket.TR_FRAME_COUNT:
0448:                    printTrDefaultCommand(in);
0449:                    break;
0450:                case JdwpCommandPacket.TR_OWNED_MONITORS:
0451:                    printTrDefaultCommand(in);
0452:                    break;
0453:                case JdwpCommandPacket.TR_CURRENT_CONTENDED_MONITOR:
0454:                    printTrDefaultCommand(in);
0455:                    break;
0456:                case JdwpCommandPacket.TR_STOP:
0457:                    printTrStopCommand(in);
0458:                    break;
0459:                case JdwpCommandPacket.TR_INTERRUPT:
0460:                    printTrDefaultCommand(in);
0461:                    break;
0462:                case JdwpCommandPacket.TR_SUSPEND_COUNT:
0463:                    printTrDefaultCommand(in);
0464:                    break;
0465:                /* no more in the jdwp spec
0466:                 case JdwpCommandPacket.TR_POP_TOP_FRAME:
0467:                 break;
0468:                 */
0469:
0470:                /** Commands ThreadGroupReference. */
0471:                case JdwpCommandPacket.TGR_NAME:
0472:                    printTgrDefaultCommand(in);
0473:                    break;
0474:                case JdwpCommandPacket.TGR_PARENT:
0475:                    printTgrDefaultCommand(in);
0476:                    break;
0477:                case JdwpCommandPacket.TGR_CHILDREN:
0478:                    printTgrDefaultCommand(in);
0479:                    break;
0480:
0481:                /** Commands ArrayReference. */
0482:                case JdwpCommandPacket.AR_LENGTH:
0483:                    printArLengthCommand(in);
0484:                    break;
0485:                case JdwpCommandPacket.AR_GET_VALUES:
0486:                    printArGetValuesCommand(in);
0487:                    break;
0488:                case JdwpCommandPacket.AR_SET_VALUES:
0489:                    printArSetValuesCommand(in);
0490:                    break;
0491:
0492:                /** Commands ClassLoaderReference. */
0493:                case JdwpCommandPacket.CLR_VISIBLE_CLASSES:
0494:                    printClrVisibleClassesCommand(in);
0495:                    break;
0496:
0497:                /** Commands EventRequest. */
0498:                case JdwpCommandPacket.ER_SET:
0499:                    printErSetCommand(in);
0500:                    break;
0501:                case JdwpCommandPacket.ER_CLEAR:
0502:                    printErClearCommand(in);
0503:                    break;
0504:                case JdwpCommandPacket.ER_CLEAR_ALL_BREAKPOINTS:
0505:                    // no data
0506:                    break;
0507:
0508:                /** Commands StackFrame. */
0509:                case JdwpCommandPacket.SF_GET_VALUES:
0510:                    printSfGetValuesCommand(in);
0511:                    break;
0512:                case JdwpCommandPacket.SF_SET_VALUES:
0513:                    printSfSetValuesCommand(in);
0514:                    break;
0515:                case JdwpCommandPacket.SF_THIS_OBJECT:
0516:                    printSfDefaultCommand(in);
0517:                    break;
0518:                case JdwpCommandPacket.SF_POP_FRAME:
0519:                    printSfDefaultCommand(in);
0520:                    break;
0521:
0522:                /** Commands ClassObjectReference. */
0523:                case JdwpCommandPacket.COR_REFLECTED_TYPE:
0524:                    printCorReflectedTypeCommand(in);
0525:                    break;
0526:
0527:                /** Commands Event. */
0528:                case JdwpCommandPacket.E_COMPOSITE:
0529:                    printECompositeCommand(in);
0530:                    break;
0531:
0532:                /** Commands Hot Code Replacement (OTI specific). */
0533:                case JdwpCommandPacket.HCR_CLASSES_HAVE_CHANGED:
0534:                case JdwpCommandPacket.HCR_GET_CLASS_VERSION:
0535:                case JdwpCommandPacket.HCR_DO_RETURN:
0536:                case JdwpCommandPacket.HCR_REENTER_ON_EXIT:
0537:                case JdwpCommandPacket.HCR_CAPABILITIES:
0538:                    throw new UnableToParseDataException(
0539:                            "NOT MANAGED COMMAND", remainderData(in)); //$NON-NLS-1$
0540:
0541:                default:
0542:                    int cset = commandId >> 8;
0543:                    int cmd = commandId & 0xFF;
0544:                    println(MessageFormat
0545:                            .format(
0546:                                    "Unknown command : {0} {1}", new String[] { "" + cset, "" + cmd })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
0547:                    break;
0548:                }
0549:            }
0550:
0551:            private void printReplyData(JdwpReplyPacket reply)
0552:                    throws IOException, UnableToParseDataException {
0553:                byte[] data = reply.data();
0554:                if (data == null)
0555:                    return;
0556:                DataInputStream in = new DataInputStream(
0557:                        new ByteArrayInputStream(data));
0558:                JdwpCommandPacket command = TcpipSpy.getCommand(reply.getId());
0559:                int commandId = command.getCommand();
0560:                switch (commandId) {
0561:                /** Commands VirtualMachine. */
0562:                case JdwpCommandPacket.VM_VERSION:
0563:                    printVmVersionReply(in);
0564:                    break;
0565:                case JdwpCommandPacket.VM_CLASSES_BY_SIGNATURE:
0566:                    printVmClassesBySignatureReply(in);
0567:                    break;
0568:                case JdwpCommandPacket.VM_ALL_CLASSES:
0569:                    printVmAllClassesReply(in);
0570:                    break;
0571:                case JdwpCommandPacket.VM_ALL_THREADS:
0572:                    printVmAllThreadsReply(in);
0573:                    break;
0574:                case JdwpCommandPacket.VM_TOP_LEVEL_THREAD_GROUPS:
0575:                    printVmTopLevelThreadGroupReply(in);
0576:                    break;
0577:                case JdwpCommandPacket.VM_DISPOSE:
0578:                    // no data
0579:                    break;
0580:                case JdwpCommandPacket.VM_ID_SIZES:
0581:                    printVmIdSizesReply(in);
0582:                    break;
0583:                case JdwpCommandPacket.VM_SUSPEND:
0584:                    // no data
0585:                    break;
0586:                case JdwpCommandPacket.VM_RESUME:
0587:                    // no data
0588:                    break;
0589:                case JdwpCommandPacket.VM_EXIT:
0590:                    // no data
0591:                    break;
0592:                case JdwpCommandPacket.VM_CREATE_STRING:
0593:                    printVmCreateStringReply(in);
0594:                    break;
0595:                case JdwpCommandPacket.VM_CAPABILITIES:
0596:                    printVmCapabilitiesReply(in);
0597:                    break;
0598:                case JdwpCommandPacket.VM_CLASS_PATHS:
0599:                    printVmClassPathsReply(in);
0600:                    break;
0601:                case JdwpCommandPacket.VM_DISPOSE_OBJECTS:
0602:                    // no data
0603:                    break;
0604:                case JdwpCommandPacket.VM_HOLD_EVENTS:
0605:                    // no data
0606:                    break;
0607:                case JdwpCommandPacket.VM_RELEASE_EVENTS:
0608:                    // no data
0609:                    break;
0610:                case JdwpCommandPacket.VM_CAPABILITIES_NEW:
0611:                    printVmCapabilitiesNewReply(in);
0612:                    break;
0613:                case JdwpCommandPacket.VM_REDEFINE_CLASSES:
0614:                    // no data
0615:                    break;
0616:                case JdwpCommandPacket.VM_SET_DEFAULT_STRATUM:
0617:                    // no data
0618:                    break;
0619:                case JdwpCommandPacket.VM_ALL_CLASSES_WITH_GENERIC:
0620:                    printVmAllClassesWithGenericReply(in);
0621:                    break;
0622:
0623:                /** Commands ReferenceType. */
0624:                case JdwpCommandPacket.RT_SIGNATURE:
0625:                    printRtSignatureReply(in);
0626:                    break;
0627:                case JdwpCommandPacket.RT_CLASS_LOADER:
0628:                    printRtClassLoaderReply(in);
0629:                    break;
0630:                case JdwpCommandPacket.RT_MODIFIERS:
0631:                    printRtModifiersReply(in);
0632:                    break;
0633:                case JdwpCommandPacket.RT_FIELDS:
0634:                    printRtFieldsReply(in);
0635:                    break;
0636:                case JdwpCommandPacket.RT_METHODS:
0637:                    printRtMethodsReply(in);
0638:                    break;
0639:                case JdwpCommandPacket.RT_GET_VALUES:
0640:                    printRtGetValuesReply(in);
0641:                    break;
0642:                case JdwpCommandPacket.RT_SOURCE_FILE:
0643:                    printRtSourceFileReply(in);
0644:                    break;
0645:                case JdwpCommandPacket.RT_NESTED_TYPES:
0646:                    printRtNestedTypesReply(in);
0647:                    break;
0648:                case JdwpCommandPacket.RT_STATUS:
0649:                    printRtStatusReply(in);
0650:                    break;
0651:                case JdwpCommandPacket.RT_INTERFACES:
0652:                    printRtInterfacesReply(in);
0653:                    break;
0654:                case JdwpCommandPacket.RT_CLASS_OBJECT:
0655:                    printRtClassObjectReply(in);
0656:                    break;
0657:                case JdwpCommandPacket.RT_SOURCE_DEBUG_EXTENSION:
0658:                    printRtSourceDebugExtensionReply(in);
0659:                    break;
0660:                case JdwpCommandPacket.RT_SIGNATURE_WITH_GENERIC:
0661:                    printRtSignatureWithGenericReply(in);
0662:                    break;
0663:                case JdwpCommandPacket.RT_FIELDS_WITH_GENERIC:
0664:                    printRtFieldsWithGenericReply(in);
0665:                    break;
0666:                case JdwpCommandPacket.RT_METHODS_WITH_GENERIC:
0667:                    printRtMethodsWithGenericReply(in);
0668:                    break;
0669:
0670:                /** Commands ClassType. */
0671:                case JdwpCommandPacket.CT_SUPERCLASS:
0672:                    printCtSuperclassReply(in);
0673:                    break;
0674:                case JdwpCommandPacket.CT_SET_VALUES:
0675:                    // no data
0676:                    break;
0677:                case JdwpCommandPacket.CT_INVOKE_METHOD:
0678:                    printCtInvokeMethodReply(in);
0679:                    break;
0680:                case JdwpCommandPacket.CT_NEW_INSTANCE:
0681:                    printCtNewInstanceReply(in);
0682:                    break;
0683:
0684:                /** Commands ArrayType. */
0685:                case JdwpCommandPacket.AT_NEW_INSTANCE:
0686:                    printAtNewInstanceReply(in);
0687:                    break;
0688:
0689:                /** Commands Method. */
0690:                case JdwpCommandPacket.M_LINE_TABLE:
0691:                    printMLineTableReply(in);
0692:                    break;
0693:                case JdwpCommandPacket.M_VARIABLE_TABLE:
0694:                    printMVariableTableReply(in);
0695:                    break;
0696:                case JdwpCommandPacket.M_BYTECODES:
0697:                    printMBytecodesReply(in);
0698:                    break;
0699:                case JdwpCommandPacket.M_IS_OBSOLETE:
0700:                    printMIsObsoleteReply(in);
0701:                    break;
0702:                case JdwpCommandPacket.M_VARIABLE_TABLE_WITH_GENERIC:
0703:                    printMVariableTableWithGenericReply(in);
0704:                    break;
0705:
0706:                /** Commands ObjectReference. */
0707:                case JdwpCommandPacket.OR_REFERENCE_TYPE:
0708:                    printOrReferenceTypeReply(in);
0709:                    break;
0710:                case JdwpCommandPacket.OR_GET_VALUES:
0711:                    printOrGetValuesReply(in);
0712:                    break;
0713:                case JdwpCommandPacket.OR_SET_VALUES:
0714:                    // no data
0715:                    break;
0716:                case JdwpCommandPacket.OR_MONITOR_INFO:
0717:                    printOrMonitorInfoReply(in);
0718:                    break;
0719:                case JdwpCommandPacket.OR_INVOKE_METHOD:
0720:                    printOrInvokeMethodReply(in);
0721:                    break;
0722:                case JdwpCommandPacket.OR_DISABLE_COLLECTION:
0723:                    // no data
0724:                    break;
0725:                case JdwpCommandPacket.OR_ENABLE_COLLECTION:
0726:                    // no data
0727:                    break;
0728:                case JdwpCommandPacket.OR_IS_COLLECTED:
0729:                    printOrIsCollectedReply(in);
0730:                    break;
0731:
0732:                /** Commands StringReference. */
0733:                case JdwpCommandPacket.SR_VALUE:
0734:                    printSrValueReply(in);
0735:                    break;
0736:
0737:                /** Commands ThreadReference. */
0738:                case JdwpCommandPacket.TR_NAME:
0739:                    printTrNameReply(in);
0740:                    break;
0741:                case JdwpCommandPacket.TR_SUSPEND:
0742:                    // no data
0743:                    break;
0744:                case JdwpCommandPacket.TR_RESUME:
0745:                    // no data
0746:                    break;
0747:                case JdwpCommandPacket.TR_STATUS:
0748:                    printTrStatusReply(in);
0749:                    break;
0750:                case JdwpCommandPacket.TR_THREAD_GROUP:
0751:                    printTrThreadGroupReply(in);
0752:                    break;
0753:                case JdwpCommandPacket.TR_FRAMES:
0754:                    printTrFramesReply(in);
0755:                    break;
0756:                case JdwpCommandPacket.TR_FRAME_COUNT:
0757:                    printTrFrameCountReply(in);
0758:                    break;
0759:                case JdwpCommandPacket.TR_OWNED_MONITORS:
0760:                    printTrOwnedMonitorsReply(in);
0761:                    break;
0762:                case JdwpCommandPacket.TR_CURRENT_CONTENDED_MONITOR:
0763:                    printTrCurrentContendedMonitorReply(in);
0764:                    break;
0765:                case JdwpCommandPacket.TR_STOP:
0766:                    // no data
0767:                    break;
0768:                case JdwpCommandPacket.TR_INTERRUPT:
0769:                    // no data
0770:                    break;
0771:                case JdwpCommandPacket.TR_SUSPEND_COUNT:
0772:                    printTrSuspendCountReply(in);
0773:                    break;
0774:                /* no more in the jdwp spec
0775:                 case JdwpCommandPacket.TR_POP_TOP_FRAME:
0776:                 break;
0777:                 */
0778:                /** Commands ThreadGroupReference. */
0779:                case JdwpCommandPacket.TGR_NAME:
0780:                    printTgrNameReply(in);
0781:                    break;
0782:                case JdwpCommandPacket.TGR_PARENT:
0783:                    printTgrParentReply(in);
0784:                    break;
0785:                case JdwpCommandPacket.TGR_CHILDREN:
0786:                    printTgrChildrenReply(in);
0787:                    break;
0788:
0789:                /** Commands ArrayReference. */
0790:                case JdwpCommandPacket.AR_LENGTH:
0791:                    printArLengthReply(in);
0792:                    break;
0793:                case JdwpCommandPacket.AR_GET_VALUES:
0794:                    printArGetValuesReply(in);
0795:                    break;
0796:                case JdwpCommandPacket.AR_SET_VALUES:
0797:                    // no data
0798:                    break;
0799:
0800:                /** Commands ClassLoaderReference. */
0801:                case JdwpCommandPacket.CLR_VISIBLE_CLASSES:
0802:                    printClrVisibleClassesReply(in);
0803:                    break;
0804:
0805:                /** Commands EventRequest. */
0806:                case JdwpCommandPacket.ER_SET:
0807:                    printErSetReply(in);
0808:                    break;
0809:                case JdwpCommandPacket.ER_CLEAR:
0810:                    // no data
0811:                    break;
0812:                case JdwpCommandPacket.ER_CLEAR_ALL_BREAKPOINTS:
0813:                    // no data
0814:                    break;
0815:
0816:                /** Commands StackFrame. */
0817:                case JdwpCommandPacket.SF_GET_VALUES:
0818:                    printSfGetValuesReply(in);
0819:                    break;
0820:                case JdwpCommandPacket.SF_SET_VALUES:
0821:                    // no data
0822:                    break;
0823:                case JdwpCommandPacket.SF_THIS_OBJECT:
0824:                    printSfThisObjectReply(in);
0825:                    break;
0826:                case JdwpCommandPacket.SF_POP_FRAME:
0827:                    // no data
0828:                    break;
0829:
0830:                /** Commands ClassObjectReference. */
0831:                case JdwpCommandPacket.COR_REFLECTED_TYPE:
0832:                    printCorReflectedTypeReply(in);
0833:                    break;
0834:
0835:                /** Commands Event. */
0836:                /* no reply
0837:                 case JdwpCommandPacket.E_COMPOSITE:
0838:                 break;*/
0839:
0840:                /** Commands Hot Code Replacement (OTI specific). */
0841:                case JdwpCommandPacket.HCR_CLASSES_HAVE_CHANGED:
0842:                case JdwpCommandPacket.HCR_GET_CLASS_VERSION:
0843:                case JdwpCommandPacket.HCR_DO_RETURN:
0844:                case JdwpCommandPacket.HCR_REENTER_ON_EXIT:
0845:                case JdwpCommandPacket.HCR_CAPABILITIES:
0846:                    throw new UnableToParseDataException(
0847:                            "NOT MANAGED COMMAND", remainderData(in)); //$NON-NLS-1$
0848:
0849:                default:
0850:                    int cset = commandId >> 8;
0851:                    int cmd = commandId & 0xFF;
0852:                    println(MessageFormat
0853:                            .format(
0854:                                    "Unknown command : {0} {1}", new String[] { "" + cset, "" + cmd })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
0855:                    break;
0856:                }
0857:            }
0858:
0859:            private void printRefTypeTag(byte refTypeTag) {
0860:                printDescription("Type tag:"); //$NON-NLS-1$
0861:                printRefTypeTagValue(refTypeTag);
0862:                println();
0863:            }
0864:
0865:            private void printRefTypeTagValue(byte refTypeTag) {
0866:                printHex(refTypeTag);
0867:                print(" ("); //$NON-NLS-1$
0868:                switch (refTypeTag) {
0869:                case TYPE_TAG_CLASS:
0870:                    print("CLASS"); //$NON-NLS-1$
0871:                    break;
0872:                case TYPE_TAG_INTERFACE:
0873:                    print("INTERFACE"); //$NON-NLS-1$
0874:                    break;
0875:                case TYPE_TAG_ARRAY:
0876:                    print("ARRAY"); //$NON-NLS-1$
0877:                    break;
0878:                default:
0879:                    print("unknown"); //$NON-NLS-1$
0880:                }
0881:                print(')');
0882:            }
0883:
0884:            private void printClassStatus(int status) {
0885:                printDescription("Status:"); //$NON-NLS-1$
0886:                printHex(status);
0887:                print(" ("); //$NON-NLS-1$
0888:                boolean spaceNeeded = false;
0889:                if ((status & JDWP_CLASS_STATUS_VERIFIED) != 0) {
0890:                    print("VERIFIED"); //$NON-NLS-1$
0891:                    spaceNeeded = true;
0892:                }
0893:                if ((status & JDWP_CLASS_STATUS_PREPARED) != 0) {
0894:                    if (spaceNeeded) {
0895:                        print(' ');
0896:                    } else {
0897:                        spaceNeeded = true;
0898:                    }
0899:                    print("PREPARED"); //$NON-NLS-1$
0900:                }
0901:                if ((status & JDWP_CLASS_STATUS_INITIALIZED) != 0) {
0902:                    if (spaceNeeded) {
0903:                        print(' ');
0904:                    } else {
0905:                        spaceNeeded = true;
0906:                    }
0907:                    print("INITIALIZED"); //$NON-NLS-1$
0908:                }
0909:                if ((status & JDWP_CLASS_STATUS_ERROR) != 0) {
0910:                    if (spaceNeeded) {
0911:                        print(' ');
0912:                    }
0913:                    print("unknown"); //$NON-NLS-1$
0914:                }
0915:                println(')');
0916:            }
0917:
0918:            private void printClassModifiers(int modifiers) {
0919:                printDescription("Modifiers:"); //$NON-NLS-1$
0920:                printHex(modifiers);
0921:                print(" ("); //$NON-NLS-1$
0922:                boolean spaceNeeded = false;
0923:                if ((modifiers & ACC_PUBLIC) != 0) {
0924:                    print("PUBLIC"); //$NON-NLS-1$
0925:                    spaceNeeded = true;
0926:                }
0927:                if ((modifiers & ACC_PRIVATE) != 0) {
0928:                    if (spaceNeeded) {
0929:                        print(' ');
0930:                    } else {
0931:                        spaceNeeded = true;
0932:                    }
0933:                    print("PRIVATE"); //$NON-NLS-1$
0934:                }
0935:                if ((modifiers & ACC_PROTECTED) != 0) {
0936:                    if (spaceNeeded) {
0937:                        print(' ');
0938:                    } else {
0939:                        spaceNeeded = true;
0940:                    }
0941:                    print("PROTECTED"); //$NON-NLS-1$
0942:                }
0943:                if ((modifiers & ACC_STATIC) != 0) {
0944:                    if (spaceNeeded) {
0945:                        print(' ');
0946:                    } else {
0947:                        spaceNeeded = true;
0948:                    }
0949:                    print("STATIC"); //$NON-NLS-1$
0950:                }
0951:                if ((modifiers & ACC_FINAL) != 0) {
0952:                    if (spaceNeeded) {
0953:                        print(' ');
0954:                    } else {
0955:                        spaceNeeded = true;
0956:                    }
0957:                    print("FINAL"); //$NON-NLS-1$
0958:                }
0959:                if ((modifiers & ACC_SUPER) != 0) {
0960:                    if (spaceNeeded) {
0961:                        print(' ');
0962:                    } else {
0963:                        spaceNeeded = true;
0964:                    }
0965:                    print("SUPER"); //$NON-NLS-1$
0966:                }
0967:                if ((modifiers & ACC_INTERFACE) != 0) {
0968:                    if (spaceNeeded) {
0969:                        print(' ');
0970:                    } else {
0971:                        spaceNeeded = true;
0972:                    }
0973:                    print("INTERFACE"); //$NON-NLS-1$
0974:                }
0975:                if ((modifiers & ACC_ABSTRACT) != 0) {
0976:                    if (spaceNeeded) {
0977:                        print(' ');
0978:                    } else {
0979:                        spaceNeeded = true;
0980:                    }
0981:                    print("ABSTRACT"); //$NON-NLS-1$
0982:                }
0983:                if ((modifiers & (ACC_EXT_SYNTHETIC | ACC_SYNTHETIC)) != 0) {
0984:                    if (spaceNeeded) {
0985:                        print(' ');
0986:                    } else {
0987:                        spaceNeeded = true;
0988:                    }
0989:                    print("SYNTHETIC"); //$NON-NLS-1$
0990:                }
0991:                println(')');
0992:            }
0993:
0994:            private void printMethodModifiers(int modifiers) {
0995:                printDescription("Modifiers:"); //$NON-NLS-1$
0996:                printHex(modifiers);
0997:                print(" ("); //$NON-NLS-1$
0998:                boolean spaceNeeded = false;
0999:                if ((modifiers & ACC_PUBLIC) != 0) {
1000:                    print("PUBLIC"); //$NON-NLS-1$
1001:                    spaceNeeded = true;
1002:                }
1003:                if ((modifiers & ACC_PRIVATE) != 0) {
1004:                    if (spaceNeeded) {
1005:                        print(' ');
1006:                    } else {
1007:                        spaceNeeded = true;
1008:                    }
1009:                    print("PRIVATE"); //$NON-NLS-1$
1010:                }
1011:                if ((modifiers & ACC_PROTECTED) != 0) {
1012:                    if (spaceNeeded) {
1013:                        print(' ');
1014:                    } else {
1015:                        spaceNeeded = true;
1016:                    }
1017:                    print("PROTECTED"); //$NON-NLS-1$
1018:                }
1019:                if ((modifiers & ACC_STATIC) != 0) {
1020:                    if (spaceNeeded) {
1021:                        print(' ');
1022:                    } else {
1023:                        spaceNeeded = true;
1024:                    }
1025:                    print("STATIC"); //$NON-NLS-1$
1026:                }
1027:                if ((modifiers & ACC_FINAL) != 0) {
1028:                    if (spaceNeeded) {
1029:                        print(' ');
1030:                    } else {
1031:                        spaceNeeded = true;
1032:                    }
1033:                    print("FINAL"); //$NON-NLS-1$
1034:                }
1035:                if ((modifiers & ACC_SYNCHRONIZED) != 0) {
1036:                    if (spaceNeeded) {
1037:                        print(' ');
1038:                    } else {
1039:                        spaceNeeded = true;
1040:                    }
1041:                    print("SYNCHRONIZED"); //$NON-NLS-1$
1042:                }
1043:                if ((modifiers & ACC_BRIDGE) != 0) {
1044:                    if (spaceNeeded) {
1045:                        print(' ');
1046:                    } else {
1047:                        spaceNeeded = true;
1048:                    }
1049:                    print("BRIDGE"); //$NON-NLS-1$
1050:                }
1051:                if ((modifiers & ACC_VARARGS) != 0) {
1052:                    if (spaceNeeded) {
1053:                        print(' ');
1054:                    } else {
1055:                        spaceNeeded = true;
1056:                    }
1057:                    print("VARARGS"); //$NON-NLS-1$
1058:                }
1059:                if ((modifiers & ACC_NATIVE) != 0) {
1060:                    if (spaceNeeded) {
1061:                        print(' ');
1062:                    } else {
1063:                        spaceNeeded = true;
1064:                    }
1065:                    print("NATIVE"); //$NON-NLS-1$
1066:                }
1067:                if ((modifiers & ACC_ABSTRACT) != 0) {
1068:                    if (spaceNeeded) {
1069:                        print(' ');
1070:                    } else {
1071:                        spaceNeeded = true;
1072:                    }
1073:                    print("ABSTRACT"); //$NON-NLS-1$
1074:                }
1075:                if ((modifiers & ACC_STRICT) != 0) {
1076:                    if (spaceNeeded) {
1077:                        print(' ');
1078:                    } else {
1079:                        spaceNeeded = true;
1080:                    }
1081:                    print("STRICT"); //$NON-NLS-1$
1082:                }
1083:                if ((modifiers & (ACC_EXT_SYNTHETIC | ACC_SYNTHETIC)) != 0) {
1084:                    if (spaceNeeded) {
1085:                        print(' ');
1086:                    } else {
1087:                        spaceNeeded = true;
1088:                    }
1089:                    print("SYNTHETIC"); //$NON-NLS-1$
1090:                }
1091:                println(')');
1092:            }
1093:
1094:            private void printFieldModifiers(int modifiers) {
1095:                printDescription("Modifiers:"); //$NON-NLS-1$
1096:                printHex(modifiers);
1097:                print(" ("); //$NON-NLS-1$
1098:                boolean spaceNeeded = false;
1099:                if ((modifiers & ACC_PUBLIC) != 0) {
1100:                    print("PUBLIC"); //$NON-NLS-1$
1101:                    spaceNeeded = true;
1102:                }
1103:                if ((modifiers & ACC_PRIVATE) != 0) {
1104:                    if (spaceNeeded) {
1105:                        print(' ');
1106:                    } else {
1107:                        spaceNeeded = true;
1108:                    }
1109:                    print("PRIVATE"); //$NON-NLS-1$
1110:                }
1111:                if ((modifiers & ACC_PROTECTED) != 0) {
1112:                    if (spaceNeeded) {
1113:                        print(' ');
1114:                    } else {
1115:                        spaceNeeded = true;
1116:                    }
1117:                    print("PROTECTED"); //$NON-NLS-1$
1118:                }
1119:                if ((modifiers & ACC_STATIC) != 0) {
1120:                    if (spaceNeeded) {
1121:                        print(' ');
1122:                    } else {
1123:                        spaceNeeded = true;
1124:                    }
1125:                    print("STATIC"); //$NON-NLS-1$
1126:                }
1127:                if ((modifiers & ACC_FINAL) != 0) {
1128:                    if (spaceNeeded) {
1129:                        print(' ');
1130:                    } else {
1131:                        spaceNeeded = true;
1132:                    }
1133:                    print("FINAL"); //$NON-NLS-1$
1134:                }
1135:                if ((modifiers & ACC_VOLATILE) != 0) {
1136:                    if (spaceNeeded) {
1137:                        print(' ');
1138:                    } else {
1139:                        spaceNeeded = true;
1140:                    }
1141:                    print("VOLATILE"); //$NON-NLS-1$
1142:                }
1143:                if ((modifiers & ACC_TRANSIENT) != 0) {
1144:                    if (spaceNeeded) {
1145:                        print(' ');
1146:                    } else {
1147:                        spaceNeeded = true;
1148:                    }
1149:                    print("TRANSIENT"); //$NON-NLS-1$
1150:                }
1151:                if ((modifiers & ACC_ENUM) != 0) {
1152:                    if (spaceNeeded) {
1153:                        print(' ');
1154:                    } else {
1155:                        spaceNeeded = true;
1156:                    }
1157:                    print("ENUM"); //$NON-NLS-1$
1158:                }
1159:                if ((modifiers & (ACC_EXT_SYNTHETIC | ACC_SYNTHETIC)) != 0) {
1160:                    if (spaceNeeded) {
1161:                        print(' ');
1162:                    } else {
1163:                        spaceNeeded = true;
1164:                    }
1165:                    print("SYNTHETIC"); //$NON-NLS-1$
1166:                }
1167:                println(')');
1168:            }
1169:
1170:            private void printInvocationOptions(int invocationOptions) {
1171:                printDescription("Invocation Options:"); //$NON-NLS-1$
1172:                printHex(invocationOptions);
1173:                print(" ("); //$NON-NLS-1$
1174:                boolean spaceNeeded = false;
1175:                if ((invocationOptions & INVOKE_SINGLE_THREADED) != 0) {
1176:                    print("SINGLE_THREADED"); //$NON-NLS-1$
1177:                    spaceNeeded = true;
1178:                }
1179:                if ((invocationOptions & INVOKE_NONVIRTUAL) != 0) {
1180:                    if (spaceNeeded) {
1181:                        print(' ');
1182:                    }
1183:                    print("NONVIRTUAL"); //$NON-NLS-1$
1184:                }
1185:                println(')');
1186:            }
1187:
1188:            private void printThreadStatus(int threadStatus) {
1189:                printDescription("Thread status:"); //$NON-NLS-1$
1190:                printHex(threadStatus);
1191:                print(" ("); //$NON-NLS-1$
1192:                switch (threadStatus) {
1193:                case THREAD_STATUS_ZOMBIE:
1194:                    print("ZOMBIE"); //$NON-NLS-1$
1195:                    break;
1196:                case THREAD_STATUS_RUNNING:
1197:                    print("RUNNING"); //$NON-NLS-1$
1198:                    break;
1199:                case THREAD_STATUS_SLEEPING:
1200:                    print("SLEEPING"); //$NON-NLS-1$
1201:                    break;
1202:                case THREAD_STATUS_MONITOR:
1203:                    print("MONITOR"); //$NON-NLS-1$
1204:                    break;
1205:                case THREAD_STATUS_WAIT:
1206:                    print("WAIT"); //$NON-NLS-1$
1207:                    break;
1208:                default:
1209:                    print("unknown"); //$NON-NLS-1$
1210:                    break;
1211:                }
1212:                println(')');
1213:            }
1214:
1215:            private void printSuspendStatus(int suspendStatus) {
1216:                printDescription("Suspend status:"); //$NON-NLS-1$
1217:                printHex(suspendStatus);
1218:                print(" ("); //$NON-NLS-1$
1219:                if ((suspendStatus & SUSPEND_STATUS_SUSPENDED) != 0) {
1220:                    print("SUSPENDED"); //$NON-NLS-1$
1221:                }
1222:                println(')');
1223:            }
1224:
1225:            private void printEventKind(byte eventKind) {
1226:                printDescription("Event kind:"); //$NON-NLS-1$
1227:                printHex(eventKind);
1228:                print(" ("); //$NON-NLS-1$
1229:                switch (eventKind) {
1230:                case EVENTKIND_SINGLE_STEP:
1231:                    print("SINGLE_STEP"); //$NON-NLS-1$
1232:                    break;
1233:                case EVENTKIND_BREAKPOINT:
1234:                    print("BREAKPOINT"); //$NON-NLS-1$
1235:                    break;
1236:                case EVENTKIND_FRAME_POP:
1237:                    print("FRAME_POP"); //$NON-NLS-1$
1238:                    break;
1239:                case EVENTKIND_EXCEPTION:
1240:                    print("EXCEPTION"); //$NON-NLS-1$
1241:                    break;
1242:                case EVENTKIND_USER_DEFINED:
1243:                    print("USER_DEFINED"); //$NON-NLS-1$
1244:                    break;
1245:                case EVENTKIND_THREAD_START:
1246:                    print("THREAD_START"); //$NON-NLS-1$
1247:                    break;
1248:                case EVENTKIND_THREAD_END:
1249:                    print("THREAD_END"); //$NON-NLS-1$
1250:                    break;
1251:                case EVENTKIND_CLASS_PREPARE:
1252:                    print("CLASS_PREPARE"); //$NON-NLS-1$
1253:                    break;
1254:                case EVENTKIND_CLASS_UNLOAD:
1255:                    print("CLASS_UNLOAD"); //$NON-NLS-1$
1256:                    break;
1257:                case EVENTKIND_CLASS_LOAD:
1258:                    print("CLASS_LOAD"); //$NON-NLS-1$
1259:                    break;
1260:                case EVENTKIND_FIELD_ACCESS:
1261:                    print("FIELD_ACCESS"); //$NON-NLS-1$
1262:                    break;
1263:                case EVENTKIND_FIELD_MODIFICATION:
1264:                    print("FIELD_MODIFICATION"); //$NON-NLS-1$
1265:                    break;
1266:                case EVENTKIND_EXCEPTION_CATCH:
1267:                    print("EXCEPTION_CATCH"); //$NON-NLS-1$
1268:                    break;
1269:                case EVENTKIND_METHOD_ENTRY:
1270:                    print("METHOD_ENTRY"); //$NON-NLS-1$
1271:                    break;
1272:                case EVENTKIND_METHOD_EXIT:
1273:                    print("METHOD_EXIT"); //$NON-NLS-1$
1274:                    break;
1275:                case EVENTKIND_VM_INIT:
1276:                    print("VM_INIT"); //$NON-NLS-1$
1277:                    break;
1278:                case EVENTKIND_VM_DEATH:
1279:                    print("VM_DEATH"); //$NON-NLS-1$
1280:                    break;
1281:                case EVENTKIND_VM_DISCONNECTED:
1282:                    print("VM_DISCONNECTED"); //$NON-NLS-1$
1283:                    break;
1284:                default:
1285:                    print("unknown"); //$NON-NLS-1$
1286:                    break;
1287:                }
1288:                println(')');
1289:            }
1290:
1291:            private void printSuspendPolicy(byte suspendPolicy) {
1292:                printDescription("Suspend policy:"); //$NON-NLS-1$
1293:                printHex(suspendPolicy);
1294:                print(" ("); //$NON-NLS-1$
1295:                switch (suspendPolicy) {
1296:                case SUSPENDPOLICY_NONE:
1297:                    print("NONE"); //$NON-NLS-1$
1298:                    break;
1299:                case SUSPENDPOLICY_EVENT_THREAD:
1300:                    print("EVENT_THREAD"); //$NON-NLS-1$
1301:                    break;
1302:                case SUSPENDPOLICY_ALL:
1303:                    print("ALL"); //$NON-NLS-1$
1304:                    break;
1305:                default:
1306:                    print("unknown"); //$NON-NLS-1$
1307:                    break;
1308:                }
1309:                println(')');
1310:            }
1311:
1312:            private void printStepDepth(int setDepth) {
1313:                printDescription("Step depth:"); //$NON-NLS-1$
1314:                printHex(setDepth);
1315:                print(" ("); //$NON-NLS-1$
1316:                switch (setDepth) {
1317:                case STEPDEPTH_INTO:
1318:                    print("INTO"); //$NON-NLS-1$
1319:                    break;
1320:                case STEPDEPTH_OVER:
1321:                    print("OVER"); //$NON-NLS-1$
1322:                    break;
1323:                case STEPDEPTH_OUT:
1324:                    print("OUT"); //$NON-NLS-1$
1325:                    break;
1326:                default:
1327:                    print("unknown"); //$NON-NLS-1$
1328:                    break;
1329:                }
1330:                println(')');
1331:            }
1332:
1333:            private void printStepSize(int setSize) {
1334:                printDescription("Step size:"); //$NON-NLS-1$
1335:                printHex(setSize);
1336:                print(" ("); //$NON-NLS-1$
1337:                switch (setSize) {
1338:                case STEPSIZE_MIN:
1339:                    print("MIN"); //$NON-NLS-1$
1340:                    break;
1341:                case STEPSIZE_LINE:
1342:                    print("LINE"); //$NON-NLS-1$
1343:                    break;
1344:                default:
1345:                    print("unknown"); //$NON-NLS-1$
1346:                    break;
1347:                }
1348:                println(')');
1349:            }
1350:
1351:            private void printVmVersionReply(DataInputStream in)
1352:                    throws IOException {
1353:                String description = readString(in);
1354:                int jdwpMajor = in.readInt();
1355:                int jdwpMinor = in.readInt();
1356:                String vmVersion = readString(in);
1357:                String vmName = readString(in);
1358:
1359:                println("VM Description:", description); //$NON-NLS-1$
1360:                println("JDWP Major Version:", jdwpMajor); //$NON-NLS-1$
1361:                println("JDWP Minor Version:", jdwpMinor); //$NON-NLS-1$
1362:                println("VM Version:", vmVersion); //$NON-NLS-1$
1363:                println("VM Name:", vmName); //$NON-NLS-1$
1364:            }
1365:
1366:            private void printVmClassesBySignatureCommand(DataInputStream in)
1367:                    throws IOException {
1368:                String signature = readString(in);
1369:                println("Class signature:", signature); //$NON-NLS-1$
1370:            }
1371:
1372:            private void printVmClassesBySignatureReply(DataInputStream in)
1373:                    throws IOException, UnableToParseDataException {
1374:                int classesCount = in.readInt();
1375:                println("Classes count:", classesCount); //$NON-NLS-1$
1376:                for (int i = 0; i < classesCount; i++) {
1377:                    byte refTypeTag = in.readByte();
1378:                    long typeId = readReferenceTypeID(in);
1379:                    int status = in.readInt();
1380:                    printRefTypeTag(refTypeTag);
1381:                    printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
1382:                    printClassStatus(status);
1383:                }
1384:            }
1385:
1386:            private void printVmAllClassesReply(DataInputStream in)
1387:                    throws IOException, UnableToParseDataException {
1388:                int classesCount = in.readInt();
1389:                println("Classes count:", classesCount); //$NON-NLS-1$
1390:                for (int i = 0; i < classesCount; i++) {
1391:                    byte refTypeTag = in.readByte();
1392:                    long typeId = readReferenceTypeID(in);
1393:                    String signature = readString(in);
1394:                    int status = in.readInt();
1395:                    printRefTypeTag(refTypeTag);
1396:                    printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
1397:                    println("Class signature:", signature); //$NON-NLS-1$
1398:                    printClassStatus(status);
1399:                }
1400:            }
1401:
1402:            private void printVmAllThreadsReply(DataInputStream in)
1403:                    throws IOException, UnableToParseDataException {
1404:                int threadsCount = in.readInt();
1405:                println("Threads count:", threadsCount); //$NON-NLS-1$
1406:                for (int i = 0; i < threadsCount; i++) {
1407:                    long threadId = readObjectID(in);
1408:                    printlnObjectId("Thread id:", threadId); //$NON-NLS-1$
1409:                }
1410:            }
1411:
1412:            private void printVmTopLevelThreadGroupReply(DataInputStream in)
1413:                    throws IOException, UnableToParseDataException {
1414:                int groupsCount = in.readInt();
1415:                println("Threads count:", groupsCount); //$NON-NLS-1$
1416:                for (int i = 0; i < groupsCount; i++) {
1417:                    long threadGroupId = readObjectID(in);
1418:                    printlnObjectId("Thread id:", threadGroupId); //$NON-NLS-1$
1419:                }
1420:            }
1421:
1422:            private void printVmIdSizesReply(DataInputStream in)
1423:                    throws IOException {
1424:                int fieldIDSize = in.readInt();
1425:                int methodIDSize = in.readInt();
1426:                int objectIDSize = in.readInt();
1427:                int referenceTypeIDSize = in.readInt();
1428:                int frameIDSize = in.readInt();
1429:                println("Field ID size:", fieldIDSize); //$NON-NLS-1$
1430:                println("Method ID size:", methodIDSize); //$NON-NLS-1$
1431:                println("Object ID size:", objectIDSize); //$NON-NLS-1$
1432:                println("Reference type ID size:", referenceTypeIDSize); //$NON-NLS-1$
1433:                println("Frame ID size:", frameIDSize); //$NON-NLS-1$
1434:                TcpipSpy.setFieldIDSize(fieldIDSize);
1435:                TcpipSpy.setMethodIDSize(methodIDSize);
1436:                TcpipSpy.setObjectIDSize(objectIDSize);
1437:                TcpipSpy.setReferenceTypeIDSize(referenceTypeIDSize);
1438:                TcpipSpy.setFrameIDSize(frameIDSize);
1439:                TcpipSpy.setHasSizes(true);
1440:            }
1441:
1442:            private void printVmExitCommand(DataInputStream in)
1443:                    throws IOException {
1444:                int exitCode = in.readInt();
1445:                println("Exit code:", exitCode); //$NON-NLS-1$
1446:            }
1447:
1448:            private void printVmCreateStringCommand(DataInputStream in)
1449:                    throws IOException {
1450:                String string = readString(in);
1451:                println("String:", string); //$NON-NLS-1$
1452:            }
1453:
1454:            private void printVmCreateStringReply(DataInputStream in)
1455:                    throws IOException, UnableToParseDataException {
1456:                long stringId = readObjectID(in);
1457:                printlnObjectId("String id:", stringId); //$NON-NLS-1$
1458:            }
1459:
1460:            private void printVmCapabilitiesReply(DataInputStream in)
1461:                    throws IOException {
1462:                boolean canWatchFieldModification = in.readBoolean();
1463:                boolean canWatchFieldAccess = in.readBoolean();
1464:                boolean canGetBytecodes = in.readBoolean();
1465:                boolean canGetSyntheticAttribute = in.readBoolean();
1466:                boolean canGetOwnedMonitorInfo = in.readBoolean();
1467:                boolean canGetCurrentContendedMonitor = in.readBoolean();
1468:                boolean canGetMonitorInfo = in.readBoolean();
1469:                println(
1470:                        "Can watch field modification:", canWatchFieldModification); //$NON-NLS-1$
1471:                println("can watch field access:", canWatchFieldAccess); //$NON-NLS-1$
1472:                println("Can get bytecodes:", canGetBytecodes); //$NON-NLS-1$
1473:                println(
1474:                        "Can get synthetic attribute:", canGetSyntheticAttribute); //$NON-NLS-1$
1475:                println("Can get owned monitor info:", canGetOwnedMonitorInfo); //$NON-NLS-1$
1476:                println(
1477:                        "Can get currently contended monitor:", canGetCurrentContendedMonitor); //$NON-NLS-1$
1478:                println("Can get monitor info:", canGetMonitorInfo); //$NON-NLS-1$
1479:            }
1480:
1481:            private void printVmClassPathsReply(DataInputStream in)
1482:                    throws IOException {
1483:                String baseDir = readString(in);
1484:                println("Base directory:", baseDir); //$NON-NLS-1$
1485:                int classpathCount = in.readInt();
1486:                println("Classpaths count:", classpathCount); //$NON-NLS-1$
1487:                for (int i = 0; i < classpathCount; i++) {
1488:                    String path = readString(in);
1489:                    println("Classpath:", path); //$NON-NLS-1$
1490:                }
1491:                int bootclasspathCount = in.readInt();
1492:                println("Bootclasspaths count:", bootclasspathCount); //$NON-NLS-1$
1493:                for (int i = 0; i < bootclasspathCount; i++) {
1494:                    String path = readString(in);
1495:                    println("Bootclasspath:", path); //$NON-NLS-1$
1496:                }
1497:            }
1498:
1499:            private void printVmDisposeObjectsCommand(DataInputStream in)
1500:                    throws IOException, UnableToParseDataException {
1501:                int requestsCount = in.readInt();
1502:                println("Requests Count:", requestsCount); //$NON-NLS-1$
1503:                for (int i = 0; i < requestsCount; i++) {
1504:                    long objectId = readObjectID(in);
1505:                    int refsCounts = in.readInt();
1506:                    printlnObjectId("Object id:", objectId); //$NON-NLS-1$
1507:                    println("References count:", refsCounts); //$NON-NLS-1$
1508:                }
1509:            }
1510:
1511:            private void printVmCapabilitiesNewReply(DataInputStream in)
1512:                    throws IOException {
1513:                printVmCapabilitiesReply(in);
1514:                boolean canRedefineClasses = in.readBoolean();
1515:                boolean canAddMethod = in.readBoolean();
1516:                boolean canUnrestrictedlyRedefineClasses = in.readBoolean();
1517:                boolean canPopFrames = in.readBoolean();
1518:                boolean canUseInstanceFilters = in.readBoolean();
1519:                boolean canGetSourceDebugExtension = in.readBoolean();
1520:                boolean canRequestVMDeathEvent = in.readBoolean();
1521:                boolean canSetDefaultStratum = in.readBoolean();
1522:                boolean reserved16 = in.readBoolean();
1523:                boolean reserved17 = in.readBoolean();
1524:                boolean reserved18 = in.readBoolean();
1525:                boolean reserved19 = in.readBoolean();
1526:                boolean reserved20 = in.readBoolean();
1527:                boolean reserved21 = in.readBoolean();
1528:                boolean reserved22 = in.readBoolean();
1529:                boolean reserved23 = in.readBoolean();
1530:                boolean reserved24 = in.readBoolean();
1531:                boolean reserved25 = in.readBoolean();
1532:                boolean reserved26 = in.readBoolean();
1533:                boolean reserved27 = in.readBoolean();
1534:                boolean reserved28 = in.readBoolean();
1535:                boolean reserved29 = in.readBoolean();
1536:                boolean reserved30 = in.readBoolean();
1537:                boolean reserved31 = in.readBoolean();
1538:                boolean reserved32 = in.readBoolean();
1539:                println("Can redefine classes:", canRedefineClasses); //$NON-NLS-1$
1540:                println("Can add method:", canAddMethod); //$NON-NLS-1$
1541:                println(
1542:                        "Can unrestrictedly rd. classes:", canUnrestrictedlyRedefineClasses); //$NON-NLS-1$
1543:                println("Can pop frames:", canPopFrames); //$NON-NLS-1$
1544:                println("Can use instance filters:", canUseInstanceFilters); //$NON-NLS-1$
1545:                println(
1546:                        "Can get source debug extension:", canGetSourceDebugExtension); //$NON-NLS-1$
1547:                println("Can request VMDeath event:", canRequestVMDeathEvent); //$NON-NLS-1$
1548:                println("Can set default stratum:", canSetDefaultStratum); //$NON-NLS-1$
1549:                println("Reserved:", reserved16); //$NON-NLS-1$
1550:                println("Reserved:", reserved17); //$NON-NLS-1$
1551:                println("Reserved:", reserved18); //$NON-NLS-1$
1552:                println("Reserved:", reserved19); //$NON-NLS-1$
1553:                println("Reserved:", reserved20); //$NON-NLS-1$
1554:                println("Reserved:", reserved21); //$NON-NLS-1$
1555:                println("Reserved:", reserved22); //$NON-NLS-1$
1556:                println("Reserved:", reserved23); //$NON-NLS-1$
1557:                println("Reserved:", reserved24); //$NON-NLS-1$
1558:                println("Reserved:", reserved25); //$NON-NLS-1$
1559:                println("Reserved:", reserved26); //$NON-NLS-1$
1560:                println("Reserved:", reserved27); //$NON-NLS-1$
1561:                println("Reserved:", reserved28); //$NON-NLS-1$
1562:                println("Reserved:", reserved29); //$NON-NLS-1$
1563:                println("Reserved:", reserved30); //$NON-NLS-1$
1564:                println("Reserved:", reserved31); //$NON-NLS-1$
1565:                println("Reserved:", reserved32); //$NON-NLS-1$
1566:            }
1567:
1568:            private void printVmRedefineClassCommand(DataInputStream in)
1569:                    throws IOException, UnableToParseDataException {
1570:                int typesCount = in.readInt();
1571:                println("Types count:", typesCount); //$NON-NLS-1$
1572:                for (int i = 0; i < typesCount; i++) {
1573:                    long typeId = readReferenceTypeID(in);
1574:                    int classfileLength = in.readInt();
1575:                    printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
1576:                    println("Classfile length:", classfileLength); //$NON-NLS-1$
1577:                    while ((classfileLength -= in.skipBytes(classfileLength)) != 0) {
1578:                    }
1579:                    printDescription("Class bytes:"); //$NON-NLS-1$
1580:                    println("skipped"); //$NON-NLS-1$
1581:                }
1582:            }
1583:
1584:            private void printVmSetDefaultStratumCommand(DataInputStream in)
1585:                    throws IOException {
1586:                String stratumId = readString(in);
1587:                println("Stratum id:", stratumId); //$NON-NLS-1$
1588:            }
1589:
1590:            private void printVmAllClassesWithGenericReply(DataInputStream in)
1591:                    throws IOException, UnableToParseDataException {
1592:                int classesCount = in.readInt();
1593:                println("Classes count:", classesCount); //$NON-NLS-1$
1594:                for (int i = 0; i < classesCount; i++) {
1595:                    byte refTypeTag = in.readByte();
1596:                    long typeId = readReferenceTypeID(in);
1597:                    String signature = readString(in);
1598:                    String genericSignature = readString(in);
1599:                    int status = in.readInt();
1600:                    printRefTypeTag(refTypeTag);
1601:                    printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
1602:                    println("Class signature:", signature); //$NON-NLS-1$
1603:                    println("Generic class signature:", genericSignature); //$NON-NLS-1$
1604:                    printClassStatus(status);
1605:                }
1606:            }
1607:
1608:            private void printRtDefaultCommand(DataInputStream in)
1609:                    throws IOException, UnableToParseDataException {
1610:                long typeId = readReferenceTypeID(in);
1611:                printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
1612:            }
1613:
1614:            private void printRtSignatureReply(DataInputStream in)
1615:                    throws IOException {
1616:                String signature = readString(in);
1617:                println("Signature:", signature); //$NON-NLS-1$
1618:            }
1619:
1620:            private void printRtClassLoaderReply(DataInputStream in)
1621:                    throws IOException, UnableToParseDataException {
1622:                long classLoaderId = readObjectID(in);
1623:                printlnObjectId("ClassLoader id:", classLoaderId); //$NON-NLS-1$
1624:            }
1625:
1626:            private void printRtModifiersReply(DataInputStream in)
1627:                    throws IOException {
1628:                int modifiers = in.readInt();
1629:                printClassModifiers(modifiers);
1630:            }
1631:
1632:            private void printRtFieldsReply(DataInputStream in)
1633:                    throws IOException, UnableToParseDataException {
1634:                int fieldsCount = in.readInt();
1635:                println("Fields count:", fieldsCount); //$NON-NLS-1$
1636:                for (int i = 0; i < fieldsCount; i++) {
1637:                    long fieldId = readFieldID(in);
1638:                    String name = readString(in);
1639:                    String signature = readString(in);
1640:                    int modifiers = in.readInt();
1641:                    printlnFieldId("Field id:", fieldId); //$NON-NLS-1$
1642:                    println("Name:", name); //$NON-NLS-1$
1643:                    println("Signature:", signature); //$NON-NLS-1$
1644:                    printFieldModifiers(modifiers);
1645:                }
1646:            }
1647:
1648:            private void printRtMethodsReply(DataInputStream in)
1649:                    throws IOException, UnableToParseDataException {
1650:                int methodsCount = in.readInt();
1651:                println("Methods count:", methodsCount); //$NON-NLS-1$
1652:                for (int i = 0; i < methodsCount; i++) {
1653:                    long methodId = readMethodID(in);
1654:                    String name = readString(in);
1655:                    String signature = readString(in);
1656:                    int modifiers = in.readInt();
1657:                    printlnMethodId("Method id:", methodId); //$NON-NLS-1$
1658:                    println("Name:", name); //$NON-NLS-1$
1659:                    println("Signature:", signature); //$NON-NLS-1$
1660:                    printMethodModifiers(modifiers);
1661:                }
1662:            }
1663:
1664:            private void printRtGetValuesCommand(DataInputStream in)
1665:                    throws IOException, UnableToParseDataException {
1666:                long typeId = readReferenceTypeID(in);
1667:                int fieldsCount = in.readInt();
1668:                printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
1669:                println("Fields count:", fieldsCount); //$NON-NLS-1$
1670:                for (int i = 0; i < fieldsCount; i++) {
1671:                    long fieldId = readFieldID(in);
1672:                    printlnFieldId("Field id:", fieldId); //$NON-NLS-1$
1673:                }
1674:            }
1675:
1676:            private void printRtGetValuesReply(DataInputStream in)
1677:                    throws IOException, UnableToParseDataException {
1678:                int valuesCount = in.readInt();
1679:                println("Values count:", valuesCount); //$NON-NLS-1$
1680:                for (int i = 0; i < valuesCount; i++) {
1681:                    readAndPrintlnTaggedValue("Value:", in); //$NON-NLS-1$
1682:                }
1683:            }
1684:
1685:            private void printRtSourceFileReply(DataInputStream in)
1686:                    throws IOException {
1687:                String sourceFile = readString(in);
1688:                println("Source file:", sourceFile); //$NON-NLS-1$
1689:            }
1690:
1691:            private void printRtNestedTypesReply(DataInputStream in)
1692:                    throws IOException, UnableToParseDataException {
1693:                int typesCount = in.readInt();
1694:                println("Types count:", typesCount); //$NON-NLS-1$
1695:                for (int i = 0; i < typesCount; i++) {
1696:                    byte typeTag = in.readByte();
1697:                    long typeId = readReferenceTypeID(in);
1698:                    printRefTypeTag(typeTag);
1699:                    printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
1700:                }
1701:            }
1702:
1703:            private void printRtStatusReply(DataInputStream in)
1704:                    throws IOException {
1705:                int status = in.readInt();
1706:                printClassStatus(status);
1707:            }
1708:
1709:            private void printRtInterfacesReply(DataInputStream in)
1710:                    throws IOException, UnableToParseDataException {
1711:                int interfacesCount = in.readInt();
1712:                println("Interfaces count:", interfacesCount); //$NON-NLS-1$
1713:                for (int i = 0; i < interfacesCount; i++) {
1714:                    long interfaceId = readReferenceTypeID(in);
1715:                    printlnReferenceTypeId("Interface type id:", interfaceId); //$NON-NLS-1$
1716:                }
1717:            }
1718:
1719:            private void printRtClassObjectReply(DataInputStream in)
1720:                    throws IOException, UnableToParseDataException {
1721:                long classObjectId = readObjectID(in);
1722:                printlnObjectId("Class object id:", classObjectId); //$NON-NLS-1$
1723:            }
1724:
1725:            private void printRtSourceDebugExtensionReply(DataInputStream in)
1726:                    throws IOException {
1727:                String extension = readString(in);
1728:                println("Extension:", extension); //$NON-NLS-1$
1729:            }
1730:
1731:            private void printRtSignatureWithGenericReply(DataInputStream in)
1732:                    throws IOException {
1733:                String signature = readString(in);
1734:                String genericSignature = readString(in);
1735:                println("Signature:", signature); //$NON-NLS-1$
1736:                println("Generic signature:", genericSignature); //$NON-NLS-1$
1737:            }
1738:
1739:            private void printRtFieldsWithGenericReply(DataInputStream in)
1740:                    throws IOException, UnableToParseDataException {
1741:                int fieldsCount = in.readInt();
1742:                println("Fields count:", fieldsCount); //$NON-NLS-1$
1743:                for (int i = 0; i < fieldsCount; i++) {
1744:                    long fieldId = readFieldID(in);
1745:                    String name = readString(in);
1746:                    String signature = readString(in);
1747:                    String genericSignature = readString(in);
1748:                    int modifiers = in.readInt();
1749:                    printlnFieldId("Field id:", fieldId); //$NON-NLS-1$
1750:                    println("Name:", name); //$NON-NLS-1$
1751:                    println("Signature:", signature); //$NON-NLS-1$
1752:                    println("Generic signature:", genericSignature); //$NON-NLS-1$
1753:                    printFieldModifiers(modifiers);
1754:                }
1755:            }
1756:
1757:            private void printRtMethodsWithGenericReply(DataInputStream in)
1758:                    throws IOException, UnableToParseDataException {
1759:                int methodsCount = in.readInt();
1760:                println("Methods count:", methodsCount); //$NON-NLS-1$
1761:                for (int i = 0; i < methodsCount; i++) {
1762:                    long methodId = readMethodID(in);
1763:                    String name = readString(in);
1764:                    String genericSignature = readString(in);
1765:                    int modifiers = in.readInt();
1766:                    printlnMethodId("Method id:", methodId); //$NON-NLS-1$
1767:                    println("Name:", name); //$NON-NLS-1$
1768:                    //			println(TcpIpSpyMessages.VerbosePacketStream_Signature__106, signature);
1769:                    println("Generic signature:", genericSignature); //$NON-NLS-1$
1770:                    printMethodModifiers(modifiers);
1771:                }
1772:            }
1773:
1774:            private void printCtSuperclassCommand(DataInputStream in)
1775:                    throws IOException, UnableToParseDataException {
1776:                long classTypeId = readReferenceTypeID(in);
1777:                printlnReferenceTypeId("Class type id:", classTypeId); //$NON-NLS-1$
1778:            }
1779:
1780:            private void printCtSuperclassReply(DataInputStream in)
1781:                    throws IOException, UnableToParseDataException {
1782:                long super classTypeId = readReferenceTypeID(in);
1783:                printlnReferenceTypeId("Superclass type id:", super classTypeId); //$NON-NLS-1$
1784:            }
1785:
1786:            private void printCtSetValuesCommand(DataInputStream in)
1787:                    throws IOException, UnableToParseDataException {
1788:                long classTypeId = readReferenceTypeID(in);
1789:                int fieldsCount = in.readInt();
1790:                printlnReferenceTypeId("Class type id:", classTypeId); //$NON-NLS-1$
1791:                println("Fields count:", fieldsCount); //$NON-NLS-1$
1792:                throw new UnableToParseDataException(
1793:                        "List of values: NOT MANAGED", remainderData(in)); //$NON-NLS-1$
1794:            }
1795:
1796:            private void printCtInvokeMethodCommand(DataInputStream in)
1797:                    throws IOException, UnableToParseDataException {
1798:                long classTypeId = readReferenceTypeID(in);
1799:                long threadId = readObjectID(in);
1800:                long methodId = readMethodID(in);
1801:                int argumentsCount = in.readInt();
1802:                printlnReferenceTypeId("Class type id:", classTypeId); //$NON-NLS-1$
1803:                printlnObjectId("Thread id:", threadId); //$NON-NLS-1$
1804:                printlnMethodId("Method id:", methodId); //$NON-NLS-1$
1805:                println("Arguments count:", argumentsCount); //$NON-NLS-1$
1806:                for (int i = 0; i < argumentsCount; i++) {
1807:                    readAndPrintlnTaggedValue("Argument:", in); //$NON-NLS-1$
1808:                }
1809:                int invocationOptions = in.readInt();
1810:                printInvocationOptions(invocationOptions);
1811:            }
1812:
1813:            private void printCtInvokeMethodReply(DataInputStream in)
1814:                    throws IOException, UnableToParseDataException {
1815:                readAndPrintlnTaggedValue("Return value:", in); //$NON-NLS-1$
1816:                byte signatureByte = in.readByte();
1817:                long exception = readObjectID(in);
1818:                printlnTaggedObjectId(
1819:                        "Exception object id:", exception, signatureByte); //$NON-NLS-1$
1820:            }
1821:
1822:            private void printCtNewInstanceCommand(DataInputStream in)
1823:                    throws IOException, UnableToParseDataException {
1824:                printCtInvokeMethodCommand(in);
1825:            }
1826:
1827:            private void printCtNewInstanceReply(DataInputStream in)
1828:                    throws IOException, UnableToParseDataException {
1829:                byte objectSignatureByte = in.readByte();
1830:                long newObjectId = readObjectID(in);
1831:                byte exceptionSignatureByte = in.readByte();
1832:                long exception = readObjectID(in);
1833:                printlnTaggedObjectId(
1834:                        "New object id:", newObjectId, objectSignatureByte); //$NON-NLS-1$
1835:                printlnTaggedObjectId(
1836:                        "Exception object id:", exception, exceptionSignatureByte); //$NON-NLS-1$
1837:            }
1838:
1839:            private void printAtNewInstanceCommand(DataInputStream in)
1840:                    throws IOException, UnableToParseDataException {
1841:                long arrayTypeId = readReferenceTypeID(in);
1842:                int length = in.readInt();
1843:                printlnReferenceTypeId("Array type id:", arrayTypeId); //$NON-NLS-1$
1844:                println("Length:", length); //$NON-NLS-1$
1845:            }
1846:
1847:            private void printAtNewInstanceReply(DataInputStream in)
1848:                    throws IOException, UnableToParseDataException {
1849:                byte signatureByte = in.readByte();
1850:                long newArrayId = readObjectID(in);
1851:                printlnTaggedObjectId(
1852:                        "New array id:", newArrayId, signatureByte); //$NON-NLS-1$
1853:            }
1854:
1855:            private void printMDefaultCommand(DataInputStream in)
1856:                    throws IOException, UnableToParseDataException {
1857:                long classTypeId = readReferenceTypeID(in);
1858:                long methodId = readMethodID(in);
1859:                printlnReferenceTypeId("Class type id:", classTypeId); //$NON-NLS-1$
1860:                printlnMethodId("Method id:", methodId); //$NON-NLS-1$
1861:            }
1862:
1863:            private void printMLineTableReply(DataInputStream in)
1864:                    throws IOException {
1865:                long start = in.readLong();
1866:                long end = in.readLong();
1867:                int lines = in.readInt();
1868:                println("Lowest valid code index:", start); //$NON-NLS-1$
1869:                println("Highest valid code index:", end); //$NON-NLS-1$
1870:                println("Number of lines:", lines); //$NON-NLS-1$
1871:                for (int i = 0; i < lines; i++) {
1872:                    long lineCodeIndex = in.readLong();
1873:                    int lineNumber = in.readInt();
1874:                    println("Line code Index:", lineCodeIndex); //$NON-NLS-1$
1875:                    println("Line number:", lineNumber); //$NON-NLS-1$
1876:                }
1877:            }
1878:
1879:            private void printMVariableTableReply(DataInputStream in)
1880:                    throws IOException {
1881:                int slotsUsedByArgs = in.readInt();
1882:                int variablesCount = in.readInt();
1883:                println("Nb of slots used by all args:", slotsUsedByArgs); //$NON-NLS-1$
1884:                println("Nb of variables:", variablesCount); //$NON-NLS-1$
1885:                for (int i = 0; i < variablesCount; i++) {
1886:                    long codeIndex = in.readLong();
1887:                    String name = readString(in);
1888:                    String signature = readString(in);
1889:                    int length = in.readInt();
1890:                    int slotId = in.readInt();
1891:                    println("First code index:", codeIndex); //$NON-NLS-1$
1892:                    println("Variable name:", name); //$NON-NLS-1$
1893:                    println("Variable type signature:", signature); //$NON-NLS-1$
1894:                    println("Code index length:", length); //$NON-NLS-1$
1895:                    println("Slot id:", slotId); //$NON-NLS-1$
1896:                }
1897:            }
1898:
1899:            private void printMBytecodesReply(DataInputStream in)
1900:                    throws IOException {
1901:                int bytes = in.readInt();
1902:                println("Nb of bytes:", bytes); //$NON-NLS-1$
1903:                while ((bytes -= in.skipBytes(bytes)) != 0) {
1904:                }
1905:                printDescription("Method bytes:"); //$NON-NLS-1$
1906:                println("skipped"); //$NON-NLS-1$
1907:            }
1908:
1909:            private void printMIsObsoleteReply(DataInputStream in)
1910:                    throws IOException {
1911:                boolean isObsolete = in.readBoolean();
1912:                println("Is obsolete:", isObsolete); //$NON-NLS-1$
1913:            }
1914:
1915:            private void printMVariableTableWithGenericReply(DataInputStream in)
1916:                    throws IOException {
1917:                int slotsUsedByArgs = in.readInt();
1918:                int variablesCount = in.readInt();
1919:                println("Nb of slots used by all args:", slotsUsedByArgs); //$NON-NLS-1$
1920:                println("Nb of variables:", variablesCount); //$NON-NLS-1$
1921:                for (int i = 0; i < variablesCount; i++) {
1922:                    long codeIndex = in.readLong();
1923:                    String name = readString(in);
1924:                    String signature = readString(in);
1925:                    String genericSignature = readString(in);
1926:                    int length = in.readInt();
1927:                    int slotId = in.readInt();
1928:                    println("First code index:", codeIndex); //$NON-NLS-1$
1929:                    println("Variable name:", name); //$NON-NLS-1$
1930:                    println("Variable type signature:", signature); //$NON-NLS-1$
1931:                    println("Var. type generic signature:", genericSignature); //$NON-NLS-1$
1932:                    println("Code index length:", length); //$NON-NLS-1$
1933:                    println("Slot id:", slotId); //$NON-NLS-1$
1934:                }
1935:            }
1936:
1937:            private void printOrDefaultCommand(DataInputStream in)
1938:                    throws IOException, UnableToParseDataException {
1939:                long objectId = readObjectID(in);
1940:                println("Object id:", objectId); //$NON-NLS-1$
1941:            }
1942:
1943:            private void printOrReferenceTypeReply(DataInputStream in)
1944:                    throws IOException, UnableToParseDataException {
1945:                byte refTypeTag = in.readByte();
1946:                long typeId = readReferenceTypeID(in);
1947:                printRefTypeTag(refTypeTag);
1948:                printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
1949:            }
1950:
1951:            private void printOrGetValuesCommand(DataInputStream in)
1952:                    throws IOException, UnableToParseDataException {
1953:                long objectId = readObjectID(in);
1954:                int fieldsCount = in.readInt();
1955:                println("Object id:", objectId); //$NON-NLS-1$
1956:                println("Fields count:", fieldsCount); //$NON-NLS-1$
1957:                for (int i = 0; i < fieldsCount; i++) {
1958:                    long fieldId = readFieldID(in);
1959:                    println("Field id:", fieldId); //$NON-NLS-1$
1960:                }
1961:            }
1962:
1963:            private void printOrGetValuesReply(DataInputStream in)
1964:                    throws IOException, UnableToParseDataException {
1965:                int valuesCount = in.readInt();
1966:                println("Values count:", valuesCount); //$NON-NLS-1$
1967:                for (int i = 0; i < valuesCount; i++) {
1968:                    readAndPrintlnTaggedValue("Value:", in); //$NON-NLS-1$
1969:                }
1970:            }
1971:
1972:            private void printOrSetValuesCommand(DataInputStream in)
1973:                    throws IOException, UnableToParseDataException {
1974:                long objectId = readObjectID(in);
1975:                int fieldsCount = in.readInt();
1976:                println("Object id:", objectId); //$NON-NLS-1$
1977:                println("Fields count:", fieldsCount); //$NON-NLS-1$
1978:                throw new UnableToParseDataException(
1979:                        "List of values: NOT MANAGED", remainderData(in)); //$NON-NLS-1$
1980:            }
1981:
1982:            private void printOrMonitorInfoReply(DataInputStream in)
1983:                    throws IOException, UnableToParseDataException {
1984:                long ownerThreadId = readObjectID(in);
1985:                int entryCount = in.readInt();
1986:                int waiters = in.readInt();
1987:                printlnObjectId("Owner thread id:", ownerThreadId); //$NON-NLS-1$
1988:                println("Entry count:", entryCount); //$NON-NLS-1$
1989:                println("Nb of waiters:", waiters); //$NON-NLS-1$
1990:                long waiterThreadId;
1991:                for (int i = 0; i < waiters; i++) {
1992:                    waiterThreadId = readObjectID(in);
1993:                    printlnObjectId("Waiting thread id:", waiterThreadId); //$NON-NLS-1$
1994:                }
1995:            }
1996:
1997:            private void printOrInvokeMethodCommand(DataInputStream in)
1998:                    throws IOException, UnableToParseDataException {
1999:                long objectId = readObjectID(in);
2000:                long threadId = readObjectID(in);
2001:                long classTypeId = readReferenceTypeID(in);
2002:                long methodId = readMethodID(in);
2003:                int argsCount = in.readInt();
2004:                printlnObjectId("Object id:", objectId); //$NON-NLS-1$
2005:                printlnObjectId("Thread id:", threadId); //$NON-NLS-1$
2006:                printlnReferenceTypeId("Class type id:", classTypeId); //$NON-NLS-1$
2007:                printlnMethodId("Method id:", methodId); //$NON-NLS-1$
2008:                println("Arguments count:", argsCount); //$NON-NLS-1$
2009:                for (int i = 0; i < argsCount; i++) {
2010:                    readAndPrintlnTaggedValue("Argument:", in); //$NON-NLS-1$
2011:                }
2012:                int invocationOption = in.readInt();
2013:                printInvocationOptions(invocationOption);
2014:            }
2015:
2016:            private void printOrInvokeMethodReply(DataInputStream in)
2017:                    throws IOException, UnableToParseDataException {
2018:                readAndPrintlnTaggedValue("Return value:", in); //$NON-NLS-1$
2019:                byte signatureByte = in.readByte();
2020:                long exception = readObjectID(in);
2021:                printlnTaggedObjectId(
2022:                        "Exception object id:", exception, signatureByte); //$NON-NLS-1$
2023:            }
2024:
2025:            private void printOrIsCollectedReply(DataInputStream in)
2026:                    throws IOException {
2027:                boolean isCollected = in.readBoolean();
2028:                println("Is collected:", isCollected); //$NON-NLS-1$
2029:            }
2030:
2031:            private void printSrValueCommand(DataInputStream in)
2032:                    throws IOException, UnableToParseDataException {
2033:                long stringObjectId = readObjectID(in);
2034:                printlnObjectId("String object id:", stringObjectId); //$NON-NLS-1$
2035:            }
2036:
2037:            private void printSrValueReply(DataInputStream in)
2038:                    throws IOException {
2039:                String value = readString(in);
2040:                println("Value:", value); //$NON-NLS-1$
2041:            }
2042:
2043:            private void printTrDefaultCommand(DataInputStream in)
2044:                    throws IOException, UnableToParseDataException {
2045:                long threadId = readObjectID(in);
2046:                printlnObjectId("Thread id:", threadId); //$NON-NLS-1$
2047:            }
2048:
2049:            private void printTrNameReply(DataInputStream in)
2050:                    throws IOException {
2051:                String threadName = readString(in);
2052:                println("Name:", threadName); //$NON-NLS-1$
2053:            }
2054:
2055:            private void printTrStatusReply(DataInputStream in)
2056:                    throws IOException {
2057:                int threadStatus = in.readInt();
2058:                int suspendStatus = in.readInt();
2059:                printThreadStatus(threadStatus);
2060:                printSuspendStatus(suspendStatus);
2061:            }
2062:
2063:            private void printTrThreadGroupReply(DataInputStream in)
2064:                    throws IOException, UnableToParseDataException {
2065:                long threadGroupId = readObjectID(in);
2066:                printlnObjectId("Thread group id:", threadGroupId); //$NON-NLS-1$
2067:            }
2068:
2069:            private void printTrFramesCommand(DataInputStream in)
2070:                    throws IOException, UnableToParseDataException {
2071:                long threadId = readObjectID(in);
2072:                int startFrame = in.readInt();
2073:                int length = in.readInt();
2074:                printlnObjectId("Thread id:", threadId); //$NON-NLS-1$
2075:                println("First frame:", startFrame); //$NON-NLS-1$
2076:                println("Number of frame:", length); //$NON-NLS-1$
2077:            }
2078:
2079:            private void printTrFramesReply(DataInputStream in)
2080:                    throws IOException, UnableToParseDataException {
2081:                int framesCount = in.readInt();
2082:                println("Frames count:", framesCount); //$NON-NLS-1$
2083:                for (int i = 0; i < framesCount; i++) {
2084:                    long frameId = readFrameID(in);
2085:                    printlnFrameId("Frame id:", frameId); //$NON-NLS-1$
2086:                    readAndPrintLocation(in);
2087:                }
2088:            }
2089:
2090:            private void printTrFrameCountReply(DataInputStream in)
2091:                    throws IOException {
2092:                int framesCount = in.readInt();
2093:                println("Frames count:", framesCount); //$NON-NLS-1$
2094:            }
2095:
2096:            private void printTrOwnedMonitorsReply(DataInputStream in)
2097:                    throws IOException, UnableToParseDataException {
2098:                int monitorsCount = in.readInt();
2099:                println("Monitors count:", monitorsCount); //$NON-NLS-1$
2100:                for (int i = 0; i < monitorsCount; i++) {
2101:                    byte signatureByte = in.readByte();
2102:                    long monitorObjectId = readObjectID(in);
2103:                    printlnTaggedObjectId(
2104:                            "Monitor object id:", monitorObjectId, signatureByte); //$NON-NLS-1$
2105:                }
2106:            }
2107:
2108:            private void printTrCurrentContendedMonitorReply(DataInputStream in)
2109:                    throws IOException, UnableToParseDataException {
2110:                byte signatureByte = in.readByte();
2111:                long monitorObjectId = readObjectID(in);
2112:                printlnTaggedObjectId(
2113:                        "Monitor object id:", monitorObjectId, signatureByte); //$NON-NLS-1$
2114:            }
2115:
2116:            private void printTrStopCommand(DataInputStream in)
2117:                    throws IOException, UnableToParseDataException {
2118:                long threadId = readObjectID(in);
2119:                long exceptionObjectId = readObjectID(in);
2120:                printlnObjectId("Thread id:", threadId); //$NON-NLS-1$
2121:                printlnObjectId("Exception object id:", exceptionObjectId); //$NON-NLS-1$
2122:            }
2123:
2124:            private void printTrSuspendCountReply(DataInputStream in)
2125:                    throws IOException {
2126:                int suspendCount = in.readInt();
2127:                println("Suspend count:", suspendCount); //$NON-NLS-1$
2128:            }
2129:
2130:            private void printTgrDefaultCommand(DataInputStream in)
2131:                    throws IOException, UnableToParseDataException {
2132:                long threadGroupId = readObjectID(in);
2133:                printlnObjectId("Thread group id:", threadGroupId); //$NON-NLS-1$
2134:            }
2135:
2136:            private void printTgrNameReply(DataInputStream in)
2137:                    throws IOException {
2138:                String name = readString(in);
2139:                println("Name:", name); //$NON-NLS-1$
2140:            }
2141:
2142:            private void printTgrParentReply(DataInputStream in)
2143:                    throws IOException, UnableToParseDataException {
2144:                long parentThreadGroupId = readObjectID(in);
2145:                printlnObjectId("Parent thread group id:", parentThreadGroupId); //$NON-NLS-1$
2146:            }
2147:
2148:            private void printTgrChildrenReply(DataInputStream in)
2149:                    throws IOException, UnableToParseDataException {
2150:                int childThreadsCount = in.readInt();
2151:                println("Child threads count:", childThreadsCount); //$NON-NLS-1$
2152:                for (int i = 0; i < childThreadsCount; i++) {
2153:                    long childThreadId = readObjectID(in);
2154:                    printlnObjectId("Child thread id:", childThreadId); //$NON-NLS-1$
2155:                }
2156:                int childGroupThreadsCount = in.readInt();
2157:                println("Child group threads count:", childGroupThreadsCount); //$NON-NLS-1$
2158:                for (int i = 0; i < childGroupThreadsCount; i++) {
2159:                    long childGroupThreadId = readObjectID(in);
2160:                    printlnObjectId(
2161:                            "Child group thread id:", childGroupThreadId); //$NON-NLS-1$
2162:                }
2163:            }
2164:
2165:            private void printArLengthCommand(DataInputStream in)
2166:                    throws IOException, UnableToParseDataException {
2167:                long arrayObjectId = readObjectID(in);
2168:                printlnObjectId("Array object id:", arrayObjectId); //$NON-NLS-1$
2169:            }
2170:
2171:            private void printArLengthReply(DataInputStream in)
2172:                    throws IOException {
2173:                int length = in.readInt();
2174:                println("Length:", length); //$NON-NLS-1$
2175:            }
2176:
2177:            private void printArGetValuesCommand(DataInputStream in)
2178:                    throws IOException, UnableToParseDataException {
2179:                long arrayObjectId = readObjectID(in);
2180:                int firstIndex = in.readInt();
2181:                int length = in.readInt();
2182:                printlnObjectId("Array object id:", arrayObjectId); //$NON-NLS-1$
2183:                println("First index:", firstIndex); //$NON-NLS-1$
2184:                println("Length:", length); //$NON-NLS-1$
2185:            }
2186:
2187:            private void printArGetValuesReply(DataInputStream in)
2188:                    throws IOException, UnableToParseDataException {
2189:                readAndPrintArrayRegion(in);
2190:            }
2191:
2192:            private void printArSetValuesCommand(DataInputStream in)
2193:                    throws IOException, UnableToParseDataException {
2194:                long arrayObjectId = readObjectID(in);
2195:                int firstIndex = in.readInt();
2196:                int length = in.readInt();
2197:                printlnObjectId("Array object id:", arrayObjectId); //$NON-NLS-1$
2198:                println("First index:", firstIndex); //$NON-NLS-1$
2199:                println("Length:", length); //$NON-NLS-1$
2200:                throw new UnableToParseDataException(
2201:                        "List of values: NOT MANAGED", remainderData(in)); //$NON-NLS-1$
2202:            }
2203:
2204:            private void printClrVisibleClassesCommand(DataInputStream in)
2205:                    throws IOException, UnableToParseDataException {
2206:                long classLoaderObjectId = readObjectID(in);
2207:                printlnObjectId("Class loader object id:", classLoaderObjectId); //$NON-NLS-1$
2208:            }
2209:
2210:            private void printClrVisibleClassesReply(DataInputStream in)
2211:                    throws IOException, UnableToParseDataException {
2212:                int classesCount = in.readInt();
2213:                println("Classes count:", classesCount); //$NON-NLS-1$
2214:                for (int i = 0; i < classesCount; i++) {
2215:                    byte refTypeTag = in.readByte();
2216:                    long typeId = readReferenceTypeID(in);
2217:                    printRefTypeTag(refTypeTag);
2218:                    printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
2219:                }
2220:            }
2221:
2222:            private void printErSetCommand(DataInputStream in)
2223:                    throws IOException, UnableToParseDataException {
2224:                byte eventKind = in.readByte();
2225:                byte suspendPolicy = in.readByte();
2226:                int modifiersCount = in.readInt();
2227:                printEventKind(eventKind);
2228:                printSuspendPolicy(suspendPolicy);
2229:                println("Modifiers count:", modifiersCount); //$NON-NLS-1$
2230:                for (int i = 0; i < modifiersCount; i++) {
2231:                    byte modKind = in.readByte();
2232:                    printDescription("Modifier kind:"); //$NON-NLS-1$
2233:                    printHex(modKind);
2234:                    switch (modKind) {
2235:                    case 1: // count
2236:                        println(" (Count)"); //$NON-NLS-1$
2237:                        int count = in.readInt();
2238:                        println("Count:", count); //$NON-NLS-1$
2239:                        break;
2240:                    case 2: // conditional
2241:                        println(" (Conditional)"); //$NON-NLS-1$
2242:                        int exprId = in.readInt();
2243:                        println("Expression id:", exprId); //$NON-NLS-1$
2244:                        break;
2245:                    case 3: // thread only
2246:                        println(" (ThreadOnly)"); //$NON-NLS-1$
2247:                        long threadId = readObjectID(in);
2248:                        printlnObjectId("Thread id:", threadId); //$NON-NLS-1$
2249:                        break;
2250:                    case 4: // class only
2251:                        println(" (ClassOnly)"); //$NON-NLS-1$
2252:                        long classId = readReferenceTypeID(in);
2253:                        printlnReferenceTypeId("Class type id:", classId); //$NON-NLS-1$
2254:                        break;
2255:                    case 5: // class match
2256:                        println(" (ClassMatch)"); //$NON-NLS-1$
2257:                        String classPatern = readString(in);
2258:                        println("Class pattern:", classPatern); //$NON-NLS-1$
2259:                        break;
2260:                    case 6: // class exclude
2261:                        println(" (ClassExclude)"); //$NON-NLS-1$
2262:                        classPatern = readString(in);
2263:                        println("Class pattern:", classPatern); //$NON-NLS-1$
2264:                        break;
2265:                    case 7: // location only
2266:                        println(" (LocationOnly)"); //$NON-NLS-1$
2267:                        readAndPrintLocation(in);
2268:                        break;
2269:                    case 8: // exception only
2270:                        println(" (ExceptionOnly)"); //$NON-NLS-1$
2271:                        long typeId = readReferenceTypeID(in);
2272:                        boolean caught = in.readBoolean();
2273:                        boolean uncaught = in.readBoolean();
2274:                        printlnReferenceTypeId("Exception type id:", typeId); //$NON-NLS-1$
2275:                        println("Caught:", caught); //$NON-NLS-1$
2276:                        println("Uncaught:", uncaught); //$NON-NLS-1$
2277:                        break;
2278:                    case 9: // field only
2279:                        println(" (FieldOnly)"); //$NON-NLS-1$
2280:                        long declaringTypeId = readReferenceTypeID(in);
2281:                        long fieldId = readFieldID(in);
2282:                        printlnReferenceTypeId(
2283:                                "Declaring type id:", declaringTypeId); //$NON-NLS-1$
2284:                        printlnFieldId("Field id:", fieldId); //$NON-NLS-1$
2285:                        break;
2286:                    case 10: // step
2287:                        println(" (Step)"); //$NON-NLS-1$
2288:                        threadId = readObjectID(in);
2289:                        int stepSize = in.readInt();
2290:                        int stepDepth = in.readInt();
2291:                        printlnObjectId("Thread id:", threadId); //$NON-NLS-1$
2292:                        printStepSize(stepSize);
2293:                        printStepDepth(stepDepth);
2294:                        break;
2295:                    case 11: // instance only
2296:                        println(" (InstanceOnly)"); //$NON-NLS-1$
2297:                        long objectId = readObjectID(in);
2298:                        printlnObjectId("Object id:", objectId); //$NON-NLS-1$
2299:                        break;
2300:                    }
2301:                }
2302:            }
2303:
2304:            private void printErSetReply(DataInputStream in) throws IOException {
2305:                int requestId = in.readInt();
2306:                println("Request id:", requestId); //$NON-NLS-1$
2307:            }
2308:
2309:            private void printErClearCommand(DataInputStream in)
2310:                    throws IOException {
2311:                byte eventKind = in.readByte();
2312:                int requestId = in.readInt();
2313:                printEventKind(eventKind);
2314:                println("Request id:", requestId); //$NON-NLS-1$
2315:            }
2316:
2317:            private void printSfDefaultCommand(DataInputStream in)
2318:                    throws IOException, UnableToParseDataException {
2319:                long threadId = readObjectID(in);
2320:                long frameId = readFrameID(in);
2321:                printlnObjectId("Thread object id:", threadId); //$NON-NLS-1$
2322:                printlnFrameId("Frame id:", frameId); //$NON-NLS-1$
2323:            }
2324:
2325:            private void printSfGetValuesCommand(DataInputStream in)
2326:                    throws IOException, UnableToParseDataException {
2327:                long threadId = readObjectID(in);
2328:                long frameId = readFrameID(in);
2329:                int slotsCount = in.readInt();
2330:                printlnObjectId("Thread object id:", threadId); //$NON-NLS-1$
2331:                printlnFrameId("Frame id:", frameId); //$NON-NLS-1$
2332:                println("Slots count:", slotsCount); //$NON-NLS-1$
2333:                for (int i = 0; i < slotsCount; i++) {
2334:                    int slotIndex = in.readInt();
2335:                    byte signatureTag = in.readByte();
2336:                    println("Slot index:", slotIndex); //$NON-NLS-1$
2337:                    printDescription("Signature tag:"); //$NON-NLS-1$
2338:                    printSignatureByte(signatureTag, true);
2339:                    println();
2340:                }
2341:            }
2342:
2343:            private void printSfGetValuesReply(DataInputStream in)
2344:                    throws IOException, UnableToParseDataException {
2345:                int valuesCount = in.readInt();
2346:                println("Values count:", valuesCount); //$NON-NLS-1$
2347:                for (int i = 0; i < valuesCount; i++) {
2348:                    readAndPrintlnTaggedValue("Value:", in); //$NON-NLS-1$
2349:                }
2350:            }
2351:
2352:            private void printSfSetValuesCommand(DataInputStream in)
2353:                    throws IOException, UnableToParseDataException {
2354:                long threadId = readObjectID(in);
2355:                long frameId = readFrameID(in);
2356:                int slotsCount = in.readInt();
2357:                printlnObjectId("Thread object id:", threadId); //$NON-NLS-1$
2358:                printlnFrameId("Frame id:", frameId); //$NON-NLS-1$
2359:                println("Slots count:", slotsCount); //$NON-NLS-1$
2360:                for (int i = 0; i < slotsCount; i++) {
2361:                    int slotIndex = in.readInt();
2362:                    println("Slot index:", slotIndex); //$NON-NLS-1$
2363:                    readAndPrintlnTaggedValue("Values:", in); //$NON-NLS-1$
2364:                }
2365:            }
2366:
2367:            private void printSfThisObjectReply(DataInputStream in)
2368:                    throws IOException, UnableToParseDataException {
2369:                byte signatureByte = in.readByte();
2370:                long objectId = readObjectID(in);
2371:                printlnTaggedObjectId(
2372:                        "'this' object id:", objectId, signatureByte); //$NON-NLS-1$
2373:            }
2374:
2375:            private void printCorReflectedTypeCommand(DataInputStream in)
2376:                    throws IOException, UnableToParseDataException {
2377:                long classObjectId = readObjectID(in);
2378:                printlnObjectId("Class object id:", classObjectId); //$NON-NLS-1$
2379:            }
2380:
2381:            private void printCorReflectedTypeReply(DataInputStream in)
2382:                    throws IOException, UnableToParseDataException {
2383:                byte refTypeTag = in.readByte();
2384:                long typeId = readReferenceTypeID(in);
2385:                printRefTypeTag(refTypeTag);
2386:                printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
2387:            }
2388:
2389:            private void printECompositeCommand(DataInputStream in)
2390:                    throws IOException, UnableToParseDataException {
2391:                byte suspendPolicy = in.readByte();
2392:                int eventsCount = in.readInt();
2393:                printSuspendPolicy(suspendPolicy);
2394:                println("Events count:", eventsCount); //$NON-NLS-1$
2395:                for (int i = 0; i < eventsCount; i++) {
2396:                    byte eventKind = in.readByte();
2397:                    int requestId = in.readInt();
2398:                    printEventKind(eventKind);
2399:                    println("Request id:", requestId); //$NON-NLS-1$
2400:                    switch (eventKind) {
2401:                    case EVENTKIND_VM_START:
2402:                        long threadId = readObjectID(in);
2403:                        printlnObjectId("Initial thread object id:", threadId); //$NON-NLS-1$
2404:                        break;
2405:                    case EVENTKIND_SINGLE_STEP:
2406:                    case EVENTKIND_BREAKPOINT:
2407:                    case EVENTKIND_METHOD_ENTRY:
2408:                    case EVENTKIND_METHOD_EXIT:
2409:                        threadId = readObjectID(in);
2410:                        printlnObjectId("Thread object id:", threadId); //$NON-NLS-1$
2411:                        readAndPrintLocation(in);
2412:                        break;
2413:                    case EVENTKIND_EXCEPTION:
2414:                        threadId = readObjectID(in);
2415:                        readAndPrintLocation(in);
2416:                        byte signatureByte = in.readByte();
2417:                        long objectId = readObjectID(in);
2418:                        printlnTaggedObjectId(
2419:                                "Exception object id:", objectId, signatureByte); //$NON-NLS-1$
2420:                        readAndPrintLocation(in);
2421:                        break;
2422:                    case EVENTKIND_THREAD_START:
2423:                    case EVENTKIND_THREAD_DEATH:
2424:                        threadId = readObjectID(in);
2425:                        printlnObjectId("Thread object id:", threadId); //$NON-NLS-1$
2426:                        break;
2427:                    case EVENTKIND_CLASS_PREPARE:
2428:                        threadId = readObjectID(in);
2429:                        byte refTypeTag = in.readByte();
2430:                        long typeId = readReferenceTypeID(in);
2431:                        String typeSignature = readString(in);
2432:                        int status = in.readInt();
2433:                        printlnObjectId("Thread object id:", threadId); //$NON-NLS-1$
2434:                        printRefTypeTag(refTypeTag);
2435:                        printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
2436:                        println("Type signature:", typeSignature); //$NON-NLS-1$
2437:                        println("Status:", status); //$NON-NLS-1$
2438:                        break;
2439:                    case EVENTKIND_CLASS_UNLOAD:
2440:                        typeSignature = readString(in);
2441:                        println("Type signature:", typeSignature); //$NON-NLS-1$
2442:                        break;
2443:                    case EVENTKIND_FIELD_ACCESS:
2444:                        threadId = readObjectID(in);
2445:                        printlnObjectId("Thread object id:", threadId); //$NON-NLS-1$
2446:                        readAndPrintLocation(in);
2447:                        refTypeTag = in.readByte();
2448:                        typeId = readReferenceTypeID(in);
2449:                        long fieldId = readFieldID(in);
2450:                        signatureByte = in.readByte();
2451:                        objectId = readObjectID(in);
2452:                        printRefTypeTag(refTypeTag);
2453:                        printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
2454:                        printlnFieldId("Field id:", fieldId); //$NON-NLS-1$
2455:                        printlnTaggedObjectId(
2456:                                "Object id:", objectId, signatureByte); //$NON-NLS-1$
2457:                        break;
2458:                    case EVENTKIND_FIELD_MODIFICATION:
2459:                        threadId = readObjectID(in);
2460:                        printlnObjectId("Thread object id:", threadId); //$NON-NLS-1$
2461:                        readAndPrintLocation(in);
2462:                        refTypeTag = in.readByte();
2463:                        typeId = readReferenceTypeID(in);
2464:                        fieldId = readFieldID(in);
2465:                        signatureByte = in.readByte();
2466:                        objectId = readObjectID(in);
2467:                        printRefTypeTag(refTypeTag);
2468:                        printlnReferenceTypeId("Type id:", typeId); //$NON-NLS-1$
2469:                        printlnFieldId("Field id:", fieldId); //$NON-NLS-1$
2470:                        printlnTaggedObjectId(
2471:                                "Object id:", objectId, signatureByte); //$NON-NLS-1$
2472:                        readAndPrintlnTaggedValue("Value:", in); //$NON-NLS-1$
2473:                        break;
2474:                    case EVENTKIND_VM_DEATH:
2475:                        break;
2476:                    }
2477:                }
2478:            }
2479:
2480:            /**
2481:             * Reads String from Jdwp stream.
2482:             * Read a UTF where length has 4 bytes, and not just 2.
2483:             * This code was based on the OTI Retysin source for readUTF.
2484:             */
2485:            private static String readString(DataInputStream in)
2486:                    throws IOException {
2487:                int utfSize = in.readInt();
2488:                byte utfBytes[] = new byte[utfSize];
2489:                in.readFully(utfBytes);
2490:                /* Guess at buffer size */
2491:                StringBuffer strBuffer = new StringBuffer(utfSize / 3 * 2);
2492:                for (int i = 0; i < utfSize;) {
2493:                    int a = utfBytes[i] & 0xFF;
2494:                    if ((a >> 4) < 12) {
2495:                        strBuffer.append((char) a);
2496:                        i++;
2497:                    } else {
2498:                        int b = utfBytes[i + 1] & 0xFF;
2499:                        if ((a >> 4) < 14) {
2500:                            if ((b & 0xBF) == 0) {
2501:                                throw new UTFDataFormatException(
2502:                                        "Second byte input does not match UTF Specification"); //$NON-NLS-1$
2503:                            }
2504:                            strBuffer
2505:                                    .append((char) (((a & 0x1F) << 6) | (b & 0x3F)));
2506:                            i += 2;
2507:                        } else {
2508:                            int c = utfBytes[i + 2] & 0xFF;
2509:                            if ((a & 0xEF) > 0) {
2510:                                if (((b & 0xBF) == 0) || ((c & 0xBF) == 0)) {
2511:                                    throw new UTFDataFormatException(
2512:                                            "Second or third byte input does not mach UTF Specification_"); //$NON-NLS-1$
2513:                                }
2514:                                strBuffer.append((char) (((a & 0x0F) << 12)
2515:                                        | ((b & 0x3F) << 6) | (c & 0x3F)));
2516:                                i += 3;
2517:                            } else {
2518:                                throw new UTFDataFormatException(
2519:                                        "Input does not match UTF Specification"); //$NON-NLS-1$
2520:                            }
2521:                        }
2522:                    }
2523:                }
2524:                return strBuffer.toString();
2525:            }
2526:
2527:            private byte[] remainderData(DataInputStream in) throws IOException {
2528:                byte[] buffer = new byte[100];
2529:                byte[] res = new byte[0], newRes;
2530:                int resLength = 0, length;
2531:                while ((length = in.read(buffer)) != -1) {
2532:                    newRes = new byte[resLength + length];
2533:                    System.arraycopy(res, 0, newRes, 0, resLength);
2534:                    System.arraycopy(buffer, 0, newRes, resLength, length);
2535:                    res = newRes;
2536:                    resLength += length;
2537:                }
2538:                return res;
2539:            }
2540:
2541:            private long readObjectID(DataInputStream in) throws IOException,
2542:                    UnableToParseDataException {
2543:                if (!TcpipSpy.hasSizes()) {
2544:                    throw new UnableToParseDataException(
2545:                            "Unable to parse remaining data", remainderData(in)); //$NON-NLS-1$
2546:                }
2547:                return readID(in, TcpipSpy.getObjectIDSize());
2548:            }
2549:
2550:            private long readReferenceTypeID(DataInputStream in)
2551:                    throws IOException, UnableToParseDataException {
2552:                if (!TcpipSpy.hasSizes()) {
2553:                    throw new UnableToParseDataException(
2554:                            "Unable to parse remaining data", remainderData(in)); //$NON-NLS-1$
2555:                }
2556:                return readID(in, TcpipSpy.getReferenceTypeIDSize());
2557:            }
2558:
2559:            private long readFieldID(DataInputStream in) throws IOException,
2560:                    UnableToParseDataException {
2561:                if (!TcpipSpy.hasSizes()) {
2562:                    throw new UnableToParseDataException(
2563:                            "Unable to parse remaining data", remainderData(in)); //$NON-NLS-1$
2564:                }
2565:                return readID(in, TcpipSpy.getFieldIDSize());
2566:            }
2567:
2568:            private long readMethodID(DataInputStream in) throws IOException,
2569:                    UnableToParseDataException {
2570:                if (!TcpipSpy.hasSizes()) {
2571:                    throw new UnableToParseDataException(
2572:                            "Unable to parse remaining data", remainderData(in)); //$NON-NLS-1$
2573:                }
2574:                return readID(in, TcpipSpy.getMethodIDSize());
2575:            }
2576:
2577:            private long readFrameID(DataInputStream in) throws IOException,
2578:                    UnableToParseDataException {
2579:                if (!TcpipSpy.hasSizes()) {
2580:                    throw new UnableToParseDataException(
2581:                            "Unable to parse remaining data", remainderData(in)); //$NON-NLS-1$
2582:                }
2583:                return readID(in, TcpipSpy.getFrameIDSize());
2584:            }
2585:
2586:            private long readID(DataInputStream in, int size)
2587:                    throws IOException {
2588:                long id = 0;
2589:                for (int i = 0; i < size; i++) {
2590:                    int b = in.readUnsignedByte(); // Note that the byte must be treated as unsigned.
2591:                    id = id << 8 | b;
2592:                }
2593:                return id;
2594:            }
2595:
2596:            private void readAndPrintlnTaggedValue(String description,
2597:                    DataInputStream in) throws IOException,
2598:                    UnableToParseDataException {
2599:                byte tag = in.readByte();
2600:                readAndPrintlnUntaggedValue(description, in, tag, true);
2601:            }
2602:
2603:            private void readAndPrintlnUntaggedValue(String description,
2604:                    DataInputStream in, byte tag, boolean printTagValue)
2605:                    throws IOException, UnableToParseDataException {
2606:                printDescription(description);
2607:                int size;
2608:                boolean isId = false;
2609:                switch (tag) {
2610:                case VOID_TAG:
2611:                    printSignatureByte(tag, printTagValue);
2612:                    println();
2613:                    return;
2614:                case BOOLEAN_TAG:
2615:                    if (printTagValue) {
2616:                        printSignatureByte(tag, true);
2617:                        print(' ');
2618:                        println(in.readBoolean());
2619:                    } else {
2620:                        println(in.readBoolean());
2621:                        print(' ');
2622:                        printSignatureByte(tag, false);
2623:                    }
2624:                    return;
2625:                case BYTE_TAG:
2626:                    size = 1;
2627:                    break;
2628:                case CHAR_TAG:
2629:                case SHORT_TAG:
2630:                    size = 2;
2631:                    break;
2632:                case INT_TAG:
2633:                case FLOAT_TAG:
2634:                    size = 4;
2635:                    break;
2636:                case DOUBLE_TAG:
2637:                case LONG_TAG:
2638:                    size = 8;
2639:                    break;
2640:                case ARRAY_TAG:
2641:                case OBJECT_TAG:
2642:                case STRING_TAG:
2643:                case THREAD_TAG:
2644:                case THREAD_GROUP_TAG:
2645:                case CLASS_LOADER_TAG:
2646:                case CLASS_OBJECT_TAG:
2647:                    if (!TcpipSpy.hasSizes()) {
2648:                        throw new UnableToParseDataException(
2649:                                "Unable to parse remaining data", remainderData(in)); //$NON-NLS-1$
2650:                    }
2651:                    size = TcpipSpy.getObjectIDSize();
2652:                    isId = true;
2653:                    break;
2654:                default:
2655:                    size = 0;
2656:                    break;
2657:                }
2658:
2659:                long value = readID(in, size);
2660:                if (printTagValue) {
2661:                    printSignatureByte(tag, true);
2662:                    print(' ');
2663:                }
2664:                printHex(value, size);
2665:                if (isId) {
2666:                    printParanthetical(value);
2667:                } else {
2668:                    switch (tag) {
2669:                    case BYTE_TAG:
2670:                        printParanthetical((byte) value);
2671:                        break;
2672:                    case CHAR_TAG:
2673:                        printParanthetical((char) value);
2674:                        break;
2675:                    case SHORT_TAG:
2676:                        printParanthetical((short) value);
2677:                        break;
2678:                    case INT_TAG:
2679:                        printParanthetical((int) value);
2680:                        break;
2681:                    case FLOAT_TAG:
2682:                        printParanthetical(Float.intBitsToFloat((int) value));
2683:                        break;
2684:                    case DOUBLE_TAG:
2685:                        printParanthetical(Double.longBitsToDouble(value));
2686:                        break;
2687:                    case LONG_TAG:
2688:                        printParanthetical(value);
2689:                        break;
2690:                    }
2691:                }
2692:                if (!printTagValue) {
2693:                    print(' ');
2694:                    printSignatureByte(tag, false);
2695:                }
2696:                println();
2697:            }
2698:
2699:            private void printSignatureByte(byte signatureByte,
2700:                    boolean printValue) {
2701:                String type;
2702:                switch (signatureByte) {
2703:                case VOID_TAG:
2704:                    type = "void"; //$NON-NLS-1$
2705:                    break;
2706:                case BOOLEAN_TAG:
2707:                    type = "boolean"; //$NON-NLS-1$
2708:                    break;
2709:                case BYTE_TAG:
2710:                    type = "byte"; //$NON-NLS-1$
2711:                    break;
2712:                case CHAR_TAG:
2713:                    type = "char"; //$NON-NLS-1$
2714:                    break;
2715:                case SHORT_TAG:
2716:                    type = "short"; //$NON-NLS-1$
2717:                    break;
2718:                case INT_TAG:
2719:                    type = "int"; //$NON-NLS-1$
2720:                    break;
2721:                case FLOAT_TAG:
2722:                    type = "float"; //$NON-NLS-1$
2723:                    break;
2724:                case DOUBLE_TAG:
2725:                    type = "double"; //$NON-NLS-1$
2726:                    break;
2727:                case LONG_TAG:
2728:                    type = "long"; //$NON-NLS-1$
2729:                    break;
2730:                case ARRAY_TAG:
2731:                    type = "array id"; //$NON-NLS-1$
2732:                    break;
2733:                case OBJECT_TAG:
2734:                    type = "object id"; //$NON-NLS-1$
2735:                    break;
2736:                case STRING_TAG:
2737:                    type = "string id"; //$NON-NLS-1$
2738:                    break;
2739:                case THREAD_TAG:
2740:                    type = "thread id"; //$NON-NLS-1$
2741:                    break;
2742:                case THREAD_GROUP_TAG:
2743:                    type = "thread group id"; //$NON-NLS-1$
2744:                    break;
2745:                case CLASS_LOADER_TAG:
2746:                    type = "class loader id"; //$NON-NLS-1$
2747:                    break;
2748:                case CLASS_OBJECT_TAG:
2749:                    type = "class object id"; //$NON-NLS-1$
2750:                    break;
2751:                default:
2752:                    type = "unknown"; //$NON-NLS-1$
2753:                    break;
2754:                }
2755:                if (printValue) {
2756:                    printHex(signatureByte);
2757:                    print(" ("); //$NON-NLS-1$
2758:                    print(signatureByte);
2759:                    print(" - "); //$NON-NLS-1$
2760:                } else {
2761:                    print(" ("); //$NON-NLS-1$
2762:                }
2763:                print(type + ')');
2764:            }
2765:
2766:            private void readAndPrintLocation(DataInputStream in)
2767:                    throws IOException, UnableToParseDataException {
2768:                byte typeTag = in.readByte();
2769:                long classId = readReferenceTypeID(in);
2770:                long methodId = readMethodID(in);
2771:                long index = in.readLong();
2772:                printlnReferenceTypeIdWithTypeTag(
2773:                        "Location: class id:", classId, typeTag); //$NON-NLS-1$
2774:                printlnMethodId("          method id:", methodId); //$NON-NLS-1$
2775:                println("          index:", index); //$NON-NLS-1$
2776:            }
2777:
2778:            private void readAndPrintArrayRegion(DataInputStream in)
2779:                    throws IOException, UnableToParseDataException {
2780:                byte signatureByte = in.readByte();
2781:                int valuesCount = in.readInt();
2782:                printDescription("Signature byte:"); //$NON-NLS-1$
2783:                printSignatureByte(signatureByte, true);
2784:                println();
2785:                println("Values count:", valuesCount); //$NON-NLS-1$
2786:                switch (signatureByte) {
2787:                case ARRAY_TAG:
2788:                case OBJECT_TAG:
2789:                case STRING_TAG:
2790:                case THREAD_TAG:
2791:                case THREAD_GROUP_TAG:
2792:                case CLASS_LOADER_TAG:
2793:                case CLASS_OBJECT_TAG:
2794:                    for (int i = 0; i < valuesCount; i++) {
2795:                        readAndPrintlnTaggedValue("Value", in); //$NON-NLS-1$
2796:                    }
2797:                    break;
2798:                default:
2799:                    for (int i = 0; i < valuesCount; i++) {
2800:                        readAndPrintlnUntaggedValue(
2801:                                "Value", in, signatureByte, false); //$NON-NLS-1$
2802:                    }
2803:                    break;
2804:                }
2805:            }
2806:
2807:            protected void println(String description, int value) {
2808:                printDescription(description);
2809:                printHex(value);
2810:                printParanthetical(value);
2811:                println();
2812:            }
2813:
2814:            protected void println(String description, long value) {
2815:                printDescription(description);
2816:                printHex(value);
2817:                printParanthetical(value);
2818:                println();
2819:            }
2820:
2821:            protected void println(String description, String value) {
2822:                printDescription(description);
2823:                print('\"');
2824:                StringBuffer val = new StringBuffer();
2825:                int pos = 0, lastPos = 0;
2826:                while ((pos = value.indexOf('\n', lastPos)) != -1) {
2827:                    pos++;
2828:                    val.append(value.substring(lastPos, pos));
2829:                    val.append(shift);
2830:                    lastPos = pos;
2831:                }
2832:                val.append(value.substring(lastPos, value.length()));
2833:                print(val);
2834:                println('"');
2835:            }
2836:
2837:            protected void println(String description, boolean value) {
2838:                printDescription(description);
2839:                println(value);
2840:            }
2841:
2842:            protected void printlnReferenceTypeId(String description, long value) {
2843:                println(description, value, TcpipSpy.getReferenceTypeIDSize());
2844:            }
2845:
2846:            protected void printlnReferenceTypeIdWithTypeTag(
2847:                    String description, long value, byte typeTag) {
2848:                printDescription(description);
2849:                printRefTypeTagValue(typeTag);
2850:                print(" - "); //$NON-NLS-1$
2851:                printHex(value, TcpipSpy.getReferenceTypeIDSize());
2852:                printParanthetical(value);
2853:                println();
2854:            }
2855:
2856:            protected void printlnObjectId(String description, long value) {
2857:                printDescription(description);
2858:                printHex(value, TcpipSpy.getObjectIDSize());
2859:                if (value == 0) {
2860:                    println(" (NULL)"); //$NON-NLS-1$
2861:                } else {
2862:                    printParanthetical(value);
2863:                    println();
2864:                }
2865:            }
2866:
2867:            protected void printlnTaggedObjectId(String description,
2868:                    long value, byte signatureByte) {
2869:                printDescription(description);
2870:                printSignatureByte(signatureByte, true);
2871:                print(' ');
2872:                printHex(value, TcpipSpy.getReferenceTypeIDSize());
2873:                if (value == 0) {
2874:                    println(" (NULL)"); //$NON-NLS-1$
2875:                } else {
2876:                    printParanthetical(value);
2877:                    println();
2878:                }
2879:            }
2880:
2881:            protected void printlnFieldId(String description, long value) {
2882:                println(description, value, TcpipSpy.getFieldIDSize());
2883:            }
2884:
2885:            protected void printlnMethodId(String description, long value) {
2886:                println(description, value, TcpipSpy.getMethodIDSize());
2887:            }
2888:
2889:            protected void printlnFrameId(String description, long value) {
2890:                println(description, value, TcpipSpy.getFrameIDSize());
2891:            }
2892:
2893:            protected void println(String description, long value, int size) {
2894:                printDescription(description);
2895:                printHex(value, size);
2896:                printParanthetical(value);
2897:                println();
2898:            }
2899:
2900:            protected void printDescription(String description) {
2901:                // current max length = 36 (+2 pad)
2902:                int width = 38 - description.length();
2903:                print(description);
2904:                write(padding, 0, width);
2905:            }
2906:
2907:            protected void printHexString(String hex, int width) {
2908:                width -= hex.length();
2909:                print("0x"); //$NON-NLS-1$
2910:                write(zeros, 0, width);
2911:                print(hex);
2912:            }
2913:
2914:            protected void printHex(long l, int byteNumber) {
2915:                printHexString(Long.toHexString(l).toUpperCase(),
2916:                        byteNumber * 2);
2917:            }
2918:
2919:            protected void printHex(byte b) {
2920:                printHexString(Integer.toHexString(b & 0xFF).toUpperCase(), 2);
2921:            }
2922:
2923:            protected void printHex(int i) {
2924:                printHexString(Integer.toHexString(i).toUpperCase(), 8);
2925:            }
2926:
2927:            protected void printHex(long l) {
2928:                printHexString(Long.toHexString(l).toUpperCase(), 16);
2929:            }
2930:
2931:            protected void printHex(byte[] b) {
2932:                if (b == null) {
2933:                    println("NULL"); //$NON-NLS-1$
2934:                    return;
2935:                }
2936:                int i, length;
2937:                for (i = 0, length = b.length; i < length; i++) {
2938:                    String hexa = Integer.toHexString(b[i]).toUpperCase();
2939:                    if (hexa.length() == 1) {
2940:                        print('0');
2941:                    }
2942:                    print(hexa);
2943:                    if ((i % 32) == 0 && i != 0) {
2944:                        println();
2945:                        print(shift);
2946:                    } else {
2947:                        print(' ');
2948:                    }
2949:                }
2950:                println();
2951:            }
2952:
2953:            protected void printParanthetical(byte i) {
2954:                print(" ("); //$NON-NLS-1$
2955:                print(i);
2956:                print(')');
2957:            }
2958:
2959:            protected void printParanthetical(char i) {
2960:                print(" ("); //$NON-NLS-1$
2961:                print(i);
2962:                print(')');
2963:            }
2964:
2965:            protected void printParanthetical(short i) {
2966:                print(" ("); //$NON-NLS-1$
2967:                print(i);
2968:                print(')');
2969:            }
2970:
2971:            protected void printParanthetical(int i) {
2972:                print(" ("); //$NON-NLS-1$
2973:                print(i);
2974:                print(')');
2975:            }
2976:
2977:            protected void printParanthetical(long l) {
2978:                print(" ("); //$NON-NLS-1$
2979:                print(l);
2980:                print(')');
2981:            }
2982:
2983:            protected void printParanthetical(float f) {
2984:                print(" ("); //$NON-NLS-1$
2985:                print(f);
2986:                print(')');
2987:            }
2988:
2989:            protected void printParanthetical(double d) {
2990:                print(" ("); //$NON-NLS-1$
2991:                print(d);
2992:                print(')');
2993:            }
2994:
2995:            protected void printParanthetical(String s) {
2996:                print(" ("); //$NON-NLS-1$
2997:                print(s);
2998:                print(')');
2999:            }
3000:
3001:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.