Skip to content

[MPH-191] Fix help:evaluate failing on Java 18+ due to Hashtable reflection - #402

Open
elharo wants to merge 2 commits into
masterfrom
fix-mph-191
Open

[MPH-191] Fix help:evaluate failing on Java 18+ due to Hashtable reflection#402
elharo wants to merge 2 commits into
masterfrom
fix-mph-191

Conversation

@elharo

@elharo elharo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem: help:evaluate fails on Java 18+ when evaluating expressions that return Properties subclasses (e.g. project.properties after effective-pom replaces them with SortedProperties). The custom XStream PropertiesConverter used exact class match (Properties.class == type), so subclasses fall through to SerializableConverter, which tries to reflectively access java.util.Hashtable.table — forbidden by the Java module system.

Fix: Changed Properties.class == type to Properties.class.isAssignableFrom(type) in canConvert(), so all Properties subclasses are handled by the converter that simply copies entries into a TreeMap, avoiding reflection on Hashtable.

Fixes #166

…ection

Change PropertiesConverter.canConvert() to use isAssignableFrom()
instead of exact class match, so that subclasses of Properties
(e.g. SortedProperties) are handled without falling through to
SerializableConverter which tries to reflectively access
java.util.Hashtable.table, forbidden on Java 18+.
@elharo
elharo requested a review from Copilot July 29, 2026 11:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Fixes help:evaluate failures on Java 18+ by ensuring XStream treats Properties subclasses with the custom PropertiesConverter, avoiding illegal reflective access to java.util.Hashtable internals.

Changes:

  • Update XStream PropertiesConverter#canConvert() to accept Properties subclasses via isAssignableFrom.
  • Add a regression test validating evaluation/serialization when the evaluated expression returns a Properties subclass.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java Broaden converter eligibility to cover Properties subclasses and prevent fallback to reflective serialization.
src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java Add regression test exercising help:evaluate with a Properties subclass result.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@elharo elharo added the bug Something isn't working label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MPH-191] help:evaluate fails on Java 18 - java.util.Hashtable.table not accessible

2 participants