160 * @param includeOSR if true,
161 * {@linkplain ProfilingInfo#getDeoptimizationCount(DeoptimizationReason)
162 * deoptimization counts} will include deoptimization that happened during execution
163 * of on-stack-replacement methods.
164 */
165 ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR);
166
167 /**
168 * Invalidates the profiling information and restarts profiling upon the next invocation.
169 */
170 void reprofile();
171
172 /**
173 * Returns the constant pool of this method.
174 */
175 ConstantPool getConstantPool();
176
177 /**
178 * A {@code Parameter} provides information about method parameters.
179 */
180 public static class Parameter implements AnnotatedElement {
181 private final String name;
182 private final ResolvedJavaMethod method;
183 private final int modifiers;
184 private final int index;
185
186 /**
187 * Constructor for {@code Parameter}.
188 *
189 * @param name the name of the parameter
190 * @param modifiers the modifier flags for the parameter
191 * @param method the method which defines this parameter
192 * @param index the index of the parameter
193 */
194 public Parameter(String name,
195 int modifiers,
196 ResolvedJavaMethod method,
197 int index) {
198 this.name = name;
199 this.modifiers = modifiers;
200 this.method = method;
201 this.index = index;
202 }
203
204 /**
205 * Gets the name of the parameter.
206 */
207 public String getName() {
208 return name;
209 }
210
211 /**
212 * Gets the method declaring the parameter.
213 */
214 public ResolvedJavaMethod getDeclaringMethod() {
215 return method;
216 }
217
218 /**
219 * Get the modifier flags for the parameter
220 */
221 public int getModifiers() {
222 return modifiers;
223 }
224
225 /**
226 * Gets the kind of the parameter.
227 */
228 public JavaKind getKind() {
229 return method.getSignature().getParameterKind(index);
230 }
231
232 /**
233 * Gets the formal type of the parameter.
234 */
235 public Type getParameterizedType() {
236 return method.getGenericParameterTypes()[index];
237 }
238
239 /**
240 * Gets the type of the parameter.
241 */
242 public JavaType getType() {
243 return method.getSignature().getParameterType(index, method.getDeclaringClass());
244 }
245
246 /**
247 * Determines if the parameter represents a variable argument list.
248 */
249 public boolean isVarArgs() {
250 return method.isVarArgs() && index == method.getSignature().getParameterCount(false) - 1;
251 }
252
253 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
254 return method.getParameterAnnotations(annotationClass)[index];
255 }
256
257 public Annotation[] getAnnotations() {
258 return method.getParameterAnnotations()[index];
259 }
260
261 public Annotation[] getDeclaredAnnotations() {
262 return getAnnotations();
263 }
264
265 @Override
266 public String toString() {
|
160 * @param includeOSR if true,
161 * {@linkplain ProfilingInfo#getDeoptimizationCount(DeoptimizationReason)
162 * deoptimization counts} will include deoptimization that happened during execution
163 * of on-stack-replacement methods.
164 */
165 ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR);
166
167 /**
168 * Invalidates the profiling information and restarts profiling upon the next invocation.
169 */
170 void reprofile();
171
172 /**
173 * Returns the constant pool of this method.
174 */
175 ConstantPool getConstantPool();
176
177 /**
178 * A {@code Parameter} provides information about method parameters.
179 */
180 class Parameter implements AnnotatedElement {
181 private final String name;
182 private final ResolvedJavaMethod method;
183 private final int modifiers;
184 private final int index;
185
186 /**
187 * Constructor for {@code Parameter}.
188 *
189 * @param name the name of the parameter or {@code null} if there is no
190 * {@literal MethodParameters} class file attribute providing a non-empty name
191 * for the parameter
192 * @param modifiers the modifier flags for the parameter
193 * @param method the method which defines this parameter
194 * @param index the index of the parameter
195 */
196 public Parameter(String name,
197 int modifiers,
198 ResolvedJavaMethod method,
199 int index) {
200 assert name == null || !name.isEmpty();
201 this.name = name;
202 this.modifiers = modifiers;
203 this.method = method;
204 this.index = index;
205 }
206
207 /**
208 * Gets the name of the parameter. If the parameter's name is {@linkplain #isNamePresent()
209 * present}, then this method returns the name provided by the class file. Otherwise, this
210 * method synthesizes a name of the form argN, where N is the index of the parameter in the
211 * descriptor of the method which declares the parameter.
212 *
213 * @return the name of the parameter, either provided by the class file or synthesized if
214 * the class file does not provide a name
215 */
216 public String getName() {
217 if (name == null) {
218 return "arg" + index;
219 } else {
220 return name;
221 }
222 }
223
224 /**
225 * Gets the method declaring the parameter.
226 */
227 public ResolvedJavaMethod getDeclaringMethod() {
228 return method;
229 }
230
231 /**
232 * Get the modifier flags for the parameter.
233 */
234 public int getModifiers() {
235 return modifiers;
236 }
237
238 /**
239 * Gets the kind of the parameter.
240 */
241 public JavaKind getKind() {
242 return method.getSignature().getParameterKind(index);
243 }
244
245 /**
246 * Gets the formal type of the parameter.
247 */
248 public Type getParameterizedType() {
249 return method.getGenericParameterTypes()[index];
250 }
251
252 /**
253 * Gets the type of the parameter.
254 */
255 public JavaType getType() {
256 return method.getSignature().getParameterType(index, method.getDeclaringClass());
257 }
258
259 /**
260 * Determines if the parameter has a name according to a {@literal MethodParameters} class
261 * file attribute.
262 *
263 * @return true if and only if the parameter has a name according to the class file.
264 */
265 public boolean isNamePresent() {
266 return name != null;
267 }
268
269 /**
270 * Determines if the parameter represents a variable argument list.
271 */
272 public boolean isVarArgs() {
273 return method.isVarArgs() && index == method.getSignature().getParameterCount(false) - 1;
274 }
275
276 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
277 return method.getParameterAnnotations(annotationClass)[index];
278 }
279
280 public Annotation[] getAnnotations() {
281 return method.getParameterAnnotations()[index];
282 }
283
284 public Annotation[] getDeclaredAnnotations() {
285 return getAnnotations();
286 }
287
288 @Override
289 public String toString() {
|