Strange behavior on different JVM

75 views
Skip to first unread message

Максим Ларин

unread,
Mar 22, 2018, 8:58:44 AM3/22/18
to google-guice

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?

Reply all
Reply to author
Forward
0 new messages