Force enabling of assertions

It's sometimes useful to require assertions to be always enabled for a particular class at runtime.

Example

If NuclearReactor is loaded into an environment which has disabled assertions, then its static initializer will throw a RuntimeException.

Two example runs of NuclearReactor give :
>java -cp . -enableassertions NuclearReactor
Proceeding normally...
>java -cp . NuclearReactor
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Asserts must be enabled for NuclearReactor.
        at NuclearReactor.<clinit>(NuclearReactor.java:22)

import java.util.Objects;

public final class NuclearReactor {

  public static void main(String... arguments){
    NuclearReactor reactor = new NuclearReactor("Fermi");
    System.out.println("Proceeding normally...");
  }

  /**
  * Prevent this class from running with assertions disabled.
  *
  * If assertions are disabled, then a RuntimeException will be
  * thrown upon class loading.
  */
  static {
    boolean hasAssertEnabled = false;
    assert hasAssertEnabled = true; // rare - an intentional side effect!
    if(!hasAssertEnabled){
      throw new RuntimeException("Asserts must be enabled for NuclearReactor.");
    }
  }

  /**
  * @param name is non-null.
  */
  public NuclearReactor(String name){
    //do NOT use assert to verify parameters passed to
    //non-private methods
    this.name = Objects.requireNonNull(name);
  }

  public String getName(){
    return name;
  }
  
  //..elided

  // PRIVATE
  private final String name;
}