Mon, 28 Feb 2011 11:48:53 +0000
7015430: Incorrect thrown type determined for unchecked invocations
Summary: Thrown types do not get updated after 15.12.2.8, and do not get erased as per 15.12.2.6
Reviewed-by: jjg, dlsmith
jjg@46 | 1 | /* |
ksrini@826 | 2 | * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
jjg@46 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@46 | 4 | * |
jjg@46 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@46 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
jjg@46 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
jjg@46 | 10 | * |
jjg@46 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@46 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@46 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@46 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@46 | 15 | * accompanied this code). |
jjg@46 | 16 | * |
jjg@46 | 17 | * You should have received a copy of the GNU General Public License version |
jjg@46 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@46 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@46 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
jjg@46 | 24 | */ |
jjg@46 | 25 | |
jjg@46 | 26 | package com.sun.tools.javap; |
jjg@46 | 27 | |
jjg@46 | 28 | import com.sun.tools.classfile.ClassFile; |
jjg@46 | 29 | import com.sun.tools.classfile.ConstantPool; |
jjg@46 | 30 | import com.sun.tools.classfile.ConstantPoolException; |
jjg@46 | 31 | |
jjg@46 | 32 | import static com.sun.tools.classfile.ConstantPool.*; |
jjg@46 | 33 | |
jjg@46 | 34 | /* |
jjg@46 | 35 | * Write a constant pool entry. |
jjg@46 | 36 | * |
jjg@581 | 37 | * <p><b>This is NOT part of any supported API. |
jjg@581 | 38 | * If you write code that depends on this, you do so at your own risk. |
jjg@46 | 39 | * This code and its internal interfaces are subject to change or |
jjg@46 | 40 | * deletion without notice.</b> |
jjg@46 | 41 | */ |
jjg@46 | 42 | public class ConstantWriter extends BasicWriter { |
jjg@300 | 43 | public static ConstantWriter instance(Context context) { |
jjg@46 | 44 | ConstantWriter instance = context.get(ConstantWriter.class); |
jjg@46 | 45 | if (instance == null) |
jjg@46 | 46 | instance = new ConstantWriter(context); |
jjg@46 | 47 | return instance; |
jjg@46 | 48 | } |
jjg@46 | 49 | |
jjg@46 | 50 | protected ConstantWriter(Context context) { |
jjg@46 | 51 | super(context); |
jjg@46 | 52 | context.put(ConstantWriter.class, this); |
jjg@46 | 53 | classWriter = ClassWriter.instance(context); |
jjg@46 | 54 | options = Options.instance(context); |
jjg@46 | 55 | } |
jjg@46 | 56 | |
jjg@300 | 57 | protected void writeConstantPool() { |
jjg@300 | 58 | ConstantPool constant_pool = classWriter.getClassFile().constant_pool; |
jjg@300 | 59 | writeConstantPool(constant_pool); |
jjg@300 | 60 | } |
jjg@300 | 61 | |
jjg@300 | 62 | protected void writeConstantPool(ConstantPool constant_pool) { |
jjg@46 | 63 | ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() { |
jjg@46 | 64 | public Integer visitClass(CONSTANT_Class_info info, Void p) { |
jjg@354 | 65 | print("#" + info.name_index); |
jjg@348 | 66 | tab(); |
jjg@348 | 67 | println("// " + stringValue(info)); |
jjg@46 | 68 | return 1; |
jjg@46 | 69 | } |
jjg@46 | 70 | |
jjg@46 | 71 | public Integer visitDouble(CONSTANT_Double_info info, Void p) { |
jjg@354 | 72 | println(stringValue(info)); |
jjg@46 | 73 | return 2; |
jjg@46 | 74 | } |
jjg@46 | 75 | |
jjg@46 | 76 | public Integer visitFieldref(CONSTANT_Fieldref_info info, Void p) { |
jjg@354 | 77 | print("#" + info.class_index + ".#" + info.name_and_type_index); |
jjg@348 | 78 | tab(); |
jjg@348 | 79 | println("// " + stringValue(info)); |
jjg@46 | 80 | return 1; |
jjg@46 | 81 | } |
jjg@46 | 82 | |
jjg@46 | 83 | public Integer visitFloat(CONSTANT_Float_info info, Void p) { |
jjg@354 | 84 | println(stringValue(info)); |
jjg@46 | 85 | return 1; |
jjg@46 | 86 | } |
jjg@46 | 87 | |
jjg@46 | 88 | public Integer visitInteger(CONSTANT_Integer_info info, Void p) { |
jjg@354 | 89 | println(stringValue(info)); |
jjg@46 | 90 | return 1; |
jjg@46 | 91 | } |
jjg@46 | 92 | |
jjg@46 | 93 | public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) { |
jjg@354 | 94 | print("#" + info.class_index + ".#" + info.name_and_type_index); |
jjg@348 | 95 | tab(); |
jjg@348 | 96 | println("// " + stringValue(info)); |
jjg@46 | 97 | return 1; |
jjg@46 | 98 | } |
jjg@46 | 99 | |
ksrini@826 | 100 | public Integer visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) { |
ksrini@826 | 101 | print("#" + info.bootstrap_method_attr_index + ":#" + info.name_and_type_index); |
ksrini@826 | 102 | tab(); |
ksrini@826 | 103 | println("// " + stringValue(info)); |
ksrini@826 | 104 | return 1; |
ksrini@826 | 105 | } |
ksrini@826 | 106 | |
jjg@46 | 107 | public Integer visitLong(CONSTANT_Long_info info, Void p) { |
jjg@354 | 108 | println(stringValue(info)); |
jjg@46 | 109 | return 2; |
jjg@46 | 110 | } |
jjg@46 | 111 | |
jjg@46 | 112 | public Integer visitNameAndType(CONSTANT_NameAndType_info info, Void p) { |
jjg@354 | 113 | print("#" + info.name_index + ":#" + info.type_index); |
jjg@348 | 114 | tab(); |
jjg@348 | 115 | println("// " + stringValue(info)); |
jjg@46 | 116 | return 1; |
jjg@46 | 117 | } |
jjg@46 | 118 | |
jjg@46 | 119 | public Integer visitMethodref(CONSTANT_Methodref_info info, Void p) { |
jjg@354 | 120 | print("#" + info.class_index + ".#" + info.name_and_type_index); |
jjg@348 | 121 | tab(); |
jjg@348 | 122 | println("// " + stringValue(info)); |
jjg@46 | 123 | return 1; |
jjg@46 | 124 | } |
jjg@46 | 125 | |
ksrini@826 | 126 | public Integer visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) { |
ksrini@826 | 127 | print("#" + info.reference_kind.tag + ":#" + info.reference_index); |
ksrini@826 | 128 | tab(); |
ksrini@826 | 129 | println("// " + stringValue(info)); |
ksrini@826 | 130 | return 1; |
ksrini@826 | 131 | } |
ksrini@826 | 132 | |
ksrini@826 | 133 | public Integer visitMethodType(CONSTANT_MethodType_info info, Void p) { |
ksrini@826 | 134 | print("#" + info.descriptor_index); |
ksrini@826 | 135 | tab(); |
ksrini@826 | 136 | println("// " + stringValue(info)); |
ksrini@826 | 137 | return 1; |
ksrini@826 | 138 | } |
ksrini@826 | 139 | |
jjg@46 | 140 | public Integer visitString(CONSTANT_String_info info, Void p) { |
jjg@354 | 141 | print("#" + info.string_index); |
jjg@348 | 142 | tab(); |
jjg@348 | 143 | println("// " + stringValue(info)); |
jjg@46 | 144 | return 1; |
jjg@46 | 145 | } |
jjg@46 | 146 | |
jjg@46 | 147 | public Integer visitUtf8(CONSTANT_Utf8_info info, Void p) { |
jjg@354 | 148 | println(stringValue(info)); |
jjg@46 | 149 | return 1; |
jjg@46 | 150 | } |
jjg@46 | 151 | |
jjg@46 | 152 | }; |
jjg@348 | 153 | println("Constant pool:"); |
jjg@348 | 154 | indent(+1); |
jjg@348 | 155 | int width = String.valueOf(constant_pool.size()).length() + 1; |
jjg@46 | 156 | int cpx = 1; |
jjg@46 | 157 | while (cpx < constant_pool.size()) { |
jjg@355 | 158 | print(String.format("%" + width + "s", ("#" + cpx))); |
jjg@46 | 159 | try { |
jjg@46 | 160 | CPInfo cpInfo = constant_pool.get(cpx); |
jjg@355 | 161 | print(String.format(" = %-18s ", cpTagName(cpInfo))); |
jjg@46 | 162 | cpx += cpInfo.accept(v, null); |
jjg@46 | 163 | } catch (ConstantPool.InvalidIndex ex) { |
jjg@348 | 164 | // should not happen |
jjg@46 | 165 | } |
jjg@46 | 166 | } |
jjg@348 | 167 | indent(-1); |
jjg@46 | 168 | } |
jjg@46 | 169 | |
jjg@300 | 170 | protected void write(int cpx) { |
jjg@46 | 171 | ClassFile classFile = classWriter.getClassFile(); |
jjg@46 | 172 | if (cpx == 0) { |
jjg@46 | 173 | print("#0"); |
jjg@46 | 174 | return; |
jjg@46 | 175 | } |
jjg@46 | 176 | |
jjg@46 | 177 | CPInfo cpInfo; |
jjg@46 | 178 | try { |
jjg@46 | 179 | cpInfo = classFile.constant_pool.get(cpx); |
jjg@46 | 180 | } catch (ConstantPoolException e) { |
jjg@46 | 181 | print("#" + cpx); |
jjg@46 | 182 | return; |
jjg@46 | 183 | } |
jjg@46 | 184 | |
jjg@46 | 185 | int tag = cpInfo.getTag(); |
jjg@46 | 186 | switch (tag) { |
jjg@46 | 187 | case CONSTANT_Methodref: |
jjg@46 | 188 | case CONSTANT_InterfaceMethodref: |
jjg@46 | 189 | case CONSTANT_Fieldref: |
jjg@46 | 190 | // simplify references within this class |
jjg@46 | 191 | CPRefInfo ref = (CPRefInfo) cpInfo; |
jjg@46 | 192 | try { |
jjg@46 | 193 | if (ref.class_index == classFile.this_class) |
jjg@46 | 194 | cpInfo = classFile.constant_pool.get(ref.name_and_type_index); |
jjg@46 | 195 | } catch (ConstantPool.InvalidIndex e) { |
jjg@46 | 196 | // ignore, for now |
jjg@46 | 197 | } |
jjg@46 | 198 | } |
jjg@46 | 199 | print(tagName(tag) + " " + stringValue(cpInfo)); |
jjg@46 | 200 | } |
jjg@46 | 201 | |
jjg@355 | 202 | String cpTagName(CPInfo cpInfo) { |
jjg@355 | 203 | String n = cpInfo.getClass().getSimpleName(); |
jjg@355 | 204 | return n.replace("CONSTANT_", "").replace("_info", ""); |
jjg@355 | 205 | } |
jjg@355 | 206 | |
jjg@46 | 207 | String tagName(int tag) { |
jjg@46 | 208 | switch (tag) { |
jjg@46 | 209 | case CONSTANT_Utf8: |
jjg@355 | 210 | return "Utf8"; |
jjg@46 | 211 | case CONSTANT_Integer: |
jjg@46 | 212 | return "int"; |
jjg@46 | 213 | case CONSTANT_Float: |
jjg@46 | 214 | return "float"; |
jjg@46 | 215 | case CONSTANT_Long: |
jjg@46 | 216 | return "long"; |
jjg@46 | 217 | case CONSTANT_Double: |
jjg@46 | 218 | return "double"; |
jjg@46 | 219 | case CONSTANT_Class: |
jjg@46 | 220 | return "class"; |
jjg@46 | 221 | case CONSTANT_String: |
jjg@46 | 222 | return "String"; |
jjg@46 | 223 | case CONSTANT_Fieldref: |
jjg@46 | 224 | return "Field"; |
ksrini@826 | 225 | case CONSTANT_MethodHandle: |
ksrini@826 | 226 | return "MethodHandle"; |
ksrini@826 | 227 | case CONSTANT_MethodType: |
ksrini@826 | 228 | return "MethodType"; |
jjg@46 | 229 | case CONSTANT_Methodref: |
jjg@46 | 230 | return "Method"; |
jjg@46 | 231 | case CONSTANT_InterfaceMethodref: |
jjg@46 | 232 | return "InterfaceMethod"; |
ksrini@826 | 233 | case CONSTANT_InvokeDynamic: |
ksrini@826 | 234 | return "InvokeDynamic"; |
jjg@46 | 235 | case CONSTANT_NameAndType: |
jjg@46 | 236 | return "NameAndType"; |
jjg@46 | 237 | default: |
ksrini@826 | 238 | return "(unknown tag " + tag + ")"; |
jjg@46 | 239 | } |
jjg@46 | 240 | } |
jjg@46 | 241 | |
jjg@46 | 242 | String stringValue(int constant_pool_index) { |
jjg@46 | 243 | ClassFile classFile = classWriter.getClassFile(); |
jjg@46 | 244 | try { |
jjg@46 | 245 | return stringValue(classFile.constant_pool.get(constant_pool_index)); |
jjg@46 | 246 | } catch (ConstantPool.InvalidIndex e) { |
jjg@46 | 247 | return report(e); |
jjg@46 | 248 | } |
jjg@46 | 249 | } |
jjg@46 | 250 | |
jjg@46 | 251 | String stringValue(CPInfo cpInfo) { |
jjg@46 | 252 | return stringValueVisitor.visit(cpInfo); |
jjg@46 | 253 | } |
jjg@46 | 254 | |
jjg@46 | 255 | StringValueVisitor stringValueVisitor = new StringValueVisitor(); |
jjg@46 | 256 | |
jjg@46 | 257 | private class StringValueVisitor implements ConstantPool.Visitor<String, Void> { |
jjg@46 | 258 | public String visit(CPInfo info) { |
jjg@46 | 259 | return info.accept(this, null); |
jjg@46 | 260 | } |
jjg@46 | 261 | |
jjg@46 | 262 | public String visitClass(CONSTANT_Class_info info, Void p) { |
jjg@46 | 263 | return getCheckedName(info); |
jjg@46 | 264 | } |
jjg@46 | 265 | |
jjg@46 | 266 | String getCheckedName(CONSTANT_Class_info info) { |
jjg@46 | 267 | try { |
jjg@46 | 268 | return checkName(info.getName()); |
jjg@46 | 269 | } catch (ConstantPoolException e) { |
jjg@46 | 270 | return report(e); |
jjg@46 | 271 | } |
jjg@46 | 272 | } |
jjg@46 | 273 | |
jjg@46 | 274 | public String visitDouble(CONSTANT_Double_info info, Void p) { |
jjg@46 | 275 | return info.value + "d"; |
jjg@46 | 276 | } |
jjg@46 | 277 | |
jjg@46 | 278 | public String visitFieldref(CONSTANT_Fieldref_info info, Void p) { |
jjg@46 | 279 | return visitRef(info, p); |
jjg@46 | 280 | } |
jjg@46 | 281 | |
jjg@46 | 282 | public String visitFloat(CONSTANT_Float_info info, Void p) { |
jjg@46 | 283 | return info.value + "f"; |
jjg@46 | 284 | } |
jjg@46 | 285 | |
jjg@46 | 286 | public String visitInteger(CONSTANT_Integer_info info, Void p) { |
jjg@46 | 287 | return String.valueOf(info.value); |
jjg@46 | 288 | } |
jjg@46 | 289 | |
jjg@46 | 290 | public String visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) { |
jjg@46 | 291 | return visitRef(info, p); |
jjg@46 | 292 | } |
jjg@46 | 293 | |
ksrini@826 | 294 | public String visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) { |
ksrini@826 | 295 | try { |
ksrini@826 | 296 | String callee = stringValue(info.getNameAndTypeInfo()); |
ksrini@826 | 297 | return "#" + info.bootstrap_method_attr_index + ":" + callee; |
ksrini@826 | 298 | } catch (ConstantPoolException e) { |
ksrini@826 | 299 | return report(e); |
ksrini@826 | 300 | } |
ksrini@826 | 301 | } |
ksrini@826 | 302 | |
jjg@46 | 303 | public String visitLong(CONSTANT_Long_info info, Void p) { |
jjg@46 | 304 | return info.value + "l"; |
jjg@46 | 305 | } |
jjg@46 | 306 | |
jjg@46 | 307 | public String visitNameAndType(CONSTANT_NameAndType_info info, Void p) { |
jjg@46 | 308 | return getCheckedName(info) + ":" + getType(info); |
jjg@46 | 309 | } |
jjg@46 | 310 | |
jjg@46 | 311 | String getCheckedName(CONSTANT_NameAndType_info info) { |
jjg@46 | 312 | try { |
jjg@46 | 313 | return checkName(info.getName()); |
jjg@46 | 314 | } catch (ConstantPoolException e) { |
jjg@46 | 315 | return report(e); |
jjg@46 | 316 | } |
jjg@46 | 317 | } |
jjg@46 | 318 | |
jjg@46 | 319 | String getType(CONSTANT_NameAndType_info info) { |
jjg@46 | 320 | try { |
jjg@46 | 321 | return info.getType(); |
jjg@46 | 322 | } catch (ConstantPoolException e) { |
jjg@46 | 323 | return report(e); |
jjg@46 | 324 | } |
jjg@46 | 325 | } |
jjg@46 | 326 | |
ksrini@826 | 327 | public String visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) { |
ksrini@826 | 328 | try { |
ksrini@826 | 329 | return info.reference_kind.name + " " + stringValue(info.getCPRefInfo()); |
ksrini@826 | 330 | } catch (ConstantPoolException e) { |
ksrini@826 | 331 | return report(e); |
ksrini@826 | 332 | } |
ksrini@826 | 333 | } |
ksrini@826 | 334 | |
ksrini@826 | 335 | public String visitMethodType(CONSTANT_MethodType_info info, Void p) { |
ksrini@826 | 336 | try { |
ksrini@826 | 337 | return info.getType(); |
ksrini@826 | 338 | } catch (ConstantPoolException e) { |
ksrini@826 | 339 | return report(e); |
ksrini@826 | 340 | } |
ksrini@826 | 341 | } |
ksrini@826 | 342 | |
jjg@46 | 343 | public String visitMethodref(CONSTANT_Methodref_info info, Void p) { |
jjg@46 | 344 | return visitRef(info, p); |
jjg@46 | 345 | } |
jjg@46 | 346 | |
jjg@46 | 347 | public String visitString(CONSTANT_String_info info, Void p) { |
jjg@46 | 348 | try { |
jjg@46 | 349 | ClassFile classFile = classWriter.getClassFile(); |
jjg@46 | 350 | int string_index = info.string_index; |
jjg@46 | 351 | return stringValue(classFile.constant_pool.getUTF8Info(string_index)); |
jjg@46 | 352 | } catch (ConstantPoolException e) { |
jjg@46 | 353 | return report(e); |
jjg@46 | 354 | } |
jjg@46 | 355 | } |
jjg@46 | 356 | |
jjg@46 | 357 | public String visitUtf8(CONSTANT_Utf8_info info, Void p) { |
jjg@46 | 358 | String s = info.value; |
jjg@46 | 359 | StringBuilder sb = new StringBuilder(); |
jjg@46 | 360 | for (int i = 0; i < s.length(); i++) { |
jjg@46 | 361 | char c = s.charAt(i); |
jjg@46 | 362 | switch (c) { |
jjg@46 | 363 | case '\t': |
jjg@46 | 364 | sb.append('\\').append('t'); |
jjg@46 | 365 | break; |
jjg@46 | 366 | case '\n': |
jjg@46 | 367 | sb.append('\\').append('n'); |
jjg@46 | 368 | break; |
jjg@46 | 369 | case '\r': |
jjg@46 | 370 | sb.append('\\').append('r'); |
jjg@46 | 371 | break; |
jjg@46 | 372 | case '\"': |
jjg@46 | 373 | sb.append('\\').append('\"'); |
jjg@46 | 374 | break; |
jjg@46 | 375 | default: |
jjg@46 | 376 | sb.append(c); |
jjg@46 | 377 | } |
jjg@46 | 378 | } |
jjg@46 | 379 | return sb.toString(); |
jjg@46 | 380 | } |
jjg@46 | 381 | |
jjg@46 | 382 | String visitRef(CPRefInfo info, Void p) { |
jjg@46 | 383 | String cn = getCheckedClassName(info); |
jjg@46 | 384 | String nat; |
jjg@46 | 385 | try { |
jjg@46 | 386 | nat = stringValue(info.getNameAndTypeInfo()); |
jjg@46 | 387 | } catch (ConstantPoolException e) { |
jjg@46 | 388 | nat = report(e); |
jjg@46 | 389 | } |
jjg@46 | 390 | return cn + "." + nat; |
jjg@46 | 391 | } |
jjg@46 | 392 | |
jjg@46 | 393 | String getCheckedClassName(CPRefInfo info) { |
jjg@46 | 394 | try { |
jjg@46 | 395 | return checkName(info.getClassName()); |
jjg@46 | 396 | } catch (ConstantPoolException e) { |
jjg@46 | 397 | return report(e); |
jjg@46 | 398 | } |
jjg@46 | 399 | } |
jjg@46 | 400 | } |
jjg@46 | 401 | |
jjg@46 | 402 | /* If name is a valid binary name, return it; otherwise quote it. */ |
jjg@46 | 403 | private static String checkName(String name) { |
jjg@46 | 404 | if (name == null) |
jjg@46 | 405 | return "null"; |
jjg@46 | 406 | |
jjg@46 | 407 | int len = name.length(); |
jjg@46 | 408 | if (len == 0) |
jjg@46 | 409 | return "\"\""; |
jjg@46 | 410 | |
jjg@46 | 411 | int cc = '/'; |
jjg@46 | 412 | int cp; |
jjg@46 | 413 | for (int k = 0; k < len; k += Character.charCount(cp)) { |
jjg@46 | 414 | cp = name.codePointAt(k); |
jjg@46 | 415 | if ((cc == '/' && !Character.isJavaIdentifierStart(cp)) |
jjg@46 | 416 | || (cp != '/' && !Character.isJavaIdentifierPart(cp))) { |
jrose@267 | 417 | return "\"" + addEscapes(name) + "\""; |
jjg@46 | 418 | } |
jjg@46 | 419 | cc = cp; |
jjg@46 | 420 | } |
jjg@46 | 421 | |
jjg@46 | 422 | return name; |
jjg@46 | 423 | } |
jjg@46 | 424 | |
jrose@267 | 425 | /* If name requires escapes, put them in, so it can be a string body. */ |
jrose@267 | 426 | private static String addEscapes(String name) { |
jrose@267 | 427 | String esc = "\\\"\n\t"; |
jrose@267 | 428 | String rep = "\\\"nt"; |
jrose@267 | 429 | StringBuilder buf = null; |
jrose@267 | 430 | int nextk = 0; |
jrose@267 | 431 | int len = name.length(); |
jrose@267 | 432 | for (int k = 0; k < len; k++) { |
jrose@267 | 433 | char cp = name.charAt(k); |
jrose@267 | 434 | int n = esc.indexOf(cp); |
jrose@267 | 435 | if (n >= 0) { |
jrose@267 | 436 | if (buf == null) |
jrose@267 | 437 | buf = new StringBuilder(len * 2); |
jrose@267 | 438 | if (nextk < k) |
jrose@267 | 439 | buf.append(name, nextk, k); |
jrose@267 | 440 | buf.append('\\'); |
jrose@267 | 441 | buf.append(rep.charAt(n)); |
jrose@267 | 442 | nextk = k+1; |
jrose@267 | 443 | } |
jrose@267 | 444 | } |
jrose@267 | 445 | if (buf == null) |
jrose@267 | 446 | return name; |
jrose@267 | 447 | if (nextk < len) |
jrose@267 | 448 | buf.append(name, nextk, len); |
jrose@267 | 449 | return buf.toString(); |
jrose@267 | 450 | } |
jrose@267 | 451 | |
jjg@46 | 452 | private ClassWriter classWriter; |
jjg@46 | 453 | private Options options; |
jjg@46 | 454 | } |