[MPH-191] Fix help:evaluate failing on Java 18+ due to Hashtable reflection - #402
Open
elharo wants to merge 2 commits into
Open
[MPH-191] Fix help:evaluate failing on Java 18+ due to Hashtable reflection#402elharo wants to merge 2 commits into
elharo wants to merge 2 commits into
Conversation
…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+.
There was a problem hiding this comment.
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 acceptPropertiessubclasses viaisAssignableFrom. - Add a regression test validating evaluation/serialization when the evaluated expression returns a
Propertiessubclass.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
help:evaluatefails on Java 18+ when evaluating expressions that returnPropertiessubclasses (e.g.project.propertiesaftereffective-pomreplaces them withSortedProperties). The custom XStreamPropertiesConverterused exact class match (Properties.class == type), so subclasses fall through toSerializableConverter, which tries to reflectively accessjava.util.Hashtable.table— forbidden by the Java module system.Fix: Changed
Properties.class == typetoProperties.class.isAssignableFrom(type)incanConvert(), so allPropertiessubclasses are handled by the converter that simply copies entries into aTreeMap, avoiding reflection onHashtable.Fixes #166