Here you can find the source of getMethodSignature(Method method)
Parameter | Description |
---|---|
method | the method |
public static String getMethodSignature(Method method)
//package com.java2s; /**/*w ww .jav a 2 s . c om*/ * Licensed under Apache License v2. See LICENSE for more information. */ import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; public class Main { private static final Map<Class<?>, String> TYPESCODES = new HashMap<Class<?>, String>(); /** * Generate the method signature used to uniquely identity a method during remote * invocation. * * @param method the method * @return the signature */ public static String getMethodSignature(Method method) { StringBuilder sb = new StringBuilder(method.getName()).append("("); for (Class<?> parameterType : method.getParameterTypes()) { appendTypeSignature(sb, parameterType); } sb.append(")"); appendTypeSignature(sb, method.getReturnType()); return sb.toString(); } private static void appendTypeSignature(StringBuilder buffer, Class<?> clazz) { if (clazz.isArray()) { buffer.append("["); appendTypeSignature(buffer, clazz.getComponentType()); } else if (clazz.isPrimitive()) { buffer.append(TYPESCODES.get(clazz)); } else { buffer.append("L").append(clazz.getName().replaceAll("\\.", "/")).append(";"); } } }