apache / apache/maven-help-plugin

DescribeMojo.toLines() delegates to generated HelpMojo via fragile reflection

Open
#390 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
29
Forks
42
Avg merge
1d 12h
Merged PRs (30d)
6

Description

In src/main/java/org/apache/maven/plugins/help/DescribeMojo.java:747-778:

Method m = HelpMojo.class.getDeclaredMethod("toLines", String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE);
m.setAccessible(true);
List output = (List) m.invoke(HelpMojo.class, text, indent, indentSize, lineLength);

HelpMojo is generated by maven-plugin-tools at compile time (in target/generated-sources/). It IS available at runtime, but this reflection is brittle: any change in the generated code toLines signature silently breaks all describe output formatting. The HelpMojo.toLines internally calls repeat() with new StringBuilder(repeat * str.length()) — a classic integer overflow risk that can throw NegativeArraySizeException.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/main/java/org/apache/maven/plugins/help/DescribeMojo.java:747-778 and inspect the generated HelpMojo.toLines and repeat implementations in target/generated-sources. Verify how describe output formatting is delegated and where integer overflow can occur. Done means describe formatting remains correct without brittle signature dependence or overflow failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.