Skip to content

J21 Updates, depreciation, and some ATB Code path removals.#8898

Merged
rjhancock merged 2 commits into
MegaMek:mainfrom
rjhancock:language-updates
Apr 21, 2026
Merged

J21 Updates, depreciation, and some ATB Code path removals.#8898
rjhancock merged 2 commits into
MegaMek:mainfrom
rjhancock:language-updates

Conversation

@rjhancock

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings April 21, 2026 22:59
@rjhancock rjhancock requested a review from a team as a code owner April 21, 2026 22:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the codebase for Java 21 usage and continues the ongoing deprecation/cleanup work, including removing legacy/unused AtB-facing UI/test paths and replacing older utility APIs with standard Java 21 or upstream MegaMek equivalents.

Changes:

  • Remove legacy/disabled AtB-related UI flows and deprecated dialogs/tests.
  • Replace JScrollPaneWithSpeed usages with FastJScrollPane across many GUI panels/tabs.
  • Apply Java 21 refactors/cleanup (e.g., Math.clamp, Stream.toList(), parameterized logging, switch patterns) and mark additional APIs as @Deprecated(forRemoval=true).

Reviewed changes

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

Show a summary per file
File Description
MekHQ/unittests/mekhq/gui/enums/PersonnelTabViewTest.java Removes deprecated test method.
MekHQ/unittests/mekhq/gui/dialog/nagDialogs/nagLogic/UnableToAffordJumpNagLogicTest.java Deletes disabled/deprecated test.
MekHQ/unittests/mekhq/gui/dialog/nagDialogs/nagLogic/NoCommanderNagLogicTest.java Deletes deprecated test.
MekHQ/unittests/mekhq/campaign/universe/TestSystems.java Removes helper mutator method.
MekHQ/unittests/mekhq/campaign/unit/cleanup/MovedEquipmentStepTest.java Simplifies Mockito answers/imports.
MekHQ/unittests/mekhq/campaign/unit/cleanup/MovedAmmoBinTest.java Simplifies Mockito answers.
MekHQ/unittests/mekhq/campaign/unit/UnitPersonTest.java Javadoc formatting/import cleanup.
MekHQ/unittests/mekhq/campaign/unit/UnitIOTest.java Import/javadoc formatting and minor signature tweak.
MekHQ/unittests/mekhq/campaign/personnel/medical/advancedMedical/InjuryTypesTest.java Uses method reference for assertDoesNotThrow.
MekHQ/unittests/mekhq/campaign/personnel/familyTree/FormerSpouseTest.java Removes redundant self-equality assertion.
MekHQ/unittests/mekhq/campaign/personnel/InjuryTypeTest.java Improves assertions and formatting (assertNull, lambda simplification).
MekHQ/unittests/mekhq/campaign/mission/MHQMoraleTest.java Removes unused imports.
MekHQ/unittests/mekhq/campaign/market/TestPartsStore.java Formatting + removes heavy “reallyStock” helper.
MekHQ/unittests/mekhq/campaign/market/ContractMarketAtBGenerationTests.java Deletes large disabled/deprecated AtB generation test suite.
MekHQ/unittests/mekhq/campaign/camOpsReputation/FieldManualMercRevDragoonsRatingTest.java Deletes disabled/deprecated test.
MekHQ/unittests/mekhq/campaign/WarehouseTest.java Removes stray statement.
MekHQ/unittests/mekhq/campaign/CampaignTest.java Assertion/javadoc formatting improvements in temp-crew tests.
MekHQ/unittests/asserts/BigDecimalAssert.java Deletes custom assertion helper.
MekHQ/src/mekhq/utilities/spaUtilities/SpaUtilities.java Deprecates isSpaCategory.
MekHQ/src/mekhq/utilities/ValidationResult.java Deprecates getPlanetsValidated.
MekHQ/src/mekhq/utilities/ReportingUtilities.java Deprecates surroundIf.
MekHQ/src/mekhq/service/mrms/MRMSService.java Adds/removes deprecations on MRMS action/status accessors.
MekHQ/src/mekhq/service/mrms/MRMSOption.java Uses parameterized logging for invalid type IDs.
MekHQ/src/mekhq/service/PartsAcquisitionService.java Deprecates various static setters.
MekHQ/src/mekhq/module/atb/PersonnelMarketAtB.java Deprecates legacy AtB personnel market implementation.
MekHQ/src/mekhq/module/atb/AtBEventProcessor.java Deprecates record + avoids regex replace where not needed.
MekHQ/src/mekhq/module/AbstractServiceManager.java Deprecates getAllServices() + uses Stream.toList().
MekHQ/src/mekhq/gui/view/PersonViewPanel.java Replaces MathUtility.clamp with Math.clamp.
MekHQ/src/mekhq/gui/view/PaperDoll.java Deprecates legacy setters/getters.
MekHQ/src/mekhq/gui/view/MissionViewPanel.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/view/ForceViewPanel.java Removes AtB tooltip wiring.
MekHQ/src/mekhq/gui/utilities/StaticChecks.java Deprecates several “areAll…” helpers.
MekHQ/src/mekhq/gui/utilities/MultiLineTooltip.java Javadoc formatting cleanup.
MekHQ/src/mekhq/gui/utilities/MarkdownEditorPanel.java Swaps to FastJScrollPane and refactors header insertion.
MekHQ/src/mekhq/gui/utilities/JSuggestField.java Swaps to FastJScrollPane + deprecates legacy API surface.
MekHQ/src/mekhq/gui/stratCon/TrackForceAssignmentUI.java Swaps to FastJScrollPane + formats deploy call.
MekHQ/src/mekhq/gui/panes/UnitMarketPane.java Swaps to FastJScrollPane + formatting.
MekHQ/src/mekhq/gui/panes/RankSystemsPane.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java Deprecates panel.
MekHQ/src/mekhq/gui/model/UnitTableModel.java Minor formatting + uses StringBuilder.isEmpty().
MekHQ/src/mekhq/gui/model/TaskTableModel.java Deprecates getTasksAt.
MekHQ/src/mekhq/gui/model/PartsInUseTableModel.java Deprecates row update and focus border accessors.
MekHQ/src/mekhq/gui/model/ObjectiveTableModel.java Deprecates addObjective.
MekHQ/src/mekhq/gui/model/FilterableListModel.java Deprecates no-arg constructor.
MekHQ/src/mekhq/gui/model/BotForceTableModel.java Deprecates getAllBotForces.
MekHQ/src/mekhq/gui/menus/AssignPersonToUnitMenu.java Switch pattern refactor for entity type checks.
MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java Deprecates legacy column-type helpers + StringBuilder.isEmpty().
MekHQ/src/mekhq/gui/enums/PersonnelTabView.java Deprecates isMedicalSkills.
MekHQ/src/mekhq/gui/enums/PersonnelFilter.java Deprecates isCampFollower.
MekHQ/src/mekhq/gui/dialog/nagDialogs/UnableToAffordJumpNagDialog.java Deletes nag dialog implementation.
MekHQ/src/mekhq/gui/dialog/nagDialogs/NoCommanderNagDialog.java Deletes deprecated nag dialog implementation.
MekHQ/src/mekhq/gui/WarehouseTab.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/TOETab.java Swaps to FastJScrollPane + stream formatting.
MekHQ/src/mekhq/gui/StratConTab.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/StratConPanel.java Deprecates isCommitForces.
MekHQ/src/mekhq/gui/RepairTab.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/PlanetarySystemMapPanel.java Deprecates removeActionListener.
MekHQ/src/mekhq/gui/PersonnelTab.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/MekLabTab.java Swaps to FastJScrollPane for tab contents.
MekHQ/src/mekhq/gui/MapTab.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/InterstellarMapPanel.java Uses Math.clamp + deprecates removeActionListener.
MekHQ/src/mekhq/gui/InfirmaryTab.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/HangarTab.java Swaps to FastJScrollPane.
MekHQ/src/mekhq/gui/FinancesTab.java Swaps to FastJScrollPane + refactors asset-name padding.
MekHQ/src/mekhq/gui/FileDialogs.java Deprecates openPlanetsTsv.
MekHQ/src/mekhq/gui/CommandCenterTab.java Swaps to FastJScrollPane + lambda simplification.
MekHQ/src/mekhq/gui/CampaignGUI.java Removes contract-market menu + removes AtB toggle/init path + simplifies new contract dialog selection.
MekHQ/src/mekhq/gui/BriefingTab.java Removes AtB-specific UI plumbing and AtB-only scenario view handling.
MekHQ/src/mekhq/Utilities.java Switch pattern refactor + Math.clamp usage + deprecates file/XML helpers.
MekHQ/src/mekhq/MekHQ.java Deprecates setCampaignGUI + removes AtB-specific game thread selection.
MekHQ/src/mekhq/IconPackage.java Deprecates auto-resolve image accessor.
MekHQ/src/mekhq/AtBGameThread.java Deprecates class and removes unused exception from signature.

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

Comment on lines 366 to 368
JPanel pnlTutorial = new TutorialHyperlinkPanel("missionTab");

setLayout(new BorderLayout());

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

initTab() builds panScenario (and likely panMission earlier) but the tab never adds the main content panel to the layout—only the tutorial panel is added. This will render the Briefing/Mission UI blank. Add an appropriate container (e.g., a split pane or panel) to BorderLayout.CENTER that includes the mission + scenario components.

Suggested change
JPanel pnlTutorial = new TutorialHyperlinkPanel("missionTab");
setLayout(new BorderLayout());
JPanel pnlTutorial = new TutorialHyperlinkPanel("missionTab");
JPanel pnlMainContent = new JPanel(new GridLayout(2, 1));
pnlMainContent.add(panMission);
pnlMainContent.add(panScenario);
setLayout(new BorderLayout());
add(pnlMainContent, BorderLayout.CENTER);

Copilot uses AI. Check for mistakes.
Comment on lines 249 to 252
private void insertHeader(int level) {
StringBuilder toInsert = new StringBuilder();
toInsert.append("#".repeat(Math.max(0, level)));
toInsert.repeat("#", Math.max(0, level));
toInsert.append(" ");

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

StringBuilder does not provide a repeat(String, int) API in the Java 21 standard library. These calls will not compile (and if you intended repeat(int) semantics, repeating an empty builder would be a no-op). Use append("#".repeat(...))/append(".".repeat(...)) or a small loop instead.

Copilot uses AI. Check for mistakes.
} else {
int numPeriods = 18 - assetName.length();
assetName.append(".".repeat(Math.max(0, numPeriods)));
assetName.repeat(".", Math.max(0, numPeriods));

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

StringBuilder does not provide a repeat(String, int) API in the Java 21 standard library, so this will not compile as written. Prefer assetName.append(".".repeat(...)) or a small loop to add the padding characters.

Suggested change
assetName.repeat(".", Math.max(0, numPeriods));
assetName.append(".".repeat(Math.max(0, numPeriods)));

Copilot uses AI. Check for mistakes.
} else if (entity1 instanceof Tank) {
if (entity1.getMovementMode() != entity2.getMovementMode()) {
return false;
case Tank ignored -> {
valid = false;
}
final boolean valid = switch (entity) {
case Mek ignored -> areAllBattleMekPilots;
}
final boolean valid = switch (entity) {
case Mek ignored -> areAllBattleMekPilots;
case ProtoMek ignored -> areAllProtoMekPilots;
final boolean valid = switch (entity) {
case Mek ignored -> areAllBattleMekPilots;
case ProtoMek ignored -> areAllProtoMekPilots;
case ConvFighter ignored -> areAllConventionalAircraftPilots;
case Mek ignored -> areAllBattleMekPilots;
case ProtoMek ignored -> areAllProtoMekPilots;
case ConvFighter ignored -> areAllConventionalAircraftPilots;
case Aero ignored -> areAllAerospacePilots;
case ProtoMek ignored -> areAllProtoMekPilots;
case ConvFighter ignored -> areAllConventionalAircraftPilots;
case Aero ignored -> areAllAerospacePilots;
case VTOL ignored -> areAllVTOLCrew;
@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0.74627% with 133 lines in your changes missing coverage. Please review.
✅ Project coverage is 13.81%. Comparing base (468c109) to head (22fb504).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
MekHQ/src/mekhq/gui/MekLabTab.java 0.00% 47 Missing ⚠️
MekHQ/src/mekhq/Utilities.java 7.69% 9 Missing and 3 partials ⚠️
MekHQ/src/mekhq/gui/TOETab.java 0.00% 8 Missing ⚠️
...HQ/src/mekhq/gui/menus/AssignPersonToUnitMenu.java 0.00% 7 Missing ⚠️
MekHQ/src/mekhq/gui/BriefingTab.java 0.00% 5 Missing ⚠️
MekHQ/src/mekhq/gui/CommandCenterTab.java 0.00% 5 Missing ⚠️
MekHQ/src/mekhq/gui/RepairTab.java 0.00% 5 Missing ⚠️
MekHQ/src/mekhq/gui/FinancesTab.java 0.00% 4 Missing ⚠️
...src/mekhq/gui/stratCon/TrackForceAssignmentUI.java 0.00% 4 Missing ⚠️
MekHQ/src/mekhq/gui/InfirmaryTab.java 0.00% 3 Missing ⚠️
... and 19 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8898      +/-   ##
============================================
+ Coverage     13.79%   13.81%   +0.02%     
+ Complexity     8179     8177       -2     
============================================
  Files          1285     1283       -2     
  Lines        167606   167433     -173     
  Branches      25279    25237      -42     
============================================
+ Hits          23126    23136      +10     
+ Misses       142152   141967     -185     
- Partials       2328     2330       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rjhancock rjhancock merged commit 35ebf73 into MegaMek:main Apr 21, 2026
8 checks passed
@rjhancock rjhancock deleted the language-updates branch April 21, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants