< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java

Print this page




 151         for (int i = 0; i < args.length; i++) {
 152             sb.append(mapDesc(args[i].getDescriptor()));
 153         }
 154         Type returnType = Type.getReturnType(desc);
 155         if (returnType == Type.VOID_TYPE) {
 156             sb.append(")V");
 157             return sb.toString();
 158         }
 159         sb.append(')').append(mapDesc(returnType.getDescriptor()));
 160         return sb.toString();
 161     }
 162 
 163     public Object mapValue(Object value) {
 164         if (value instanceof Type) {
 165             return mapType((Type) value);
 166         }
 167         if (value instanceof Handle) {
 168             Handle h = (Handle) value;
 169             return new Handle(h.getTag(), mapType(h.getOwner()), mapMethodName(
 170                     h.getOwner(), h.getName(), h.getDesc()),
 171                     mapMethodDesc(h.getDesc()));
 172         }
 173         return value;
 174     }
 175 
 176     /**
 177      *

 178      * @param typeSignature
 179      *            true if signature is a FieldTypeSignature, such as the
 180      *            signature parameter of the ClassVisitor.visitField or
 181      *            MethodVisitor.visitLocalVariable methods

 182      */
 183     public String mapSignature(String signature, boolean typeSignature) {
 184         if (signature == null) {
 185             return null;
 186         }
 187         SignatureReader r = new SignatureReader(signature);
 188         SignatureWriter w = new SignatureWriter();
 189         SignatureVisitor a = createRemappingSignatureAdapter(w);
 190         if (typeSignature) {
 191             r.acceptType(a);
 192         } else {
 193             r.accept(a);
 194         }
 195         return w.toString();
 196     }
 197 




 198     protected SignatureVisitor createRemappingSignatureAdapter(
 199             SignatureVisitor v) {
 200         return new RemappingSignatureAdapter(v, this);
 201     }
 202 





 203     /**
 204      * Map method name to the new name. Subclasses can override.
 205      *
 206      * @param owner
 207      *            owner of the method.
 208      * @param name
 209      *            name of the method.
 210      * @param desc
 211      *            descriptor of the method.
 212      * @return new name of the method
 213      */
 214     public String mapMethodName(String owner, String name, String desc) {
 215         return name;
 216     }
 217 
 218     /**
 219      * Map invokedynamic method name to the new name. Subclasses can override.
 220      *
 221      * @param name
 222      *            name of the invokedynamic.


 228         return name;
 229     }
 230 
 231     /**
 232      * Map field name to the new name. Subclasses can override.
 233      *
 234      * @param owner
 235      *            owner of the field.
 236      * @param name
 237      *            name of the field
 238      * @param desc
 239      *            descriptor of the field
 240      * @return new name of the field.
 241      */
 242     public String mapFieldName(String owner, String name, String desc) {
 243         return name;
 244     }
 245 
 246     /**
 247      * Map type name to the new name. Subclasses can override.




 248      */
 249     public String map(String typeName) {
 250         return typeName;
 251     }
 252 }


 151         for (int i = 0; i < args.length; i++) {
 152             sb.append(mapDesc(args[i].getDescriptor()));
 153         }
 154         Type returnType = Type.getReturnType(desc);
 155         if (returnType == Type.VOID_TYPE) {
 156             sb.append(")V");
 157             return sb.toString();
 158         }
 159         sb.append(')').append(mapDesc(returnType.getDescriptor()));
 160         return sb.toString();
 161     }
 162 
 163     public Object mapValue(Object value) {
 164         if (value instanceof Type) {
 165             return mapType((Type) value);
 166         }
 167         if (value instanceof Handle) {
 168             Handle h = (Handle) value;
 169             return new Handle(h.getTag(), mapType(h.getOwner()), mapMethodName(
 170                     h.getOwner(), h.getName(), h.getDesc()),
 171                     mapMethodDesc(h.getDesc()), h.isInterface());
 172         }
 173         return value;
 174     }
 175 
 176     /**
 177      * @param signature
 178      *            signature for mapper
 179      * @param typeSignature
 180      *            true if signature is a FieldTypeSignature, such as the
 181      *            signature parameter of the ClassVisitor.visitField or
 182      *            MethodVisitor.visitLocalVariable methods
 183      * @return signature rewritten as a string
 184      */
 185     public String mapSignature(String signature, boolean typeSignature) {
 186         if (signature == null) {
 187             return null;
 188         }
 189         SignatureReader r = new SignatureReader(signature);
 190         SignatureWriter w = new SignatureWriter();
 191         SignatureVisitor a = createSignatureRemapper(w);
 192         if (typeSignature) {
 193             r.acceptType(a);
 194         } else {
 195             r.accept(a);
 196         }
 197         return w.toString();
 198     }
 199 
 200     /**
 201      * @deprecated use {@link #createSignatureRemapper} instead.
 202      */
 203     @Deprecated
 204     protected SignatureVisitor createRemappingSignatureAdapter(
 205             SignatureVisitor v) {
 206         return new SignatureRemapper(v, this);
 207     }
 208 
 209     protected SignatureVisitor createSignatureRemapper(
 210             SignatureVisitor v) {
 211         return createRemappingSignatureAdapter(v);
 212     }
 213 
 214     /**
 215      * Map method name to the new name. Subclasses can override.
 216      *
 217      * @param owner
 218      *            owner of the method.
 219      * @param name
 220      *            name of the method.
 221      * @param desc
 222      *            descriptor of the method.
 223      * @return new name of the method
 224      */
 225     public String mapMethodName(String owner, String name, String desc) {
 226         return name;
 227     }
 228 
 229     /**
 230      * Map invokedynamic method name to the new name. Subclasses can override.
 231      *
 232      * @param name
 233      *            name of the invokedynamic.


 239         return name;
 240     }
 241 
 242     /**
 243      * Map field name to the new name. Subclasses can override.
 244      *
 245      * @param owner
 246      *            owner of the field.
 247      * @param name
 248      *            name of the field
 249      * @param desc
 250      *            descriptor of the field
 251      * @return new name of the field.
 252      */
 253     public String mapFieldName(String owner, String name, String desc) {
 254         return name;
 255     }
 256 
 257     /**
 258      * Map type name to the new name. Subclasses can override.
 259      *
 260      * @param typeName
 261      *            the type name
 262      * @return new name, default implementation is the identity.
 263      */
 264     public String map(String typeName) {
 265         return typeName;
 266     }
 267 }
< prev index next >