--- old/src/share/vm/opto/parse3.cpp 2016-05-18 10:10:01.426320700 +0200 +++ new/src/share/vm/opto/parse3.cpp 2016-05-18 10:10:01.134320691 +0200 @@ -300,6 +300,24 @@ 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(), "") != 0) { + C->record_failure("The current method sets a static final field but " + "it is not the class or interface initializer method ."); + 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(), "") != 0) { + C->record_failure("The current method sets a final field but " + "it is not the instance initializer method ."); + return; + } + // If the field is final, the rules of Java say we are in or . // 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