Skip to main content
Glama

find_reflection_usage

Detect Java reflection API calls like Class.forName and Method.invoke to reveal dynamic usages static reference searches miss and renames can break.

Instructions

Find places where Java reflection API is used.

USAGE: find_reflection_usage() OUTPUT: All reflection calls grouped by method type

Detects calls to:

  • Class.forName(), Class.newInstance()

  • Class.getMethod/getDeclaredMethod/getField/getDeclaredField

  • Class.getConstructor/getDeclaredConstructor

  • Method.invoke(), Field.get/set(), Constructor.newInstance()

These usages are invisible to static reference searches and can break when types or methods are renamed.

maxResults caps the calls listed for each reflection method, all its overloads together (default 100), in source order: by file, then position. summary counts every call of each reflection method, and totalCalls and meta.totalCount count every call; meta.truncated is true when calls are left out. potentialMatches lists, the first maxResults of each reflection method in source order, the calls JDT could not confirm, each with its reflection method.

potentialMatches, present only when there are any, holds the places JDT's search reports as possible matches but cannot confirm, because a type or name there does not resolve (a missing dependency or a compile error): count is their exact number, and locations lists them, as many as the results it stands beside may list. They are never counted or listed as results.

Requires load_project to be called first.

Input Schema

NameRequiredDescriptionDefault
maxResultsNoMaximum results per reflection method (default 100)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.4
  2. Removedv1.3.3
  3. First observedv1.2.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so thoroughly: it discloses output grouping, truncation behavior (meta.truncated, meta.totalCount), how maxResults applies per method across overloads, and the special potentialMatches semantics (unresolved types never counted or listed as results). This is rich behavioral disclosure beyond what any structured field provides.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and organized into USAGE/OUTPUT/Detects sections, but the potentialMatches explanation is verbose and partly redundant ('count is their exact number, and locations lists them, as many as the results it stands beside may list'). The load_project prerequisite is buried at the very end rather than surfaced up front.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description must explain return values and does: it covers summary counts, totalCalls, meta truncation flags, and the potentialMatches edge case. For a single-optional-param analysis tool, nothing an agent needs to interpret or call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning: maxResults caps results 'for each reflection method, all its overloads together' in source order (by file, then position) – a per-method-across-overloads and ordering rule not present in the schema's terse 'Maximum results per reflection method'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Find places where Java reflection API is used') and enumerates exactly which calls count (Class.forName, getDeclaredMethod, Method.invoke, etc.). It also distinguishes itself from sibling reference-search tools by noting these usages are 'invisible to static reference searches', so an agent can tell it apart from find_references without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a hard prerequisite ('Requires load_project to be called first') and an implicit when-to-use rationale (reflection calls that evade static reference searches). It does not name a specific sibling alternative or state exclusions, so it is clear context rather than explicit routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.