src/share/vm/opto/parse3.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/opto/parse3.cpp	Wed May 18 10:10:01 2016
--- new/src/share/vm/opto/parse3.cpp	Wed May 18 10:10:01 2016

*** 298,307 **** --- 298,325 ---- if (is_field) { set_wrote_fields(true); } + // Check if modification of a static final field is attempted outside of + // the class/interface initializer method. + if (!is_field && field->is_constant() && + strcmp(method()->name()->as_quoted_ascii(), "<clinit>") != 0) { + C->record_failure("The current method sets a static final field but " + "it is not the class or interface initializer method <clinit>."); + return; + } + + // Check if modification of a static final field is attempted outside of + // the instance initializer method. + if (is_field && field->is_final() && + strcmp(method()->name()->as_quoted_ascii(), "<init>") != 0) { + C->record_failure("The current method sets a final field but " + "it is not the instance initializer method <init>."); + return; + } + // If the field is final, the rules of Java say we are in <init> or <clinit>. // Note the presence of writes to final non-static fields, so that we // can insert a memory barrier later on to keep the writes from floating // out of the constructor. // Any method can write a @Stable field; insert memory barriers after those also.

src/share/vm/opto/parse3.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File