278 * @see #isSafeBytecodeName(java.lang.String)
279 */
280 public static String toSourceName(String s) {
281 checkSafeBytecodeName(s);
282 String sn = s;
283 if (looksMangled(s)) {
284 sn = demangle(s);
285 assert(s.equals(mangle(sn))) : s+" => "+sn+" => "+mangle(sn);
286 }
287 return sn;
288 }
289
290 /**
291 * Given a bytecode name from a classfile, separate it into
292 * components delimited by dangerous characters.
293 * Each resulting array element will be either a dangerous character,
294 * or else a safe bytecode name.
295 * (The safe name might possibly be mangled to hide further dangerous characters.)
296 * For example, the qualified class name {@code java/lang/String}
297 * will be parsed into the array {@code {"java", '/', "lang", '/', "String"}}.
298 * The name {@code <init>} will be parsed into { '<', "init", '>'}}
299 * The name {@code foo/bar$:baz} will be parsed into
300 * {@code {"foo", '/', "bar", '$', ':', "baz"}}.
301 * The name {@code ::\=:foo:\=bar\!baz} will be parsed into
302 * {@code {':', ':', "", ':', "foo", ':', "bar:baz"}}.
303 */
304 public static Object[] parseBytecodeName(String s) {
305 int slen = s.length();
306 Object[] res = null;
307 for (int pass = 0; pass <= 1; pass++) {
308 int fillp = 0;
309 int lasti = 0;
310 for (int i = 0; i <= slen; i++) {
311 int whichDC = -1;
312 if (i < slen) {
313 whichDC = DANGEROUS_CHARS.indexOf(s.charAt(i));
314 if (whichDC < DANGEROUS_CHAR_FIRST_INDEX) continue;
315 }
316 // got to end of string or next dangerous char
317 if (lasti < i) {
318 // normal component
|
278 * @see #isSafeBytecodeName(java.lang.String)
279 */
280 public static String toSourceName(String s) {
281 checkSafeBytecodeName(s);
282 String sn = s;
283 if (looksMangled(s)) {
284 sn = demangle(s);
285 assert(s.equals(mangle(sn))) : s+" => "+sn+" => "+mangle(sn);
286 }
287 return sn;
288 }
289
290 /**
291 * Given a bytecode name from a classfile, separate it into
292 * components delimited by dangerous characters.
293 * Each resulting array element will be either a dangerous character,
294 * or else a safe bytecode name.
295 * (The safe name might possibly be mangled to hide further dangerous characters.)
296 * For example, the qualified class name {@code java/lang/String}
297 * will be parsed into the array {@code {"java", '/', "lang", '/', "String"}}.
298 * The name {@code <init>} will be parsed into {@code {'<', "init", '>'}}.
299 * The name {@code foo/bar$:baz} will be parsed into
300 * {@code {"foo", '/', "bar", '$', ':', "baz"}}.
301 * The name {@code ::\=:foo:\=bar\!baz} will be parsed into
302 * {@code {':', ':', "", ':', "foo", ':', "bar:baz"}}.
303 */
304 public static Object[] parseBytecodeName(String s) {
305 int slen = s.length();
306 Object[] res = null;
307 for (int pass = 0; pass <= 1; pass++) {
308 int fillp = 0;
309 int lasti = 0;
310 for (int i = 0; i <= slen; i++) {
311 int whichDC = -1;
312 if (i < slen) {
313 whichDC = DANGEROUS_CHARS.indexOf(s.charAt(i));
314 if (whichDC < DANGEROUS_CHAR_FIRST_INDEX) continue;
315 }
316 // got to end of string or next dangerous char
317 if (lasti < i) {
318 // normal component
|