Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
 // Determine whether object auth has required/expected class name
if (auth.getClass().getName().equals("com.application.auth.DefaultAuthenticationHandler")) {
  // ...
}

Multiple Comparing fully qualified class names is insufficient because distinct class loaders may load differing classes with identical names may exist with the same name in the JVM; consequently this is not a valid comparisonfully qualified names into a single JVM.

Compliant Solution

This compliant solution compares the class object of class Auth to the class object of the class that the current class loader loads, instead of comparing just the class names.

...