`AddJaxbAPIDependencies` silently no-ops when `javax.xml.bind` is only JDK-provided
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- java
- 領域
- build-system, devtools
調査の方向性
Start with jaxb-apis.yml at the AddJaxbAPIDependencies recipe and trace its onlyIfUsing condition when parsing the supplied Java example on JDK 11 or later. Compare the related recipes named in the issue and add a regression test for a module using javax.xml.bind with no JAXB dependency. Done means the migration adds the required JAXB dependencies and the project no longer has the reported compile break.
索引モデルが issue の本文から書いたものです。
説明
What version of OpenRewrite are you using?
- Moderne CLI v4.8.8
org.openrewrite.recipe:rewrite-migrate-java:3.44.0-20260829.193944-5
Recipe YAML is unchanged on main as of b6526609.
How are you running OpenRewrite?
Moderne CLI against a single-module Maven project:
mod run . --recipe org.openrewrite.java.migrate.UpgradeToJava25
Reached via UpgradeToJava25 -> 21 -> 17 -> Java8toJava11 -> AddJaxbDependenciesWithRuntime -> AddJaxbAPIDependencies. Should also affect the Maven/Gradle plugin whenever the JDK parsing the project is 11+.
Public reproducer: https://github.com/CSPF-Founder/JavaVulnerableLab
What is the smallest, simplest way to reproduce the problem?
A Maven project using JAXB with no JAXB dependency declared — i.e. relying on the JDK to provide it:
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<!-- no javax.xml.bind:jaxb-api / jakarta.xml.bind dependency -->
import javax.xml.bind.DatatypeConverter;
class JwtUtil {
static String base64Url(byte[] data) {
return DatatypeConverter.printBase64Binary(data);
}
}
Run UpgradeToJava25 (or Java8toJava11) parsing with a JDK >= 11.
What did you expect to see?
AddJaxbAPIDependencies adds jakarta.xml.bind:jakarta.xml.bind-api (plus the glassfish runtime), so the project still compiles once source/target are raised.
What did you see instead?
source/target raised to 25, but no JAXB dependency added — leaving the exact compile break the recipe exists to prevent:
[ERROR] .../JwtUtil.java:[6,22] package javax.xml.bind does not exist
[ERROR] .../JwtUtil.java:[59,16] cannot find symbol
[ERROR] symbol: variable DatatypeConverter
Root cause: type-attribution bootstrap problem
# jaxb-apis.yml:117-123
- org.openrewrite.java.dependencies.AddDependency:
groupId: jakarta.xml.bind
artifactId: jakarta.xml.bind-api
version: 2.3.x
onlyIfUsing: javax.xml.bind..* # never matches
acceptTransitive: true
onlyIfUsing needs the type attributed in the LST. But javax.xml.bind is JDK-provided only through Java 8 and was removed in 11 — so when parsed by a JDK >= 11 with no JAXB dependency declared, it never resolves.
The recipe that adds the missing JAXB dependency only fires if the JAXB dependency is already there.
This is attribution, not a broken classpath — FindTypes on the same LST, types from the same file:
| Type | Provided by | Found |
|---|---|---|
javax.crypto.Mac |
JDK (still present) | 1 |
org.json.JSONObject |
declared dep | 2 |
javax.servlet.http.HttpServletRequest |
declared dep | 10 |
javax.xml.bind.DatatypeConverter |
JDK-only, removed in 11 | 0 |
Note the preconditions are not at fault — both recipes use preconditions: [org.openrewrite.Singleton] (jaxb-apis.yml:32, :93) and do run. The inner onlyIfUsing silently no-ops.
Likely affects sibling recipes
Same flaw for any onlyIfUsing on a JDK-11-removed package:
javax.annotation..*—add-common-annotations-dependencies.yml:50javax.activation..*—jakarta-ee-9.yml:106javax.xml.bind..*—jakarta-ee-9.yml:997javax.xml.soap..*—jakarta-ee-9.yml:1092AddJaxwsDependencies
Suggested fix
onlyIfUsing can't be the sole trigger for JDK-removed modules. Either fall back to matching unresolved imports when the type is unattributed, or add an onlyIfUsingImport-style option to AddDependency.
Worth a regression test on a module that uses javax.xml.bind with no JAXB dependency, parsed on a modern JDK — existing tests likely declare it, which is how this slipped through.
Impact
Upgrading any Java <= 8 project relying on JDK-provided JAXB to 11+ produces a silent compile break, with no warning in the recipe output.
- 主要言語
- Java
- スター
- 159
- フォーク
- 130
- 平均マージ
- 6時間 49分
- マージ済み PR(30日)
- 47
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openrewrite/rewrite-migrate-java のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 32/100
openrewrite/rewrite-migrate-java#1227 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
OptionalNotPresentToIsEmpty rewrites `!isPresent()` on a non-`java.util.Optional` type, producing uncompilable `isEmpty()`再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
openrewrite/rewrite-migrate-java#1146 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
openrewrite/rewrite-migrate-java#1119 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
openrewrite/rewrite-migrate-java#1069 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
FacesManagedBeansRemoved for Faces 4.0 recipe updates再び着手できるかも @salaheddinemchich が 189 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
openrewrite/rewrite-migrate-java#1023 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
openrewrite/rewrite-migrate-java の issue をすべて見る
似ている issue
-
Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
MinecraftForge/MinecraftForge#10902 · コメント 1 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
refinedmods/refinedstorage2#1421 ·
-
StepExamBenchmarkTest runs a loop and prints a timing but asserts nothing対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンjules
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
open-learning-exchange/myplanet#18199 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
wikipathways/GPML2RDF#126 ·
-
Authorization 'Artifacts' is shown under category Run instead of Job in Authorization matrix対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信