Open GoogleCodeExporter opened 9 years ago
Two pieces of different code behaving differently. :-)
What may be happening behind the scenes is "US" is being inlined and the
compiler knows it can never change. Annotations are effectively static
modifiers, so I'm surprised the first example even compiles. I bet making
'var' static may fix the second one, but even then I'm not entirely sure.
Original comment by sberlin
on 16 Sep 2011 at 10:05
(FWIW, this is a quirk with the annotations subsystem and java and is nothing
specific to Guice.)
Original comment by sberlin
on 16 Sep 2011 at 10:05
Adding static gives the same compilation error.
Do you have any thoughts to make the second scenario work?
Original comment by sony....@gmail.com
on 16 Sep 2011 at 10:18
Probably not gonna work at all -- javac wants to know the value, it's not going
to let you change it at runtime. You can ask on stackoverflow, but I suspect
that'll be the answer.
Original comment by sberlin
on 16 Sep 2011 at 10:42
You can construct the Key<String> at runtime and use the Injector directly, or
call getProvider(key) inside a module.
Original comment by isaac.q....@gmail.com
on 17 Sep 2011 at 2:09
Original issue reported on code.google.com by
sony....@gmail.com
on 16 Sep 2011 at 9:41