On Monday, August 5, 2013 10:19:05 AM UTC-4, Christian Gruber wrote:

> We wouldn't be building people's object graph in the IDE, as the 
> configure() method means that in order to fully extract the object 
> graph, we would need to do flow analysis on the code


I noticed that Guice has a design-time phase, and figured sooner or later 
somebody would use it and discover all the reasons running arbitrary code 
inside an IDE's VM is a bad idea (the NetBeans team went there and got the 
t-shirt while I was on it) :-)

Since most Guice modules *do* add up to declarative statements that just 
happen to be in Java, it's possible to do some limited flow analysis based 
on it, which is enough to figure out at least some things - just ignoring 
statements that are likely to be non-trivial to analyze, or which are 
obviously stateful.  So, you can probably at least discern what types 
definitely are bound with a high degree of confidence, but not which ones 
aren't.

I think if you want to do better static analysis, sooner or later, you're 
going to need a standard for declaring and binding configuration stuff, 
similar to what the giulius-settings stuff does here 
- https://github.com/timboudreau/giulius - that is, if a tool can infer the 
values of bound strings and primitives, you gain the ability to make more 
assertions about the behavior of the code at runtime.
 

> - specifically 
> run-time code not available to us in the annotation processing APIs.   
>

Yeah.  Basically, you can do limited flow analysis and track variable 
assignments, and figure out some subset what the configure() method of a 
module does.

I *could* actually imagine a tool that loaded Modules into a stubbed out 
version of Guice that just printed out binding information, and doing it 
with a SecurityManager that blocks file writes and network i/o - do that in 
a separate process and parse the output.  Probably overkill, and would fail 
sometimes, but it would allow richer information than static analysis will 
ever get - and if you do the SecurityManager stuff right, you can do it 
without wreaking havoc on the user's system.  Might not be worth it - the 
point of diminishing returns comes up pretty fast on this sort of thing. 
 But fun to think about :-)

-Tim

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to