@Test public void loadConstructorParam() throws Exception { assertEquals(0,ClassDescriptor.loadParameterNames(C.class.getConstructor()).length); String[] names = ClassDescriptor.loadParameterNames(C.class.getConstructor(int.class, int.class, String.class)); assertEquals("[a, b, x]",Arrays.asList(names).toString()); }
public static String[] loadParameterNames(Method m) { CapturedParameterNames cpn = m.getAnnotation(CapturedParameterNames.class); if(cpn!=null) return cpn.value(); try { String[] n = ASM.loadParametersFromAsm(m); if (n!=null) return n; } catch (LinkageError e) { LOGGER.log(FINE, "Incompatible ASM", e); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load a class file", e); } Class<?> c = m.getDeclaringClass(); URL url = c.getClassLoader().getResource( c.getName().replace('.', '/').replace('$','/') + '/' + m.getName() + ".stapler"); if(url!=null) { try { return IOUtils.toString(url.openStream()).split(","); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load "+url,e); return EMPTY_ARRAY; } } return EMPTY_ARRAY; }
ClassDescriptor { public static String[] loadParameterNames(Method m) { CapturedParameterNames cpn = m.getAnnotation(CapturedParameterNames.class); if(cpn!=null) return cpn.value(); try { String[] n = ASM.loadParametersFromAsm(m); if (n!=null) return n; } catch (LinkageError e) { LOGGER.log(FINE, "Incompatible ASM", e); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load a class file", e); } Class<?> c = m.getDeclaringClass(); URL url = c.getClassLoader().getResource( c.getName().replace('.', '/').replace('$','/') + '/' + m.getName() + ".stapler"); if(url!=null) { try { return IOUtils.toString(url.openStream()).split(","); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load "+url,e); return EMPTY_ARRAY; } } return EMPTY_ARRAY; } }
ClassDescriptor { public static String[] loadParameterNames(Method m) { CapturedParameterNames cpn = m.getAnnotation(CapturedParameterNames.class); if(cpn!=null) return cpn.value(); try { String[] n = ASM.loadParametersFromAsm(m); if (n!=null) return n; } catch (LinkageError e) { LOGGER.log(FINE, "Incompatible ASM", e); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load a class file", e); } Class<?> c = m.getDeclaringClass(); URL url = c.getClassLoader().getResource( c.getName().replace('.', '/').replace('$','/') + '/' + m.getName() + ".stapler"); if(url!=null) { try { return IOUtils.toString(url.openStream()).split(","); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load "+url,e); return EMPTY_ARRAY; } } return EMPTY_ARRAY; } ClassDescriptor(Class clazz, Class... wrappers); }
ClassDescriptor { public static String[] loadParameterNames(Method m) { CapturedParameterNames cpn = m.getAnnotation(CapturedParameterNames.class); if(cpn!=null) return cpn.value(); try { String[] n = ASM.loadParametersFromAsm(m); if (n!=null) return n; } catch (LinkageError e) { LOGGER.log(FINE, "Incompatible ASM", e); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load a class file", e); } Class<?> c = m.getDeclaringClass(); URL url = c.getClassLoader().getResource( c.getName().replace('.', '/').replace('$','/') + '/' + m.getName() + ".stapler"); if(url!=null) { try { return IOUtils.toString(url.openStream()).split(","); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load "+url,e); return EMPTY_ARRAY; } } return EMPTY_ARRAY; } ClassDescriptor(Class clazz, Class... wrappers); static String[] loadParameterNames(Method m); static String[] loadParameterNames(Constructor<?> m); String[] loadConstructorParamNames(); }
ClassDescriptor { public static String[] loadParameterNames(Method m) { CapturedParameterNames cpn = m.getAnnotation(CapturedParameterNames.class); if(cpn!=null) return cpn.value(); try { String[] n = ASM.loadParametersFromAsm(m); if (n!=null) return n; } catch (LinkageError e) { LOGGER.log(FINE, "Incompatible ASM", e); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load a class file", e); } Class<?> c = m.getDeclaringClass(); URL url = c.getClassLoader().getResource( c.getName().replace('.', '/').replace('$','/') + '/' + m.getName() + ".stapler"); if(url!=null) { try { return IOUtils.toString(url.openStream()).split(","); } catch (IOException e) { LOGGER.log(WARNING, "Failed to load "+url,e); return EMPTY_ARRAY; } } return EMPTY_ARRAY; } ClassDescriptor(Class clazz, Class... wrappers); static String[] loadParameterNames(Method m); static String[] loadParameterNames(Constructor<?> m); String[] loadConstructorParamNames(); final Class clazz; final FunctionList methods; final Field[] fields; }