Discussion:
Strange behavior on different JVM
Максим Ларин
2018-03-22 12:58:44 UTC
Permalink
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
<https://github.com/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?
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/503503d1-6daf-4865-a4e0-6d90547033d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...