Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/jdwp/CommandPacket.java
41161 views
1
/*
2
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package nsk.share.jdwp;
25
26
import nsk.share.*;
27
28
/**
29
* This class represents a JDWP command packet.
30
*/
31
public class CommandPacket extends Packet {
32
33
/**
34
* Static counter for enumeration of the command packets.
35
*/
36
private static int nextID = 1;
37
38
/**
39
* Return next free number for enumeration of the command packets.
40
*/
41
public static int getLastID() {
42
return (nextID - 1);
43
}
44
45
/**
46
* Make JDWP command packet for specified command.
47
*/
48
public CommandPacket(int fullCommand) {
49
super();
50
51
setPacketID(nextID++);
52
setFlags(JDWP.Flag.NONE);
53
setFullCommand(fullCommand);
54
}
55
56
/**
57
* Make JDWP command packet for specified command.
58
*/
59
public CommandPacket(int fullCommand, int id) {
60
super();
61
62
setPacketID(id);
63
setFlags(JDWP.Flag.NONE);
64
setFullCommand(fullCommand);
65
}
66
67
/**
68
* Make command packet with data from the specified byte buffer.
69
*/
70
// public CommandPacket(ByteBuffer packet) {
71
public CommandPacket(Packet packet) {
72
super(packet);
73
}
74
75
/**
76
* Return full command number for this packet.
77
*/
78
public int getFullCommand() {
79
int id = 0;
80
81
try {
82
id = (int) getID(FullCommandOffset, 2);
83
}
84
catch (BoundException e) {
85
throw new Failure("Caught unexpected exception while getting command number from header:\n\t"
86
+ e);
87
}
88
89
return id;
90
}
91
92
/**
93
* Return short command number for this packet.
94
*/
95
public byte getCommand() {
96
byte id = 0;
97
98
try {
99
id = getByte(CommandOffset);
100
}
101
catch (BoundException e) {
102
throw new Failure("Caught unexpected exception while getting command number from header:\n\t"
103
+ e);
104
}
105
106
return id;
107
}
108
109
/**
110
* Return command set number for this packet.
111
*/
112
public byte getCommandSet() {
113
byte id = 0;
114
115
try {
116
id = getByte(CommandSetOffset);
117
}
118
catch (BoundException e) {
119
throw new Failure("Caught unexpected exception while getting command number from header:\n\t"
120
+ e);
121
}
122
123
return id;
124
}
125
126
/**
127
* Assign command number for this packet.
128
*/
129
public void setFullCommand(int fullCommand) {
130
try {
131
putID(FullCommandOffset, fullCommand, 2);
132
}
133
catch (BoundException e) {
134
throw new Failure("Caught unexpected exception while setting command number into header: "
135
+ e);
136
}
137
}
138
139
/**
140
* Return string representation of the command packet header.
141
*/
142
public String headerToString() {
143
return super.headerToString()
144
+ " " + toHexString(CommandSetOffset, 4) + " (cmd set): 0x" + toHexDecString(getCommandSet(), 2) + "\n"
145
+ " " + toHexString(CommandOffset, 4) + " (command): 0x" + toHexDecString(getCommand(), 2) + "\n";
146
}
147
148
}
149
150