FYI: Method (setter) injection ordering and Java 7

116 views
Skip to first unread message

Christian Gruber

unread,
Apr 27, 2012, 4:51:59 PM4/27/12
to google...@googlegroups.com
Greetings Guice users,

    Many people are starting to use Java7 in production applications, and some underlying changes in the Java7 VM may change behaviour in Guice, particularly relating to setter/method injection.  While there are no guarantees of method order returned Class's methods in the JVM spec, Java virtual machines, particularly HotSpot, have historically returned Method objects in a deterministic way.  Java7 changes that.


    As of Java 7, because Methods WILL be returned in inconsistent order, this means that @Inject annotated methods will not maintain the same order of injection, even from execution to execution.  Now, naturally, your code is good and right and proper and wasn't relying on this un-specified behaviour in the JVM... but just in case it wasn't, we thought it wise to warn Guice users of this implicit behaviour change when running in a Java7 runtime. 

Christian
Reply all
Reply to author
Forward
0 new messages