Skip to content

Add forRemoval=true and since to @deprecated elements; fixes #812 + fix deprecation warnings across the code base post JDK baseline shift to 11#830

Open
rhusar wants to merge 3 commits into
arquillian:mainfrom
rhusar:812-add-forRemoval
Open

Add forRemoval=true and since to @deprecated elements; fixes #812 + fix deprecation warnings across the code base post JDK baseline shift to 11#830
rhusar wants to merge 3 commits into
arquillian:mainfrom
rhusar:812-add-forRemoval

Conversation

@rhusar
Copy link
Copy Markdown
Member

@rhusar rhusar commented Apr 16, 2026

Quick test, mvn clean install | grep WARNING | grep deprecated | grep -v AccessibleObject is now empty result.

Summary by Sourcery

Clarify and harden deprecations after moving to a newer JDK baseline, while updating legacy APIs and usages to avoid deprecation warnings.

Bug Fixes:

  • Fix usage of deprecated APIs such as Class#newInstance(), File#toURL(), and Integer constructors to use modern, non-deprecated alternatives.
  • Ensure JMX protocol uses the context collection API instead of the deprecated single-context accessor to handle JMX contexts correctly.

Enhancements:

  • Annotate deprecated APIs across core, container, protocol, and test modules with forRemoval and since metadata, and extend Javadoc to point to preferred replacements.
  • Add targeted @SuppressWarnings("removal"/"deprecation") annotations where deprecated methods must remain in use for compatibility with existing contracts.
  • Adjust deprecation suppression in tests and lifecycle managers for updated dependencies like JUnit 5.13 and the JDK removal warnings.

Tests:

  • Update test utilities to construct instances via reflective constructors and safe URL conversion, aligning tests with non-deprecated APIs.

rhusar added 3 commits April 16, 2026 11:01
…an#812

Also add @deprecated Javadoc with replacement guidance to all deprecated
elements, add missing @deprecated annotation to TestDeployment constructor,
un-deprecate TestResult#setStatus which is still actively used, and migrate
AbstractJMXProtocol from getContext() to getContexts().

Signed-off-by: Radoslav Husar <radosoft@gmail.com>
Replace new Integer(int) with Integer.valueOf(int), Class.newInstance()
with getDeclaredConstructor().newInstance(), and File.toURL() with
File.toURI().toURL().

Signed-off-by: Radoslav Husar <radosoft@gmail.com>
…move when dropping JUnit 5.13 support

Signed-off-by: Radoslav Husar <radosoft@gmail.com>
@rhusar rhusar requested a review from jamezp April 16, 2026 09:03
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 16, 2026

Reviewer's Guide

This PR modernizes deprecation handling and removes Java 11+ deprecation warnings by adding explicit forRemoval/since metadata and replacement guidance to deprecated APIs, tightening their usage, and updating various call sites and utility code to non‑deprecated alternatives.

Sequence diagram for updated JMX executor context resolution

sequenceDiagram
    participant AbstractJMXProtocol
    participant ProtocolMetaData
    participant JMXContext
    participant MBeanServerConnection

    AbstractJMXProtocol->>ProtocolMetaData: hasContext(JMXContext.class)
    alt JMXContext available
        AbstractJMXProtocol->>ProtocolMetaData: getContexts(JMXContext.class)
        ProtocolMetaData-->>AbstractJMXProtocol: Collection~JMXContext~
        AbstractJMXProtocol->>JMXContext: iterator().next()
        JMXContext-->>AbstractJMXProtocol: JMXContext
        AbstractJMXProtocol->>JMXContext: getConnection()
        JMXContext-->>AbstractJMXProtocol: MBeanServerConnection
        AbstractJMXProtocol->>MBeanServerConnection: use for remote test execution
    else no JMXContext
        AbstractJMXProtocol-->>AbstractJMXProtocol: handle missing JMXContext
    end
Loading

Class diagram for updated deprecation metadata and usage

classDiagram
    class ProtocolMetaData {
        - List~Object~ contexts
        + boolean hasContext(Class clazz)
        + <T> T getContext(Class clazz) <<deprecated>>
        + <T> Collection~T~ getContexts(Class clazz)
    }

    class AbstractJMXProtocol {
        + ProtocolDescription getDescription()
        + ContainerMethodExecutor getExecutor(Object config, ProtocolMetaData metaData, CommandCallback callback)
    }

    class JMXContext {
        + MBeanServerConnection getConnection()
    }

    class ContainerRegistryCreator {
        <<utility>>
        + static String ARQUILLIAN_LAUNCH_PROPERTY
        + static String ARQUILLIAN_LAUNCH_DEFAULT
        + static String ARQUILLIAN_LAUNCH_DEFAULT_DEPRECATED <<deprecated>>
        - Logger log
        - void validateConfiguration(ArquillianDescriptor desc)
        - String getActivatedConfiguration()
    }

    class DeployableContainer {
        <<interface>>
        + void start() throws LifecycleException
        + void stop() throws LifecycleException
        + void deploy(Archive archive) throws DeploymentException
        + void undeploy(Archive archive) throws DeploymentException
        + void deploy(Descriptor descriptor) throws DeploymentException <<deprecated>>
        + void undeploy(Descriptor descriptor) throws DeploymentException <<deprecated>>
    }

    class JMXTestRunnerMBean {
        <<interface>>
        + byte[] runTestMethod(String className, String methodName) <<deprecated>>
        + byte[] runTestMethod(String className, String methodName, Map protocolProps)
    }

    class JMXTestRunner {
        + void registerMBean(MBeanServer mbeanServer) throws JMException
        + void unregisterMBean(MBeanServer mbeanServer) throws JMException
        + byte[] runTestMethod(String className, String methodName)
        + byte[] runTestMethod(String className, String methodName, Map protocolProps)
        - TestResult runTestMethodInternal(String className, String methodName, Map protocolProps)
    }

    class JUnitJupiterTestClassLifecycleManager {
        <<suppress_deprecation>>
        - static String MANAGER_KEY
        - TestRunnerAdaptor adaptor
        + void close()
    }

    class MethodParameters {
        <<suppress_deprecation>>
        - Map~Integer, Object~ parameters
        + void close()
    }

    class ExtensionContextStoreCloseableResource {
        <<interface>>
    }

    class ExtensionContext
    class Store

    ProtocolMetaData --> JMXContext : provides
    AbstractJMXProtocol --> ProtocolMetaData : uses
    AbstractJMXProtocol --> JMXContext : uses

    JMXTestRunnerMBean <|.. JMXTestRunner

    DeployableContainer <|.. SomeConcreteDeployableContainer

    ExtensionContextStoreCloseableResource <|.. JUnitJupiterTestClassLifecycleManager
    ExtensionContextStoreCloseableResource <|.. MethodParameters

    ExtensionContext ..> ExtensionContextStoreCloseableResource : nested type
    ExtensionContext ..> Store : nested type

    ContainerRegistryCreator ..> ArquillianDescriptor : validates
    ContainerRegistryCreator ..> SecurityActions : uses
Loading

File-Level Changes

Change Details Files
Clarify and harden deprecation of TestResult constructors and mutators, and guard new factory methods against removal warnings.
  • Add detailed @deprecated Javadoc with replacement guidance to legacy TestResult constructors and setDescription, marking them forRemoval=true with appropriate since versions.
  • Annotate factory and utility methods (passed/failed/skipped/flatten) with @SuppressWarnings("removal") to keep using the deprecated constructors internally without warnings.
  • Remove deprecation from setStatus while keeping its fluent behavior unchanged.
test/spi/src/main/java/org/jboss/arquillian/test/spi/TestResult.java
Clarify container and protocol API deprecations and adapt to updated metadata/context APIs.
  • Document and hard‑deprecate ProtocolMetaData#getContext(Class) in favor of getContexts(Class), including forRemoval and since metadata.
  • Update AbstractJMXProtocol to use ProtocolMetaData#getContexts(Class) and select the first JMXContext instead of getContext(Class).
  • Document and hard‑deprecate the ARQUILLIAN_LAUNCH_DEFAULT_DEPRECATED constant and suppress removal warnings in getActivatedConfiguration().
  • Document and mark forRemoval JMXTestRunnerMBean#runTestMethod(String,String) and delegate through JMXTestRunner with @SuppressWarnings("removal").
  • Document and mark forRemoval TestDeployment constructor overload that lacks DeploymentDescription.
container/spi/src/main/java/org/jboss/arquillian/container/spi/client/protocol/metadata/ProtocolMetaData.java
protocols/jmx/src/main/java/org/jboss/arquillian/protocol/jmx/AbstractJMXProtocol.java
container/impl-base/src/main/java/org/jboss/arquillian/container/impl/client/container/ContainerRegistryCreator.java
protocols/jmx/src/main/java/org/jboss/arquillian/protocol/jmx/JMXTestRunnerMBean.java
protocols/jmx/src/main/java/org/jboss/arquillian/protocol/jmx/JMXTestRunner.java
container/test-spi/src/main/java/org/jboss/arquillian/container/test/spi/TestDeployment.java
Align suppression annotations with Java 11+ deprecation semantics (using "removal" instead of "deprecation").
  • Update @SuppressWarnings annotations in container deployment controller and tests from "deprecation" to "removal" for deprecated deploy/undeploy methods.
  • Adjust JUnit Jupiter lifecycle manager and parameter store to suppress new deprecation of ExtensionContext.Store.CloseableResource instead of relying on default behavior.
container/impl-base/src/test/java/org/jboss/arquillian/container/impl/client/container/ContainerDeployControllerTestCase.java
container/impl-base/src/main/java/org/jboss/arquillian/container/impl/client/container/ContainerDeployController.java
junit5/core/src/main/java/org/jboss/arquillian/junit5/JUnitJupiterTestClassLifecycleManager.java
junit5/core/src/main/java/org/jboss/arquillian/junit5/MethodParameters.java
Replace uses of deprecated Java and library APIs with non‑deprecated, Java 11‑friendly alternatives.
  • Replace new Integer(...) constructors with Integer.valueOf(...) in deployment ordering and JUnit state tracking.
  • Switch reflective instantiation from Class#newInstance() to getDeclaredConstructor().newInstance() in several test utilities and protocol configuration creation.
  • Use File#toURI().toURL() instead of deprecated File#toURL() when building the URLClassLoader classpath.
container/spi/src/main/java/org/jboss/arquillian/container/spi/client/deployment/DeploymentScenario.java
container/test-impl-base/src/main/java/org/jboss/arquillian/container/test/impl/client/deployment/AbstractDeploymentScenarioGenerator.java
junit/core/src/main/java/org/jboss/arquillian/junit/State.java
container/test-impl-base/src/test/java/org/jboss/arquillian/container/test/impl/enricher/resource/OperatesOnDeploymentAwareProviderBase.java
container/test-impl-base/src/main/java/org/jboss/arquillian/container/test/impl/domain/ProtocolDefinition.java
test/spi/src/test/java/org/jboss/arquillian/test/spi/ExceptionProxyTestCase.java
Mark selected SPI methods as deprecated for removal with explicit since metadata while preserving behavior.
  • Add forRemoval=true and since attributes to DeployableContainer#deploy(Descriptor) and #undeploy(Descriptor) default methods, keeping their no‑op implementations.
  • Tighten various deprecation Javadocs across the codebase to point to the preferred Archive‑based or factory‑method replacements.
container/spi/src/main/java/org/jboss/arquillian/container/spi/client/container/DeployableContainer.java

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In TestResult, the setStatus(Status) method had its @deprecated annotation removed while other deprecated members were made more explicit; if this was not an intentional undeprecation, consider restoring @deprecated(forRemoval = true, since = ...) and a replacement hint, or otherwise updating its Javadoc to reflect its intended lifecycle.
  • For methods now annotated with @SuppressWarnings("removal"), consider limiting the suppression to the minimal scope (e.g., a local variable or a helper method) where feasible to avoid masking future accidental uses of other removal-deprecated APIs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In TestResult, the setStatus(Status) method had its @Deprecated annotation removed while other deprecated members were made more explicit; if this was not an intentional undeprecation, consider restoring @Deprecated(forRemoval = true, since = ...) and a replacement hint, or otherwise updating its Javadoc to reflect its intended lifecycle.
- For methods now annotated with @SuppressWarnings("removal"), consider limiting the suppression to the minimal scope (e.g., a local variable or a helper method) where feasible to avoid masking future accidental uses of other removal-deprecated APIs.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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