- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Internal fields names
Dear all,
I am trying to inject a private field with reflection, in a test suite. I have discovered that the name of the field has changed compared to the one I have declared.
Namely the following:
private var active = false;
@Autowired
private var gigaSpace: GigaSpace = _;
become:
com$gottex$gottware$datafeeds$mocks$MockRealTimeConnector$$gigaSpace
while active stays the same when I inspect the Fields[] collection.
Why does it happen? Should I not rely anymore on fields name for doing reflection in my tests?
Best Regards
Edmondo
I am trying to inject a private field with reflection, in a test suite. I have discovered that the name of the field has changed compared to the one I have declared.
Namely the following:
private var active = false;
@Autowired
private var gigaSpace: GigaSpace = _;
become:
com$gottex$gottware$datafeeds$mocks$MockRealTimeConnector$$gigaSpace
while active stays the same when I inspect the Fields[] collection.
Why does it happen? Should I not rely anymore on fields name for doing reflection in my tests?
Best Regards
Edmondo










Re: Internal fields names
On Tue, Jan 3, 2012 at 2:00 PM, Edmondo Porcu <edmondo [dot] porcu [at] gmail [dot] com> wrote:
I'm pretty sure that field names are an implementation detail and aren't guaranteed in the Scala Spec.
--
Viktor Klang
Akka Tech LeadTypesafe - Enterprise-Grade Scala from the Experts
Twitter: @viktorklang
Re: Internal fields names
Exactly true. If it's a var you can inject with the "foo_$eq" method. See the scala-mojo-support project for a working inject example for plexus.
On Jan 3, 2012 8:08 AM, "√iktor Ҡlang" <viktor [dot] klang [at] gmail [dot] com> wrote: