{"push_id":1238986285,"size":1,"distinct_size":1,"ref":"refs/heads/topic/SD-194","head":"e2c421d68352c4607e013a27096105b1a685c036","before":"eef487d7387364236359ac4dd5de5a2970ff8b9a","commits":[{"sha":"e2c421d68352c4607e013a27096105b1a685c036","author":{"name":"Jason Zaugg","email":"ed7c853e8cee0d3b3580a0be792529cf101f03e4@gmail.com"},"message":"SD-194 Tweak module initialization to comply with JVM spec\n\nDmitry learned that we've been relying on a bug in the\nverifier that will be fixed in JDK 9 under the new\nclassfile format.\n\nAssignment to a static final must occur lexically\nwithin the <clinit>. We were performing this assignment\nfrom the constructor of the module class.\n\nI'd like to move the assignment to <clinit> but that would\nchange behaviour of \"benign\" cyclic references between modules.\n\nExample:\n\n```\npackage p1; class CC { def foo = O.bar}; object O {new CC().foo; def bar = println(1)};\n\n// Exiting paste mode, now interpreting.\n\nscala> p1.O\n1\n```\n\nWe currently assign the MODULE$ field after the super class constructors are finished,\nbut before the rest of the module constructor is called.\n\n```\n  private p1.O$();\n    Code:\n       0: aload_0\n       1: invokespecial #30                 // Method java/lang/Object.\"<init>\":()V\n       4: aload_0\n       5: putstatic     #32                 // Field MODULE$:Lp1/O$;\n       8: new           #34                 // class p1/CC\n      11: dup\n      12: invokespecial #35                 // Method p1/CC.\"<init>\":()V\n      15: invokevirtual #38                 // Method p1/CC.foo:()V\n      18: return\n```\n\nThis commit removes the ACC_FINAL bit from the field. It actually wasn't\nbehaving as final at all, precisely the issue that the stricter verifier\nnow alerts us to.\n\n```\nscala> :paste -raw\n// Entering paste mode (ctrl-D to finish)\n\npackage p1; object O\n\n// Exiting paste mode, now interpreting.\n\nscala> val O1 = p1.O\nO1: p1.O.type = p1.O$@ee7d9f1\n\nscala> scala.reflect.ensureAccessible(p1.O.getClass.getDeclaredConstructor()).newInstance()\nres0: p1.O.type = p1.O$@64cee07\n\nscala> O1 eq p1.O\nres1: Boolean = false\n```\n\nFixes scala/scala-dev#SD-194","distinct":true,"url":"https://api.github.com/repos/retronym/scala/commits/e2c421d68352c4607e013a27096105b1a685c036"}]}
{"actor":{"display_login":"retronym"}}