40 |
40 |
41 private Reference<Method> methodRef; |
41 private Reference<Method> methodRef; |
42 |
42 |
43 private String[] paramNames; |
43 private String[] paramNames; |
44 |
44 |
45 private List params; |
45 private List<WeakReference<Class<?>>> params; |
46 |
46 |
47 private ParameterDescriptor parameterDescriptors[]; |
47 private ParameterDescriptor parameterDescriptors[]; |
48 |
48 |
49 /** |
49 /** |
50 * Constructs a <code>MethodDescriptor</code> from a |
50 * Constructs a <code>MethodDescriptor</code> from a |
79 * @return The low-level description of the method |
79 * @return The low-level description of the method |
80 */ |
80 */ |
81 public synchronized Method getMethod() { |
81 public synchronized Method getMethod() { |
82 Method method = getMethod0(); |
82 Method method = getMethod0(); |
83 if (method == null) { |
83 if (method == null) { |
84 Class cls = getClass0(); |
84 Class<?> cls = getClass0(); |
85 String name = getName(); |
85 String name = getName(); |
86 if ((cls != null) && (name != null)) { |
86 if ((cls != null) && (name != null)) { |
87 Class[] params = getParams(); |
87 Class<?>[] params = getParams(); |
88 if (params == null) { |
88 if (params == null) { |
89 for (int i = 0; i < 3; i++) { |
89 for (int i = 0; i < 3; i++) { |
90 // Find methods for up to 2 params. We are guessing here. |
90 // Find methods for up to 2 params. We are guessing here. |
91 // This block should never execute unless the classloader |
91 // This block should never execute unless the classloader |
92 // that loaded the argument classes disappears. |
92 // that loaded the argument classes disappears. |
119 return (this.methodRef != null) |
119 return (this.methodRef != null) |
120 ? this.methodRef.get() |
120 ? this.methodRef.get() |
121 : null; |
121 : null; |
122 } |
122 } |
123 |
123 |
124 private synchronized void setParams(Class[] param) { |
124 private synchronized void setParams(Class<?>[] param) { |
125 if (param == null) { |
125 if (param == null) { |
126 return; |
126 return; |
127 } |
127 } |
128 paramNames = new String[param.length]; |
128 paramNames = new String[param.length]; |
129 params = new ArrayList(param.length); |
129 params = new ArrayList<>(param.length); |
130 for (int i = 0; i < param.length; i++) { |
130 for (int i = 0; i < param.length; i++) { |
131 paramNames[i] = param[i].getName(); |
131 paramNames[i] = param[i].getName(); |
132 params.add(new WeakReference(param[i])); |
132 params.add(new WeakReference<Class<?>>(param[i])); |
133 } |
133 } |
134 } |
134 } |
135 |
135 |
136 // pp getParamNames used as an optimization to avoid method.getParameterTypes. |
136 // pp getParamNames used as an optimization to avoid method.getParameterTypes. |
137 String[] getParamNames() { |
137 String[] getParamNames() { |
138 return paramNames; |
138 return paramNames; |
139 } |
139 } |
140 |
140 |
141 private synchronized Class[] getParams() { |
141 private synchronized Class<?>[] getParams() { |
142 Class[] clss = new Class[params.size()]; |
142 Class<?>[] clss = new Class<?>[params.size()]; |
143 |
143 |
144 for (int i = 0; i < params.size(); i++) { |
144 for (int i = 0; i < params.size(); i++) { |
145 Reference ref = (Reference)params.get(i); |
145 Reference<? extends Class<?>> ref = (Reference<? extends Class<?>>)params.get(i); |
146 Class cls = (Class)ref.get(); |
146 Class<?> cls = ref.get(); |
147 if (cls == null) { |
147 if (cls == null) { |
148 return null; |
148 return null; |
149 } else { |
149 } else { |
150 clss[i] = cls; |
150 clss[i] = cls; |
151 } |
151 } |