Skip to content

[java] Deprecate methods to avoid internal BiDi connection surfacing on driver#17751

Merged
pujagani merged 1 commit into
SeleniumHQ:trunkfrom
pujagani:origin-trunk
Jul 6, 2026
Merged

[java] Deprecate methods to avoid internal BiDi connection surfacing on driver#17751
pujagani merged 1 commit into
SeleniumHQ:trunkfrom
pujagani:origin-trunk

Conversation

@pujagani

@pujagani pujagani commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🔗 Related Issues

To align the Java BiDi code with the ADR #17670

💥 What does this PR do?

It deprecates methods that allow get BiDi internals on driver object

🔧 Implementation Notes

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s):
    • What was generated:
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

🔄 Types of changes

  • Deprecation

@selenium-ci selenium-ci added C-java Java Bindings B-devtools Includes everything BiDi or Chrome DevTools related labels Jul 6, 2026
@pujagani pujagani merged commit 3936678 into SeleniumHQ:trunk Jul 6, 2026
9 of 10 checks passed
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Deprecate HasBiDi accessors to keep BiDi internals off Java drivers

✨ Enhancement 🕐 Less than 5 minutes

Grey Divider

AI Description

• Deprecate direct driver access to the internal BiDi connection to align with the ADR.
• Mark getBiDi() and maybeGetBiDi() for removal and document the future-breaking change.
Diagram

graph TD
  D["WebDriver impl"] --> H["HasBiDi (deprecated)"] --> B[("BiDi connection")]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Remove HasBiDi accessors immediately
  • ➕ Eliminates internal API leakage and maintenance burden right away
  • ➕ Forces ecosystem to migrate to the intended public surface
  • ➖ Hard breaking change; likely impacts downstream users immediately
  • ➖ No transition window for migration guidance/tools
2. Move BiDi access behind a dedicated public capability API
  • ➕ Provides a supported, stable surface without exposing the raw BiDi object
  • ➕ Allows controlled feature gating and evolution
  • ➖ Requires additional design and implementation work across drivers
  • ➖ May still need a transition plan from existing HasBiDi usage
3. Keep methods but narrow exposure (internal package / restricted visibility)
  • ➕ Reduces accidental discovery/usage while minimizing immediate breakage
  • ➖ Java module/visibility constraints may not fully prevent usage in typical builds
  • ➖ Still leaves a semi-supported escape hatch that conflicts with the ADR intent

Recommendation: Proceed with deprecation-for-removal as in this PR: it aligns with the ADR while providing a clear migration signal and a transition window. Consider follow-up work to document the intended replacement public API/capability for users who currently depend on direct BiDi access.

Files changed (1) +10 / -0

Enhancement (1) +10 / -0
HasBiDi.javaDeprecate BiDi accessor methods on HasBiDi +10/-0

Deprecate BiDi accessor methods on HasBiDi

• Adds Javadoc and '@Deprecated(since = "4.46", forRemoval = true)' to 'getBiDi()' and 'maybeGetBiDi()'. This communicates that BiDi access from drivers is an internal detail and will be removed in a future release.

java/src/org/openqa/selenium/bidi/HasBiDi.java

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. getBiDi() Javadoc missing @return 📘 Rule violation ✧ Quality
Description
The new Javadoc for public methods getBiDi() and maybeGetBiDi() contains only an @deprecated
tag and omits required documentation, including a free-text description and @return tags. This
reduces API documentation quality and violates the requirement for complete Javadoc on public
methods.
Code

java/src/org/openqa/selenium/bidi/HasBiDi.java[R25-40]

+  /**
+   * @deprecated BiDi is an internal implementation detail. Direct access to the BiDi object from
+   *     drivers will be removed in a future release.
+   */
+  @Deprecated(since = "4.46", forRemoval = true)
  default BiDi getBiDi() {
    return maybeGetBiDi()
        .orElseThrow(() -> new BiDiException("Unable to create a BiDi connection"));
  }

+  /**
+   * @deprecated BiDi is an internal implementation detail. Direct access to the BiDi object from
+   *     drivers will be removed in a future release.
+   */
+  @Deprecated(since = "4.46", forRemoval = true)
  Optional<BiDi> maybeGetBiDi();
Evidence
PR Compliance ID 330201 requires complete Javadoc on changed public methods, including a free-text
description and an @return tag for non-void returns. The updated Javadoc blocks for getBiDi()
and maybeGetBiDi() contain only @deprecated text and no @return tag.

Rule 330201: Require complete Javadoc on public API methods
java/src/org/openqa/selenium/bidi/HasBiDi.java[25-40]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Public methods `getBiDi()` and `maybeGetBiDi()` have new Javadoc that only includes an `@deprecated` tag, but is missing (a) at least one free-text sentence describing the method and (b) an `@return` tag.

## Issue Context
These methods are part of a `public interface` and therefore need complete Javadoc per the checklist.

## Fix Focus Areas
- java/src/org/openqa/selenium/bidi/HasBiDi.java[25-40]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Deprecated methods lack alternative guidance 📘 Rule violation ☼ Reliability
Description
The new @deprecated Javadoc text explains removal intent but does not name a recommended
alternative or explicitly state there is no replacement. This violates the requirement that
deprecated public APIs include guidance before removal.
Code

java/src/org/openqa/selenium/bidi/HasBiDi.java[R25-39]

+  /**
+   * @deprecated BiDi is an internal implementation detail. Direct access to the BiDi object from
+   *     drivers will be removed in a future release.
+   */
+  @Deprecated(since = "4.46", forRemoval = true)
  default BiDi getBiDi() {
    return maybeGetBiDi()
        .orElseThrow(() -> new BiDiException("Unable to create a BiDi connection"));
  }

+  /**
+   * @deprecated BiDi is an internal implementation detail. Direct access to the BiDi object from
+   *     drivers will be removed in a future release.
+   */
+  @Deprecated(since = "4.46", forRemoval = true)
Evidence
PR Compliance ID 389271 requires deprecated public APIs to include guidance naming an alternative or
stating "no replacement". The added @deprecated text only says BiDi access is internal and will be
removed, without any alternative or explicit no-replacement statement.

Rule 389271: Deprecate public APIs with guidance before removal
java/src/org/openqa/selenium/bidi/HasBiDi.java[25-39]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `@deprecated` Javadoc for `getBiDi()` and `maybeGetBiDi()` does not provide guidance on what callers should use instead, nor does it explicitly state "no replacement".

## Issue Context
The checklist requires deprecated public APIs to include a human-readable message that names or links to the recommended alternative, or explicitly states there is no replacement.

## Fix Focus Areas
- java/src/org/openqa/selenium/bidi/HasBiDi.java[25-29]
- java/src/org/openqa/selenium/bidi/HasBiDi.java[35-39]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines +25 to 40
/**
* @deprecated BiDi is an internal implementation detail. Direct access to the BiDi object from
* drivers will be removed in a future release.
*/
@Deprecated(since = "4.46", forRemoval = true)
default BiDi getBiDi() {
return maybeGetBiDi()
.orElseThrow(() -> new BiDiException("Unable to create a BiDi connection"));
}

/**
* @deprecated BiDi is an internal implementation detail. Direct access to the BiDi object from
* drivers will be removed in a future release.
*/
@Deprecated(since = "4.46", forRemoval = true)
Optional<BiDi> maybeGetBiDi();

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.

Action required

1. getbidi() javadoc missing @return 📘 Rule violation ✧ Quality

The new Javadoc for public methods getBiDi() and maybeGetBiDi() contains only an @deprecated
tag and omits required documentation, including a free-text description and @return tags. This
reduces API documentation quality and violates the requirement for complete Javadoc on public
methods.
Agent Prompt
## Issue description
Public methods `getBiDi()` and `maybeGetBiDi()` have new Javadoc that only includes an `@deprecated` tag, but is missing (a) at least one free-text sentence describing the method and (b) an `@return` tag.

## Issue Context
These methods are part of a `public interface` and therefore need complete Javadoc per the checklist.

## Fix Focus Areas
- java/src/org/openqa/selenium/bidi/HasBiDi.java[25-40]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +25 to +39
/**
* @deprecated BiDi is an internal implementation detail. Direct access to the BiDi object from
* drivers will be removed in a future release.
*/
@Deprecated(since = "4.46", forRemoval = true)
default BiDi getBiDi() {
return maybeGetBiDi()
.orElseThrow(() -> new BiDiException("Unable to create a BiDi connection"));
}

/**
* @deprecated BiDi is an internal implementation detail. Direct access to the BiDi object from
* drivers will be removed in a future release.
*/
@Deprecated(since = "4.46", forRemoval = true)

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.

Action required

2. Deprecated methods lack alternative guidance 📘 Rule violation ☼ Reliability

The new @deprecated Javadoc text explains removal intent but does not name a recommended
alternative or explicitly state there is no replacement. This violates the requirement that
deprecated public APIs include guidance before removal.
Agent Prompt
## Issue description
The `@deprecated` Javadoc for `getBiDi()` and `maybeGetBiDi()` does not provide guidance on what callers should use instead, nor does it explicitly state "no replacement".

## Issue Context
The checklist requires deprecated public APIs to include a human-readable message that names or links to the recommended alternative, or explicitly states there is no replacement.

## Fix Focus Areas
- java/src/org/openqa/selenium/bidi/HasBiDi.java[25-29]
- java/src/org/openqa/selenium/bidi/HasBiDi.java[35-39]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-devtools Includes everything BiDi or Chrome DevTools related C-java Java Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants