Class BambooConstantUtils


  • public class BambooConstantUtils
    extends Object
    A collection of utility methods to prevent inlining of Bamboo constants by the Java compiler.

    Use these methods when defining constants which may be used by external code. Using them guarantees that the Java compiler does not inline the values of the constants in the compiled classes.

    Changing constants not wrapped by such utility methods (and not protected in any other way) may lead to plugin compatibility issues.

    Example:

    
     import static com.atlassian.bamboo.util.BambooConstantUtils.preventInlining;
    
     public class BambooConstants {
         public static final String  BAMBOO_VERSION      = preventInlining("6.0.0");
         public static final int     BAMBOO_BUILD_NUMBER = preventInlining(60000);
         public static final boolean BAMBOO_DEV_MODE     = preventInlining(false);
     }
     
    See Also:
    Quiz, what's wrong with this?
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean preventInlining​(boolean value)
      Prevent inlining of a boolean Bamboo constant by the Java compiler.
      static byte preventInlining​(byte value)
      Prevent inlining of a byte Bamboo constant by the Java compiler.
      static char preventInlining​(char value)
      Prevent inlining of a char Bamboo constant by the Java compiler.
      static double preventInlining​(double value)
      Prevent inlining of a double Bamboo constant by the Java compiler.
      static float preventInlining​(float value)
      Prevent inlining of a float Bamboo constant by the Java compiler.
      static int preventInlining​(int value)
      Prevent inlining of a int Bamboo constant by the Java compiler.
      static long preventInlining​(long value)
      Prevent inlining of a long Bamboo constant by the Java compiler.
      static short preventInlining​(short value)
      Prevent inlining of a short Bamboo constant by the Java compiler.
      static <T> T preventInlining​(T value)
      Prevent inlining of any type Bamboo constant by the Java compiler.
    • Method Detail

      • preventInlining

        public static boolean preventInlining​(boolean value)
        Prevent inlining of a boolean Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils
      • preventInlining

        public static byte preventInlining​(byte value)
        Prevent inlining of a byte Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils
      • preventInlining

        public static short preventInlining​(short value)
        Prevent inlining of a short Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils
      • preventInlining

        public static int preventInlining​(int value)
        Prevent inlining of a int Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils
      • preventInlining

        public static long preventInlining​(long value)
        Prevent inlining of a long Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils
      • preventInlining

        public static float preventInlining​(float value)
        Prevent inlining of a float Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils
      • preventInlining

        public static double preventInlining​(double value)
        Prevent inlining of a double Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils
      • preventInlining

        public static char preventInlining​(char value)
        Prevent inlining of a char Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils
      • preventInlining

        public static <T> T preventInlining​(T value)
        Prevent inlining of any type Bamboo constant by the Java compiler.
        See Also:
        BambooConstantUtils