/* package whatever; // don't place package name! */


import sun.misc.Unsafe;
import java.lang.reflect.Field;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	
	private static final Unsafe theUnsafe; 
	static {
		try {
			Field f = Unsafe.class.getDeclaredField("theUnsafe");
			f.setAccessible(true);
			theUnsafe = (Unsafe) f.get(null);
		} catch (ReflectiveOperationException roe) {
			throw new ExceptionInInitializerError(roe);
		}
	}
	
	public static void setStaticObjectUnsafe(final Field field, Object value) {
        final Object staticFieldBase = theUnsafe.staticFieldBase(field);
        final long staticFieldOffset = theUnsafe.staticFieldOffset(field);
        theUnsafe.putObject(staticFieldBase, staticFieldOffset, value);
    }
    
    // Integer, not int, so javac won't inline it.
    static final Integer VALUE = 10;
    
    static Integer useField() {
        for (int i = 0; i < 1_000_000; i++) {
            if (VALUE != 10) {
                return VALUE;
            }
        }
        return VALUE;
    }
	
	public static void main (String[] args) throws Exception
	{
		useField();
		useField();
		setStaticObjectUnsafe(Ideone.class.getDeclaredField("VALUE"), 100);
		System.out.println(useField());
	}
}