001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Aleksey V. Yantsen
021: * @version $Revision: 1.5 $
022: */
023:
024: /**
025: * Created on 10.25.2004
026: */package org.apache.harmony.jpda.tests.framework.jdwp;
027:
028: /**
029: * This class defines various constants from JDWP specifications.
030: * Each class has getName function to convert a constant value
031: * to string equivalent.
032: */
033: public class JDWPConstants {
034:
035: /**
036: * JDWP ThreadStatus constants
037: */
038: public static class ThreadStatus {
039:
040: public static final byte ZOMBIE = 0;
041:
042: public static final byte RUNNING = 1;
043:
044: public static final byte SLEEPING = 2;
045:
046: public static final byte MONITOR = 3;
047:
048: public static final byte WAIT = 4;
049:
050: /**
051: * Gets name for corresponding constant value.
052: *
053: * @param status
054: * a constant from ones declared in this class
055: * @return String
056: */
057: public static String getName(int status) {
058: switch (status) {
059: case ZOMBIE:
060: return "ZOMBIE";
061: case RUNNING:
062: return "RUNNING";
063: case SLEEPING:
064: return "SLEEPING";
065: case MONITOR:
066: return "MONITOR";
067: case WAIT:
068: return "WAIT";
069: default:
070: return "<unknown>";
071: }
072: }
073: }
074:
075: /**
076: * JDWP SuspendStatus constants
077: */
078: public static class SuspendStatus {
079:
080: public static final byte SUSPEND_STATUS_SUSPENDED = 1;
081:
082: /**
083: * Gets name for corresponding constant value.
084: *
085: * @param status
086: * a constant from ones declared in this class
087: * @return String
088: */
089: public static String getName(int status) {
090: if (status == SUSPEND_STATUS_SUSPENDED)
091: return "SUSPENDED";
092: return "NONE";
093: }
094: }
095:
096: /**
097: * JDWP ClassStatus constants
098: */
099: public static class ClassStatus {
100:
101: public static final byte VERIFIED = 1;
102:
103: public static final byte PREPARED = 2;
104:
105: public static final byte INITIALIZED = 4;
106:
107: public static final byte ERROR = 8;
108:
109: // it looks like JDWP spec becomes out of date
110: // see JVMTI specification for GetClassStatus:
111: //
112: public static final byte ARRAY = 16;
113:
114: public static final byte PRIMITIVE = 32;
115:
116: /**
117: * Gets name for corresponding constant value.
118: *
119: * @param status
120: * a constant from ones declared in this class
121: * @return String
122: */
123: public static String getName(int status) {
124:
125: String returnValue = "";
126: if ((status & VERIFIED) == VERIFIED)
127: returnValue += "|VERIFIED";
128: if ((status & PREPARED) == PREPARED)
129: returnValue += "|PREPARED";
130: if ((status & INITIALIZED) == INITIALIZED)
131: returnValue += "|INITIALIZED";
132: if ((status & ERROR) == ERROR)
133: returnValue += "|ERROR";
134: if ((status & ARRAY) == ARRAY)
135: returnValue += "|ARRAY";
136: if ((status & PRIMITIVE) == PRIMITIVE)
137: returnValue += "|PRIMITIVE";
138:
139: if (returnValue.equals("")) {
140: returnValue = "NONE";
141: } else {
142: returnValue = returnValue.substring(1);
143: }
144:
145: return returnValue;
146: }
147: }
148:
149: /**
150: * JDWP TypeTag constants
151: */
152: public static class TypeTag {
153:
154: public static final byte CLASS = 1;
155:
156: public static final byte INTERFACE = 2;
157:
158: public static final byte ARRAY = 3;
159:
160: /**
161: * Gets name for corresponding constant value.
162: *
163: * @param refTypeTag
164: * a constant from ones declared in this class
165: * @return String
166: */
167: public static String getName(byte refTypeTag) {
168: switch (refTypeTag) {
169: case CLASS:
170: return "CLASS";
171: case INTERFACE:
172: return "INTERFACE";
173: case ARRAY:
174: return "ARRAY";
175: default:
176: return "<unknown>";
177: }
178: }
179: }
180:
181: /**
182: * JDWP Tag constants
183: */
184: public static class Tag {
185:
186: public static final byte ARRAY_TAG = 91;
187:
188: public static final byte BYTE_TAG = 66;
189:
190: public static final byte CHAR_TAG = 67;
191:
192: public static final byte OBJECT_TAG = 76;
193:
194: public static final byte FLOAT_TAG = 70;
195:
196: public static final byte DOUBLE_TAG = 68;
197:
198: public static final byte INT_TAG = 73;
199:
200: public static final byte LONG_TAG = 74;
201:
202: public static final byte SHORT_TAG = 83;
203:
204: public static final byte VOID_TAG = 86;
205:
206: public static final byte BOOLEAN_TAG = 90;
207:
208: public static final byte STRING_TAG = 115;
209:
210: public static final byte THREAD_TAG = 116;
211:
212: public static final byte THREAD_GROUP_TAG = 103;
213:
214: public static final byte CLASS_LOADER_TAG = 108;
215:
216: public static final byte CLASS_OBJECT_TAG = 99;
217:
218: public static final byte NO_TAG = 0;
219:
220: /**
221: * Gets name for corresponding constant value.
222: *
223: * @param tag
224: * a constant from ones declared in this class
225: * @return String
226: */
227: public static String getName(byte tag) {
228: switch (tag) {
229: case ARRAY_TAG:
230: return "ARRAY_TAG";
231: case BYTE_TAG:
232: return "BYTE_TAG";
233: case CHAR_TAG:
234: return "CHAR_TAG";
235: case OBJECT_TAG:
236: return "OBJECT_TAG";
237: case FLOAT_TAG:
238: return "FLOAT_TAG";
239: case DOUBLE_TAG:
240: return "DOUBLE_TAG";
241: case INT_TAG:
242: return "INT_TAG";
243: case LONG_TAG:
244: return "LONG_TAG";
245: case SHORT_TAG:
246: return "SHORT_TAG";
247: case VOID_TAG:
248: return "VOID_TAG";
249: case BOOLEAN_TAG:
250: return "BOOLEAN_TAG";
251: case STRING_TAG:
252: return "STRING_TAG";
253: case THREAD_TAG:
254: return "THREAD_TAG";
255: case THREAD_GROUP_TAG:
256: return "THREAD_GROUP_TAG";
257: case CLASS_LOADER_TAG:
258: return "CLASS_LOADER_TAG";
259: case CLASS_OBJECT_TAG:
260: return "CLASS_OBJECT_TAG";
261: case NO_TAG:
262: return "NO_TAG";
263: default:
264: return "<unknown>";
265: }
266: }
267: }
268:
269: /**
270: * JDWP EventKind constants
271: */
272: public static class EventKind {
273:
274: public static final byte SINGLE_STEP = 1;
275:
276: public static final byte BREAKPOINT = 2;
277:
278: public static final byte FRAME_POP = 3;
279:
280: public static final byte EXCEPTION = 4;
281:
282: public static final byte USER_DEFINED = 5;
283:
284: public static final byte THREAD_START = 6;
285:
286: public static final byte THREAD_END = 7;
287:
288: public static final byte THREAD_DEATH = THREAD_END;
289:
290: public static final byte CLASS_PREPARE = 8;
291:
292: public static final byte CLASS_UNLOAD = 9;
293:
294: public static final byte CLASS_LOAD = 10;
295:
296: public static final byte FIELD_ACCESS = 20;
297:
298: public static final byte FIELD_MODIFICATION = 21;
299:
300: public static final byte EXCEPTION_CATCH = 30;
301:
302: public static final byte METHOD_ENTRY = 40;
303:
304: public static final byte METHOD_EXIT = 41;
305:
306: public static final byte VM_INIT = 90;
307:
308: public static final byte VM_START = VM_INIT;
309:
310: public static final byte VM_DEATH = 99;
311:
312: public static final byte VM_DISCONNECTED = 100;
313:
314: /**
315: * Gets name for corresponding constant value.
316: *
317: * @param eventKind
318: * a constant from ones declared in this class
319: * @return String
320: */
321: public static String getName(byte eventKind) {
322: switch (eventKind) {
323: case SINGLE_STEP:
324: return "SINGLE_STEP";
325: case BREAKPOINT:
326: return "BREAKPOINT";
327: case FRAME_POP:
328: return "FRAME_POP";
329: case EXCEPTION:
330: return "EXCEPTION";
331: case USER_DEFINED:
332: return "USER_DEFINED";
333: case THREAD_START:
334: return "THREAD_START";
335: case THREAD_END:
336: return "THREAD_END";
337: case CLASS_PREPARE:
338: return "CLASS_PREPARE";
339: case CLASS_UNLOAD:
340: return "CLASS_UNLOAD";
341: case CLASS_LOAD:
342: return "CLASS_LOAD";
343: case FIELD_ACCESS:
344: return "FIELD_ACCESS";
345: case FIELD_MODIFICATION:
346: return "FIELD_MODIFICATION";
347: case EXCEPTION_CATCH:
348: return "EXCEPTION_CATCH";
349: case METHOD_ENTRY:
350: return "METHOD_ENTRY";
351: case METHOD_EXIT:
352: return "METHOD_EXIT";
353: case VM_INIT:
354: return "VM_INIT";
355: case VM_DEATH:
356: return "VM_DEATH";
357: case VM_DISCONNECTED:
358: return "VM_DISCONNECTED";
359: default:
360: return "<unknown>";
361: }
362: }
363: }
364:
365: /**
366: * JDWP Error constants
367: */
368: public static class Error {
369:
370: public static final int NONE = 0;
371:
372: public static final int INVALID_THREAD = 10;
373:
374: public static final int INVALID_THREAD_GROUP = 11;
375:
376: public static final int INVALID_PRIORITY = 12;
377:
378: public static final int THREAD_NOT_SUSPENDED = 13;
379:
380: public static final int THREAD_SUSPENDED = 14;
381:
382: public static final int INVALID_OBJECT = 20;
383:
384: public static final int INVALID_CLASS = 21;
385:
386: public static final int CLASS_NOT_PREPARED = 22;
387:
388: public static final int INVALID_METHODID = 23;
389:
390: public static final int INVALID_LOCATION = 24;
391:
392: public static final int INVALID_FIELDID = 25;
393:
394: public static final int INVALID_FRAMEID = 30;
395:
396: public static final int NO_MORE_FRAMES = 31;
397:
398: public static final int OPAQUE_FRAME = 32;
399:
400: public static final int NOT_CURRENT_FRAME = 33;
401:
402: public static final int TYPE_MISMATCH = 34;
403:
404: public static final int INVALID_SLOT = 35;
405:
406: public static final int DUPLICATE = 40;
407:
408: public static final int NOT_FOUND = 41;
409:
410: public static final int INVALID_MONITOR = 50;
411:
412: public static final int NOT_MONITOR_OWNER = 51;
413:
414: public static final int INTERRUPT = 52;
415:
416: public static final int INVALID_CLASS_FORMAT = 60;
417:
418: public static final int CIRCULAR_CLASS_DEFENITION = 61;
419:
420: public static final int FAILS_VERIFICATION = 62;
421:
422: public static final int ADD_METHOD_NOT_IMPLEMENTED = 63;
423:
424: public static final int SCHEMA_CHANGE_NOT_IMPLEMENTED = 64;
425:
426: public static final int INVALID_TYPESTATE = 65;
427:
428: public static final int HIERARCHY_CHANGE_NOT_IMPLEMENTED = 66;
429:
430: public static final int DELETE_METHOD_NOT_IMPLEMENTED = 67;
431:
432: public static final int UNSUPPORTED_VERSION = 68;
433:
434: public static final int NAMES_DONT_MATCH = 69;
435:
436: public static final int CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 70;
437:
438: public static final int METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 71;
439:
440: public static final int NOT_IMPLEMENTED = 99;
441:
442: public static final int NULL_POINTER = 100;
443:
444: public static final int ABSENT_INFORMATION = 101;
445:
446: public static final int INVALID_EVENT_TYPE = 102;
447:
448: public static final int ILLEGAL_ARGUMENT = 103;
449:
450: public static final int OUT_OF_MEMORY = 110;
451:
452: public static final int ACCESS_DENIED = 111;
453:
454: public static final int VM_DEAD = 112;
455:
456: public static final int INTERNAL = 113;
457:
458: public static final int UNATTACHED_THREAD = 115;
459:
460: public static final int INVALID_TAG = 500;
461:
462: public static final int ALREADY_INVOKING = 502;
463:
464: public static final int INVALID_INDEX = 503;
465:
466: public static final int INVALID_LENGTH = 504;
467:
468: public static final int INVALID_STRING = 506;
469:
470: public static final int INVALID_CLASS_LOADER = 507;
471:
472: public static final int INVALID_ARRAY = 508;
473:
474: public static final int TRANSPORT_LOAD = 509;
475:
476: public static final int TRANSPORT_INIT = 510;
477:
478: public static final int NATIVE_METHOD = 511;
479:
480: public static final int INVALID_COUNT = 512;
481:
482: /**
483: * Gets name for corresponding constant value.
484: *
485: * @param errorCode
486: * a constant from ones declared in this class
487: * @return String
488: */
489: public static String getName(int errorCode) {
490: switch (errorCode) {
491: case NONE:
492: return "NONE";
493: case INVALID_THREAD:
494: return "INVALID_THREAD";
495: case INVALID_THREAD_GROUP:
496: return "INVALID_THREAD_GROUP";
497: case INVALID_PRIORITY:
498: return "INVALID_PRIORITY";
499: case THREAD_NOT_SUSPENDED:
500: return "THREAD_NOT_SUSPENDED";
501: case THREAD_SUSPENDED:
502: return "THREAD_SUSPENDED";
503: case INVALID_OBJECT:
504: return "INVALID_OBJECT";
505: case INVALID_CLASS:
506: return "INVALID_CLASS";
507: case CLASS_NOT_PREPARED:
508: return "CLASS_NOT_PREPARED";
509: case INVALID_METHODID:
510: return "INVALID_METHODID";
511: case INVALID_LOCATION:
512: return "INVALID_LOCATION";
513: case INVALID_FIELDID:
514: return "INVALID_FIELDID";
515: case INVALID_FRAMEID:
516: return "INVALID_FRAMEID";
517: case NO_MORE_FRAMES:
518: return "NO_MORE_FRAMES";
519: case OPAQUE_FRAME:
520: return "OPAQUE_FRAME";
521: case NOT_CURRENT_FRAME:
522: return "NOT_CURRENT_FRAME";
523: case TYPE_MISMATCH:
524: return "TYPE_MISMATCH";
525: case INVALID_SLOT:
526: return "INVALID_SLOT";
527: case DUPLICATE:
528: return "DUPLICATE";
529: case NOT_FOUND:
530: return "NOT_FOUND";
531: case INVALID_MONITOR:
532: return "INVALID_MONITOR";
533: case NOT_MONITOR_OWNER:
534: return "NOT_MONITOR_OWNER";
535: case INTERRUPT:
536: return "INTERRUPT";
537: case INVALID_CLASS_FORMAT:
538: return "INVALID_CLASS_FORMAT";
539: case CIRCULAR_CLASS_DEFENITION:
540: return "CIRCULAR_CLASS_DEFENITION";
541: case FAILS_VERIFICATION:
542: return "FAILS_VERIFICATION";
543: case ADD_METHOD_NOT_IMPLEMENTED:
544: return "ADD_METHOD_NOT_IMPLEMENTED";
545: case SCHEMA_CHANGE_NOT_IMPLEMENTED:
546: return "SCHEMA_CHANGE_NOT_IMPLEMENTED";
547: case INVALID_TYPESTATE:
548: return "INVALID_TYPESTATE";
549: case HIERARCHY_CHANGE_NOT_IMPLEMENTED:
550: return "HIERARCHY_CHANGE_NOT_IMPLEMENTED";
551: case DELETE_METHOD_NOT_IMPLEMENTED:
552: return "DELETE_METHOD_NOT_IMPLEMENTED";
553: case UNSUPPORTED_VERSION:
554: return "UNSUPPORTED_VERSION";
555: case NAMES_DONT_MATCH:
556: return "NAMES_DONT_MATCH";
557: case CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
558: return "CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED";
559: case METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
560: return "METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED";
561: case NOT_IMPLEMENTED:
562: return "NOT_IMPLEMENTED";
563: case NULL_POINTER:
564: return "NULL_POINTER";
565: case ABSENT_INFORMATION:
566: return "ABSENT_INFORMATION";
567: case INVALID_EVENT_TYPE:
568: return "INVALID_EVENT_TYPE";
569: case ILLEGAL_ARGUMENT:
570: return "ILLEGAL_ARGUMENT";
571: case OUT_OF_MEMORY:
572: return "OUT_OF_MEMORY";
573: case ACCESS_DENIED:
574: return "ACCESS_DENIED";
575: case VM_DEAD:
576: return "VM_DEAD";
577: case INTERNAL:
578: return "INTERNAL";
579: case UNATTACHED_THREAD:
580: return "UNATTACHED_THREAD";
581: case INVALID_TAG:
582: return "INVALID_TAG";
583: case ALREADY_INVOKING:
584: return "ALREADY_INVOKING";
585: case INVALID_INDEX:
586: return "INVALID_INDEX";
587: case INVALID_LENGTH:
588: return "INVALID_LENGTH";
589: case INVALID_STRING:
590: return "INVALID_STRING";
591: case INVALID_CLASS_LOADER:
592: return "INVALID_CLASS_LOADER";
593: case INVALID_ARRAY:
594: return "INVALID_ARRAY";
595: case TRANSPORT_LOAD:
596: return "TRANSPORT_LOAD";
597: case TRANSPORT_INIT:
598: return "TRANSPORT_INIT";
599: case NATIVE_METHOD:
600: return "NATIVE_METHOD";
601: case INVALID_COUNT:
602: return "INVALID_COUNT";
603: default:
604: return "<unknown>";
605: }
606: }
607: }
608:
609: /**
610: * JDWP StepDepth constants
611: */
612: public static class StepDepth {
613:
614: public static final byte INTO = 0;
615:
616: public static final byte OVER = 1;
617:
618: public static final byte OUT = 2;
619:
620: /**
621: * Gets name for corresponding constant value.
622: *
623: * @param code
624: * a constant from ones declared in this class
625: * @return String
626: */
627: public static String getName(int code) {
628: switch (code) {
629: case INTO:
630: return "INTO";
631: case OVER:
632: return "OVER";
633: case OUT:
634: return "OUT";
635: default:
636: return "<unknown>";
637: }
638: }
639: }
640:
641: /**
642: * JDWP StepSize constants
643: */
644: public static class StepSize {
645:
646: public static final byte MIN = 0;
647:
648: public static final byte LINE = 1;
649:
650: /**
651: * Gets name for corresponding constant value.
652: *
653: * @param code
654: * a constant from ones declared in this class
655: * @return String
656: */
657: public static String getName(int code) {
658: switch (code) {
659: case MIN:
660: return "MIN";
661: case LINE:
662: return "LINE";
663: default:
664: return "<unknown>";
665: }
666: }
667: }
668:
669: /**
670: * JDWP SuspendPolicy constants
671: */
672: public static class SuspendPolicy {
673:
674: public static final byte NONE = 0;
675:
676: public static final byte EVENT_THREAD = 1;
677:
678: public static final byte ALL = 2;
679:
680: /**
681: * Gets name for corresponding constant value.
682: *
683: * @param code
684: * a constant from ones declared in this class
685: * @return String
686: */
687: public static String getName(int code) {
688: switch (code) {
689: case NONE:
690: return "NONE";
691: case EVENT_THREAD:
692: return "EVENT_THREAD";
693: case ALL:
694: return "ALL";
695: default:
696: return "<unknown>";
697: }
698: }
699: }
700:
701: /**
702: * JDWP InvokeOptions constants
703: */
704: public static class InvokeOptions {
705: public static final byte INVOKE_SINGLE_THREADED = 0x01;
706:
707: public static final byte INVOKE_NONVIRTUAL = 0x02;
708:
709: /**
710: * Gets name for corresponding constant value.
711: *
712: * @param code
713: * a constant from ones declared in this class
714: * @return String
715: */
716: public static String getName(int code) {
717: String buf = "NONE";
718: if ((code & INVOKE_SINGLE_THREADED) != 0) {
719: buf += "|INVOKE_SINGLE_THREADED";
720: }
721: if ((code & INVOKE_NONVIRTUAL) != 0) {
722: buf += "|INVOKE_NONVIRTUAL";
723: }
724: if ((code & ~(INVOKE_SINGLE_THREADED | INVOKE_NONVIRTUAL)) != 0) {
725: buf += "|<unknown>";
726: }
727: return buf;
728: }
729: }
730:
731: /**
732: * Field access flags
733: */
734: public static class FieldAccess {
735:
736: /**
737: * Is public; may be accessed from outside its package; Any field.
738: */
739: public static final int ACC_PUBLIC = 0x0001;
740:
741: /**
742: * Is private; usable only within the defining class; Class field.
743: */
744: public static final int ACC_PRIVATE = 0x0002;
745:
746: /**
747: * Is protected; may be accessed within subclasses; Class field.
748: */
749: public static final int ACC_PROTECTED = 0x0004;
750:
751: /**
752: * Is static; Any field.
753: */
754: public static final int ACC_STATIC = 0x0008;
755:
756: /**
757: * Is final; no further overriding or assignment after initialization;
758: * Any field.
759: */
760: public static final int ACC_FINAL = 0x0010;
761:
762: /**
763: * Is volatile; cannot be cached; Class field.
764: */
765: public static final int ACC_VOLATILE = 0x0040;
766:
767: /**
768: * Is transient; not written or read by a persistent object manager;
769: * Class field.
770: */
771: public static final int ACC_TRANSIENT = 0x0080;
772:
773: /**
774: * Gets name for corresponding constant value.
775: *
776: * @param code
777: * a constant from ones declared in this class
778: * @return String
779: */
780: public static String getName(int code) {
781: switch (code) {
782: case ACC_PUBLIC:
783: return "ACC_PUBLIC";
784: case ACC_PRIVATE:
785: return "ACC_PRIVATE";
786: case ACC_PROTECTED:
787: return "ACC_PROTECTED";
788: case ACC_STATIC:
789: return "ACC_STATIC";
790: case ACC_FINAL:
791: return "ACC_FINAL";
792: case ACC_VOLATILE:
793: return "ACC_VOLATILE";
794: case ACC_TRANSIENT:
795: return "ACC_TRANSIENT";
796: default:
797: return "<unknown>";
798: }
799: }
800: }
801: }
|