--- old/src/share/vm/c1/c1_GraphBuilder.cpp 2016-05-18 10:10:01.390320699 +0200 +++ new/src/share/vm/c1/c1_GraphBuilder.cpp 2016-05-18 10:10:01.158320692 +0200 @@ -1654,6 +1654,14 @@ break; } case Bytecodes::_putstatic: { + // Check if modification of a static final field is attempted outside of + // the class/interface initializer method. + if (field->is_constant() && + strcmp(method()->name()->as_quoted_ascii(), "") != 0) { + bailout("The current method sets a static final field but " + "it is not the class or interface initializer method ."); + return; + } Value val = pop(type); if (state_before == NULL) { state_before = copy_state_for_exception(); @@ -1705,6 +1713,14 @@ break; } case Bytecodes::_putfield: { + // Check if modification of a static final field is attempted outside of + // the instance initializer method. + if (field->is_final() && + strcmp(method()->name()->as_quoted_ascii(), "") != 0) { + bailout("The current method sets a final field but " + "it is not the instance initializer method ."); + return; + } Value val = pop(type); obj = apop(); if (state_before == NULL) {