Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-3950

The build check that only component roles are injected ignores fields annotated with jakarta.inject.Inject

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      The Spoon build check InjectAnnotationProcessor of xwiki-commons-tool-spoon verifies that @Inject is only used on fields and only with component roles, which catches the injection of a component implementation class instead of its role. It only looks at javax.inject.Inject, so since XCOMMONS-2777 added support for the jakarta.inject annotations, fields annotated with jakarta.inject.Inject, which new code is supposed to use, aren't checked at all.

      STEPS TO REPRODUCE:

      • In a component of a module that runs the Spoon checks, inject a component implementation class (not its role) with @jakarta.inject.Inject.
      • Build the module.

      EXPECTED RESULTS: the build fails with "You must inject a component role", as it does with @javax.inject.Inject.

      ACTUAL RESULTS: the build passes.

      Attachments

        Issue Links

          Activity

            People

              MichaelHamann Michael Hamann
              MichaelHamann Michael Hamann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: