Fields in object is now static in 2.13

Hi.
We use Spring a lot using the @javax.annotation.Resource annotation for injecting stuff. It works well but we see new behaviour using the annotation to inject stuff into object in 2.13:

import javax.annotation.Resource
import org.springframework.beans.factory.annotation.Configurable

@Configurable
object MyObject {
	@Resource
	val myService: MyService = null
}

This works fine in Scala-2.12, but in 2.13 it fails at runtime with:
Caused by: java.lang.IllegalStateException: @Resource annotation is not supported on static fields

Any ideas for a clean solution to this?

Forgot to say; We use AspectJ to weave these non-Spring managed objects, with config like this (aop.xml):

<aspectj>
    <weaver options="-verbose -showWeaveInfo">
        <!--
        Only weave @Configurable stuff
        -->
        <include within="@org.springframework.beans.factory.annotation.Configurable com.visena..*"/>
	</weaver>
</aspectj>

looks like a consequence of https://github.com/scala/scala/pull/7270

In case anyone gooles this, this is a work-around:

@Configurable
object MyObject {
	@(Resource @setter)
	private var myService: MyService = _
}

Anyone else got a better idea?

Ran into the same issue - this is the minimal version that doesn’t work in Scala 2.13:

import com.google.inject.{Guice, Inject, Injector}

class A {}

object O {
  @Inject var a: A = _
}

val injector: Injector = Guice.createInjector()
injector.injectMembers(O)
println(O.a) // prints null

We were able to fix this by changing it to the syntax above: @(Inject @setter) var a: A = _

However, there’s one remaining issue - did anyone figure out how to use the @Named annotation in combination with this? @(Inject @Named("foo") @setter) var a: A = _ or @Named("foo") @(Inject @setter) var a: A = _ don’t work

How about this?

  import com.google.inject.{Guice, Inject, Injector}

  class A {}

  class O {
    @Inject var variable: A = _
    @Inject val value: A = null
  }

  object O extends O

  val injector: Injector = Guice.createInjector()
  injector.injectMembers(O)
  println(O.variable)
  println(O.value)