Class LoadedTypeInitializer.ForStaticField

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object accessControlContext
      The access control context to use for loading classes or null if the access controller is not available on the current VM.
      private java.lang.String fieldName
      The name of the field.
      private static long serialVersionUID
      This class's serial version UID.
      private java.lang.Object value
      The value of the field.
    • Constructor Summary

      Constructors 
      Constructor Description
      ForStaticField​(java.lang.String fieldName, java.lang.Object value)
      Creates a new LoadedTypeInitializer for setting a static field.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static <T> T doPrivileged​(java.security.PrivilegedAction<T> action, java.lang.Object context)
      A proxy for java.security.AccessController#doPrivileged that is activated if available.
      private static java.lang.Object getContext()
      A proxy for java.security.AccessController#getContext that is activated if available.
      boolean isAlive()
      Indicates if this initializer is alive and needs to be invoked.
      void onLoad​(java.lang.Class<?> type)
      Callback that is invoked on the creation of an instrumented type.
      private java.lang.Object readResolve()
      Resolves this instance after deserialization to assure the access control context is set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        This class's serial version UID.
        See Also:
        Constant Field Values
      • fieldName

        private final java.lang.String fieldName
        The name of the field.
      • value

        private final java.lang.Object value
        The value of the field.
      • accessControlContext

        @MaybeNull
        @ValueHandling(IGNORE)
        private final transient java.lang.Object accessControlContext
        The access control context to use for loading classes or null if the access controller is not available on the current VM.
    • Constructor Detail

      • ForStaticField

        public ForStaticField​(java.lang.String fieldName,
                              java.lang.Object value)
        Creates a new LoadedTypeInitializer for setting a static field.
        Parameters:
        fieldName - the name of the field.
        value - The value to be set.
    • Method Detail

      • getContext

        @MaybeNull
        @Enhance
        private static java.lang.Object getContext()
        A proxy for java.security.AccessController#getContext that is activated if available.
        Returns:
        The current access control context or null if the current VM does not support it.
      • doPrivileged

        @Enhance
        private static <T> T doPrivileged​(java.security.PrivilegedAction<T> action,
                                          @MaybeNull
                                          java.lang.Object context)
        A proxy for java.security.AccessController#doPrivileged that is activated if available.
        Type Parameters:
        T - The type of the action's resolved value.
        Parameters:
        action - The action to execute from a privileged context.
        context - The access control context or null if the current VM does not support it.
        Returns:
        The action's resolved value.
      • readResolve

        private java.lang.Object readResolve()
        Resolves this instance after deserialization to assure the access control context is set.
        Returns:
        A resolved instance of this instance that includes an appropriate access control context.
      • onLoad

        public void onLoad​(java.lang.Class<?> type)
        Callback that is invoked on the creation of an instrumented type. If the loaded type initializer is alive, this method should be implemented empty instead of throwing an exception.
        Specified by:
        onLoad in interface LoadedTypeInitializer
        Parameters:
        type - The manifestation of the instrumented type.
      • isAlive

        public boolean isAlive()
        Indicates if this initializer is alive and needs to be invoked. This is only meant as a mark. A loaded type initializer that is not alive might still be called and must therefore not throw an exception but rather provide an empty implementation.
        Specified by:
        isAlive in interface LoadedTypeInitializer
        Returns:
        true if this initializer is alive.