Package io.micronaut.test.typepollution
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 TypeMethodDescriptionvoid
Called on every focus event, potentially concurrently.static void
setFocusListener
(@Nullable FocusListener focusListener) Set the global focus listener, ornull
to disable listening for focus events.
-
Method Details
-
setFocusListener
Set the global focus listener, ornull
to disable listening for focus events.- Parameters:
focusListener
- The focus listener
-
onFocus
Called on every focus event, potentially concurrently.- Parameters:
concreteType
- The concrete type that was checkedinterfaceType
- The interface type that the concrete type was type checked against
-