Skip to content

Upgrade to Java 21: sample.daytrader3 - #2

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1784000342-upgrade-java21
Open

devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1784000342-upgrade-java21

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Summary

Migrates DayTrader3 (an online stock-trading benchmark: login, portfolio, quotes, buy/sell, holdings) from Java 8 / Java EE 6 to build and run on Java 21, while preserving externally observable trading behavior. No domain/business logic is changed — the change set is confined to build config, a Derby CVE bump, added regression tests, CI and docs. Jira: JEFF-DT3-JAVA21.

Full written migration plan is in MIGRATION.md (architecture, Java 8 assumptions, required vs. optional work, high-risk trade-path items).

Migration summary (what changed & why)

The app compiled against -source/-target 1.7, which javac 21 rejects, and used two API groups removed from the JDK in Java 11 (JEP 320). Those APIs are re-added as explicit dependencies keeping the javax.* namespace, so no source code changes were needed:

  • javax.xml.bind (JAXB) — used by the REST address-book sample → javax.xml.bind:jaxb-api (provided).
  • javax.annotation (@PostConstruct/@Resource) — used by EJB + web modules → javax.annotation:javax.annotation-api (provided).

Compiler targets set to Java 21 in Maven (root pom.xml maven.compiler.release=21 + pinned modern plugin versions) and Gradle (sourceCompatibility/targetCompatibility = VERSION_21 per module). One EAR-plugin config had to be modernized (fileNameMapping was removed in maven-ear-plugin 3.0.0 → outputFileNameMapping).

# root pom.xml
+ <maven.compiler.release>21</maven.compiler.release>
+ pluginManagement: maven-compiler-plugin 3.13.0, surefire 3.2.5, ear 3.3.0, war 3.4.0
+ <derby.version>10.17.1.0</derby.version>

# daytrader3-ee6/pom.xml (EAR)
- <fileNameMapping>no-version</fileNameMapping>
+ <outputFileNameMapping>@{artifactId}@.@{extension}@</outputFileNameMapping>
- derby 10.10.1.1  →  + derby / derbyshared / derbytools 10.17.1.0

Architecture summary

Maven+Gradle multi-module reactor targeting WebSphere Liberty:
daytrader3-ee6-ejb (JPA entities + EJB/JDBC business logic) → packaged with daytrader3-ee6-web (servlets/JSP/JSF) and daytrader3-ee6-rest (JAX-RS) into the daytrader3-ee6 EAR; daytrader3-ee6-wlpcfg holds Liberty server config. All EE APIs are container-provided; the JDK removals above only affect compile-time classpath. The Java EE 6 (javax.*) programming model is intentionally retained — a Jakarta EE (jakarta.*) migration is a separate, larger effort and is out of scope.

Changed dependencies + reasons

Dependency From → To Reason
org.apache.derby:derby (+ new derbyshared, derbytools) 10.10.1.1 → 10.17.1.0 Java 21 support + CVE remediation (see below). Derby 10.15+ is modularized, hence the two companion jars.
javax.xml.bind:jaxb-api (new, provided) JAXB removed from JDK in Java 11 (JEP 320).
javax.annotation:javax.annotation-api (new, provided) Common Annotations removed from JDK in Java 11 (JEP 320).
Maven compiler/surefire/ear/war plugins legacy (inherited) → 3.13.0 / 3.2.5 / 3.3.0 / 3.4.0 Java 21 toolchain support + JUnit 5.
org.junit.jupiter:junit-jupiter (new, test) Regression test framework.

Security findings addressed

Derby 10.10.1.1 → 10.17.1.0 remediates:

Test evidence

Repo previously shipped no tests. Added 27 JUnit 5 regression tests in daytrader3-ee6-ejb/src/test covering the requested surfaces:

  • Order creation / lifecycle — OrderDataBeanTest (buy/sell classification, open/processing/completed/cancelled, symbol resolution, 24.95 fee).
  • Quote retrieval — QuoteDataBeanTest.
  • Buy/sell execution math — BuySellExecutionTest (balance debit = cost + fee; credit = proceeds − fee; round-trip P&L) + TradeConfigTest (fee schedule) + MarketSummaryDataBeanTest.
  • Holdings valuation — HoldingDataBeanTest, FinancialUtilsTest (gain, gain %, holdings total).
$ mvn -B clean package      # JDK 21
Tests run: 27, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS   (dt-ejb.jar, web.war, Rest.war, daytrader3-ee6.ear all built)

CI runs mvn clean package on Temurin 21 (new .github/workflows/ci.yml; .travis.yml JDK bumped to 21). package stops before the integration-test phases, so unit CI does not require downloading/running Liberty.

Remaining risks

  • Derby major upgrade (10.10 → 10.17) is the highest-risk item for observable behavior. The embedded driver class and SQL dialect used by TradeDirect are unchanged, but the runtime now needs derbyshared/derbytools on the server classpath (added to the EAR copy step). Money math should be re-verified against a running Liberty + Derby server.
  • Full end-to-end trade-path validation (login → quote → buy → portfolio → sell) runs against a live Liberty server and is not part of unit CI; it remains a manual functional test.
  • ~30 deprecated boxing/BigDecimal(double) constructors remain (compile with warnings only) — intentionally left to avoid trade-path churn.

Human-review checklist

  • Deploy the EAR to WebSphere Liberty on a Java 21 JRE and confirm it starts.
  • Smoke-test the trade path: register/login, get a quote, buy, check portfolio/holdings, sell, verify balance and P&L.
  • Confirm the Derby datasource initializes and existing data reads correctly with derby/derbyshared/derbytools 10.17.1.0.
  • Confirm the REST sample war deploys (JAXB provided at runtime).
  • Confirm javax.* (not Jakarta) is still the intended runtime target.

Rollback guidance

Change set is limited to build files, Derby version, test sources, CI and docs — no schema or business-logic changes, so no data migration.

  • Full rollback: revert this PR and redeploy the previous Java 8 EAR (Derby data format unchanged).
  • Partial: if only Derby is problematic, revert derby.version while keeping the Java 21 compiler settings.

Link to Devin session: https://app.devin.ai/sessions/3c4680e962e14711bdd913a76d01de25
Requested by: @achalc


Devin Review

Status Commit
⚪ Not started —

Run Devin Review

Open in Devin Review (Staging)

Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
@achalc achalc self-assigned this Jul 14, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

1 participant