This way it could never work, you'll need to remove the final keyword and
compute the constants later.
They're not real constants if you need a provider to compute them at inject
time ;)

PS static and requestStaticInjection should be last resort.


2010/2/17 Willi Schönborn <[email protected]>

> Grary wrote:
>
>> Hi all,
>>
>> I'd like to configure a module in Guice (Gin) such that...
>>
>> public enum WeekSpanFields {
>>        RECURRING_TIMES(TIME_CONSTS.recurringTimes());
>> ...
>>        private WeekSpanFields(String constStr) {
>>                ...
>>        }
>> }
>>
>> where...
>>
>> class Constants {
>>        @Inject static Provider<TimeWrapperConstants> constantsProvider;
>>        static final TimeWrapperConstants TIME_CONSTS =
>> constantsProvider.get();
>> }
>>
>> But I keep getting null pointer exceptions at the get() call in the
>> code snippet immediately above.
>>
>>
> I guess the jvm initialises your class, which means it also initialises
> all fields and because constantsProvider is not yet injected its null.
> Guice can only work after the jvm loaded the class, but its too late by
> then.
>
>  Any thoughts on how to configure this in my module? (I hope it's
>> clear.)
>>
>> Thanks,
>>
>> Grar
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to