/** * Inspects the target class. Exceptions will be logged and a maker map returned * to indicate the lack of debug information. */ private Map<Member, String[]> inspectClass(Class<?> clazz) { InputStream is = clazz.getResourceAsStream(ClassUtils.getClassFileName(clazz)); if (is == null) { // We couldn‘t load the class file, which is not fatal as it // simply means this method of discovering parameter names won‘t work. if (logger.isDebugEnabled()) { logger.debug("Cannot find ‘.class‘ file for class [" + clazz + "] - unable to determine constructors/methods parameter names"); } return NO_DEBUG_INFO_MAP; } try { ClassReader classReader = new ClassReader(is); Map<Member, String[]> map = new ConcurrentHashMap<Member, String[]>(32); classReader.accept(new ParameterNameDiscoveringVisitor(clazz, map), 0); return map; } catch (IOException ex) { if (logger.isDebugEnabled()) { logger.debug("Exception thrown while reading ‘.class‘ file for class [" + clazz + "] - unable to determine constructors/methods parameter names", ex); } } catch (IllegalArgumentException ex) { if (logger.isDebugEnabled()) { logger.debug("ASM ClassReader failed to parse class file [" + clazz + "], probably due to a new Java class file version that isn‘t supported yet " + "- unable to determine constructors/methods parameter names", ex); } } finally { try { is.close(); } catch (IOException ex) { // ignore } } return NO_DEBUG_INFO_MAP; }
时间: 2024-10-09 17:31:32