--- old/src/share/vm/opto/parse3.cpp 2016-05-18 13:03:52.310630137 +0200 +++ new/src/share/vm/opto/parse3.cpp 2016-05-18 13:03:52.094630130 +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() && + !method()->is_static_initializer()) { + 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() && + !method()->is_instance_initializer()) { + 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