Interface FocusListener

All Known Implementing Classes:
ThresholdFocusListener

public interface FocusListener
Public listener for responding to focus events.

A focus event happens when a certain concrete type is successfully type checked against an interface that it was not checked against immediately before:

 Impl impl = new Impl();
 impl instanceof A // focus event
 impl instanceof A // no focus event
 impl instanceof A // no focus event
 impl instanceof B // focus event
 impl instanceof B // no focus event
 impl instanceof A // focus event
 
Each focus event may invalidate a cache field on the concrete class which can be especially expensive on machines with many cores (JDK-8180450). Thus, such focus events should be kept off the hot path when running on JDK versions that still have this bug.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onFocus(Class<?> concreteType, Class<?> interfaceType)
    Called on every focus event, potentially concurrently.
    static void
    setFocusListener(@Nullable FocusListener focusListener)
    Set the global focus listener, or null to disable listening for focus events.
  • Method Details

    • setFocusListener

      static void setFocusListener(@Nullable @Nullable FocusListener focusListener)
      Set the global focus listener, or null to disable listening for focus events.
      Parameters:
      focusListener - The focus listener
    • onFocus

      void onFocus(Class<?> concreteType, Class<?> interfaceType)
      Called on every focus event, potentially concurrently.
      Parameters:
      concreteType - The concrete type that was checked
      interfaceType - The interface type that the concrete type was type checked against