Class SystemUtil

java.lang.Object
org.checkerframework.javacutil.SystemUtil

public class SystemUtil extends Object
This file contains basic utility functions.
  • Field Details

    • jreVersion

      public static final int jreVersion
      The major version number of the Java runtime (JRE), such as 8, 11, or 17.
  • Method Details

    • available

      public static @Nullable Integer available(InputStream is)
      Calls InputStream.available(), but returns null instead of throwing an IOException.
      Parameters:
      is - an input stream
      Returns:
      is.available(), or null if that throws an exception
    • isWhitespaceOnly

      public static @Nullable Boolean isWhitespaceOnly(InputStream is, int readLimit)
      Returns true if the first readLimit bytes of the input stream consist only of whitespace.
      Parameters:
      is - an input stream
      readLimit - how many bytes to look ahead in the input stream
      Returns:
      null if !is.markSupported(); otherwise, true if the first readLimit characters of the input stream consist only of whitespace
    • readCodePoint

      public static int readCodePoint(InputStream is)
      Reads a Unicode code point from an input stream.
      Parameters:
      is - an input stream
      Returns:
      the Unicode code point for the next character in the input stream
    • getJreVersion

      @Deprecated public static int getJreVersion()
      Deprecated.
      use field jreVersion instead
      Returns the major version number from the "java.version" system property, such as 8, 11, or 17.

      This is different from the version passed to the compiler via --release; use getReleaseValue(ProcessingEnvironment) to get that version.

      Two possible formats of the "java.version" system property are considered. Up to Java 8, from a version string like `1.8.whatever`, this method extracts 8. Since Java 9, from a version string like `11.0.1`, this method extracts 11.

      Starting in Java 9, there is the int Runtime.version().feature(), but that does not exist on JDK 8.

      Returns:
      the major version of the Java runtime
    • getReleaseValue

      public static @Nullable String getReleaseValue(ProcessingEnvironment env)
      Returns the release value passed to the compiler or null if release was not passed.
      Parameters:
      env - the ProcessingEnvironment
      Returns:
      the release value or null if none was passed
    • getToolsJar

      public static @Nullable String getToolsJar()
      Returns the pathname to the tools.jar file, or null if it does not exist. Returns null on Java 9 and later.
      Returns:
      the pathname to the tools.jar file, or null