Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
public class NonFinal {
  public NonFinal() {
    // invoke java.lang.Object.getClass to get class instance
    Class c = getClass();
    // confirm class type
    if (c != NonFinal.class) {
      // check the permission needed to subclass NonFinal
      securityManagerCheck(); // throws a security exception if not allowed
    }
  // ...   
  }
}

It is critical to compare the class types and not the class names (OBJ34-J. Compare classes and not class names).

...