[9] RFR (S): 8157181: Compilers accept modification of final fields outside initializer methods

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Wed May 18 10:02:53 UTC 2016


> Webrev:
> http://cr.openjdk.java.net/~zmajo/8157181/webrev.00/

src/share/vm/c1/c1_GraphBuilder.cpp:
+       if (field->is_constant() &&
+           strcmp(method()->name()->as_quoted_ascii(), "<clinit>") != 0) {

+       if (field->is_final() &&
+           strcmp(method()->name()->as_quoted_ascii(), "<init>") != 0) {

Use Method::is_initializer()/is_static_initializer() instead.

Also, instead of bailing out the whole compilation, you can emit an 
access as if the field access isn't linked yet (C1 supports that by 
setting field offset to -1). The JVM should throw an appropriate 
exception when trying to link the field.

> It seems to me that the interpeter is affected by a related problem
> (i.e., the interpreter does not throw an IllegalAccessError if (2) does
> not hold). I'd prefer to file a separate bug for that problem.
I'm confused. How do you observe the difference between -Xint & -Xcomp 
mode then?

Best regards,
Vladimir Ivanov


More information about the hotspot-compiler-dev mailing list