google / google/guice

Strange behavior on different JVM

Open
#1,167 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

Hello everyone!

I have got a problem with using Google Guava in test project. I have configured a module with binding singletone implementation to an interface with wrong module configuration. Something like below described:
>public interface Helper {
> void a();
>}

and implementation:
>public class HelperImpl implements Helper{
> public void a() { ...}
>private HelperImpl () {}
>private static Helper instance = new HelperImpl();
>
> public HelperImpl getInstance(){
> return instance;
> }
>}

and Module:
> bind(Helper.class).to(HelperImpl.class);

**Expected behavior:** Could not find a suitable constructor in Helper. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.

**Actual behavior:** Application started on local JVM is instantiated without error(_I cant understand why there is no error?_). Application started on remote JVM is failed with expected error message(_correct behavior_)

Are there ideas why it is so unpredictable? May be local JVM has another options?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.