60 sb.append('Z');
61 } else if (typeName.equals("byte")) {
62 sb.append('B');
63 } else if (typeName.equals("char")) {
64 sb.append('C');
65 } else if (typeName.equals("short")) {
66 sb.append('S');
67 } else if (typeName.equals("int")) {
68 sb.append('I');
69 } else if (typeName.equals("long")) {
70 sb.append('J');
71 } else if (typeName.equals("float")) {
72 sb.append('F');
73 } else if (typeName.equals("double")) {
74 sb.append('D');
75 } else {
76 sb.append('L');
77 index = typeName.indexOf("/"); // check if it's a hidden class
78 if (index < 0) {
79 sb.append(typeName.replace('.', '/'));
80 } else {
81 sb.append(typeName.substring(0, index).replace('.', '/'));
82 sb.append(".");
83 sb.append(typeName.substring(index+1, typeName.length()));
84 }
85 sb.append(';');
86 }
87
88 return sb.toString();
89 }
90
91 String typeName() {
92 return typeNameList().get(typeNameList().size()-1);
93 }
94
95 List<String> argumentTypeNames() {
96 return typeNameList().subList(0, typeNameList().size() - 1);
97 }
98
99 String signature() {
100 return signatureList().get(signatureList().size()-1);
101 }
102
103 List<String> argumentSignatures() {
104 return signatureList().subList(0, signatureList().size() - 1);
105 }
148 typeNameList.add(elem);
149 }
150 if (typeNameList.size() == 0) {
151 throw new IllegalArgumentException("Invalid JNI signature '" +
152 signature + "'");
153 }
154 }
155 return typeNameList;
156 }
157
158 private String nextSignature() {
159 char key = signature.charAt(currentIndex++);
160
161 switch(key) {
162 case (JDWP.Tag.ARRAY):
163 return key + nextSignature();
164
165 case (JDWP.Tag.OBJECT):
166 int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
167 currentIndex);
168 String retVal = signature.substring(currentIndex - 1,
169 endClass + 1);
170 currentIndex = endClass + 1;
171 return retVal;
172
173 case (JDWP.Tag.VOID):
174 case (JDWP.Tag.BOOLEAN):
175 case (JDWP.Tag.BYTE):
176 case (JDWP.Tag.CHAR):
177 case (JDWP.Tag.SHORT):
178 case (JDWP.Tag.INT):
179 case (JDWP.Tag.LONG):
180 case (JDWP.Tag.FLOAT):
181 case (JDWP.Tag.DOUBLE):
182 return String.valueOf(key);
183
184 case SIGNATURE_ENDFUNC:
185 case SIGNATURE_FUNC:
186 return nextSignature();
187
188 default:
189 throw new IllegalArgumentException(
190 "Invalid JNI signature character '" + key + "'");
193 }
194
195 private String nextTypeName() {
196 char key = signature.charAt(currentIndex++);
197
198 switch(key) {
199 case (JDWP.Tag.ARRAY):
200 return nextTypeName() + "[]";
201
202 case (JDWP.Tag.BYTE):
203 return "byte";
204
205 case (JDWP.Tag.CHAR):
206 return "char";
207
208 case (JDWP.Tag.OBJECT):
209 int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
210 currentIndex);
211 String retVal = signature.substring(currentIndex,
212 endClass);
213 int index = retVal.indexOf(".");
214 if (index < 0) {
215 retVal = retVal.replace('/', '.');
216 } else {
217 retVal = retVal.substring(0, index).replace('/', '.') + "/" +
218 retVal.substring(index + 1, retVal.length());
219 }
220 currentIndex = endClass + 1;
221 return retVal;
222
223 case (JDWP.Tag.FLOAT):
224 return "float";
225
226 case (JDWP.Tag.DOUBLE):
227 return "double";
228
229 case (JDWP.Tag.INT):
230 return "int";
231
232 case (JDWP.Tag.LONG):
233 return "long";
234
235 case (JDWP.Tag.SHORT):
236 return "short";
237
238 case (JDWP.Tag.VOID):
239 return "void";
240
|
60 sb.append('Z');
61 } else if (typeName.equals("byte")) {
62 sb.append('B');
63 } else if (typeName.equals("char")) {
64 sb.append('C');
65 } else if (typeName.equals("short")) {
66 sb.append('S');
67 } else if (typeName.equals("int")) {
68 sb.append('I');
69 } else if (typeName.equals("long")) {
70 sb.append('J');
71 } else if (typeName.equals("float")) {
72 sb.append('F');
73 } else if (typeName.equals("double")) {
74 sb.append('D');
75 } else {
76 sb.append('L');
77 index = typeName.indexOf("/"); // check if it's a hidden class
78 if (index < 0) {
79 sb.append(typeName.replace('.', '/'));
80 sb.append(";");
81 } else {
82 sb.append(typeName.substring(0, index).replace('.', '/'));
83 sb.append(";");
84 sb.append(typeName.substring(index, typeName.length()));
85 }
86 }
87
88 return sb.toString();
89 }
90
91 String typeName() {
92 return typeNameList().get(typeNameList().size()-1);
93 }
94
95 List<String> argumentTypeNames() {
96 return typeNameList().subList(0, typeNameList().size() - 1);
97 }
98
99 String signature() {
100 return signatureList().get(signatureList().size()-1);
101 }
102
103 List<String> argumentSignatures() {
104 return signatureList().subList(0, signatureList().size() - 1);
105 }
148 typeNameList.add(elem);
149 }
150 if (typeNameList.size() == 0) {
151 throw new IllegalArgumentException("Invalid JNI signature '" +
152 signature + "'");
153 }
154 }
155 return typeNameList;
156 }
157
158 private String nextSignature() {
159 char key = signature.charAt(currentIndex++);
160
161 switch(key) {
162 case (JDWP.Tag.ARRAY):
163 return key + nextSignature();
164
165 case (JDWP.Tag.OBJECT):
166 int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
167 currentIndex);
168 String retVal;
169 if ((endClass+1) < signature.length() && signature.charAt(endClass+1) == '/') {
170 // hidden class
171 retVal = signature.substring(currentIndex - 1);
172 currentIndex = signature.length();
173 } else {
174 retVal = signature.substring(currentIndex - 1, endClass + 1);
175 currentIndex = endClass + 1;
176 }
177 return retVal;
178
179 case (JDWP.Tag.VOID):
180 case (JDWP.Tag.BOOLEAN):
181 case (JDWP.Tag.BYTE):
182 case (JDWP.Tag.CHAR):
183 case (JDWP.Tag.SHORT):
184 case (JDWP.Tag.INT):
185 case (JDWP.Tag.LONG):
186 case (JDWP.Tag.FLOAT):
187 case (JDWP.Tag.DOUBLE):
188 return String.valueOf(key);
189
190 case SIGNATURE_ENDFUNC:
191 case SIGNATURE_FUNC:
192 return nextSignature();
193
194 default:
195 throw new IllegalArgumentException(
196 "Invalid JNI signature character '" + key + "'");
199 }
200
201 private String nextTypeName() {
202 char key = signature.charAt(currentIndex++);
203
204 switch(key) {
205 case (JDWP.Tag.ARRAY):
206 return nextTypeName() + "[]";
207
208 case (JDWP.Tag.BYTE):
209 return "byte";
210
211 case (JDWP.Tag.CHAR):
212 return "char";
213
214 case (JDWP.Tag.OBJECT):
215 int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
216 currentIndex);
217 String retVal = signature.substring(currentIndex,
218 endClass);
219 if ((endClass+1) < signature.length() && signature.charAt(endClass+1) == '/') {
220 // hidden class
221 retVal = retVal.replace('/', '.') + signature.substring(endClass + 1);
222 currentIndex = signature.length();
223 } else {
224 retVal = retVal.replace('/', '.');
225 currentIndex = endClass + 1;
226 }
227 return retVal;
228
229 case (JDWP.Tag.FLOAT):
230 return "float";
231
232 case (JDWP.Tag.DOUBLE):
233 return "double";
234
235 case (JDWP.Tag.INT):
236 return "int";
237
238 case (JDWP.Tag.LONG):
239 return "long";
240
241 case (JDWP.Tag.SHORT):
242 return "short";
243
244 case (JDWP.Tag.VOID):
245 return "void";
246
|