Package org.checkerframework.javacutil
Class SystemUtil
java.lang.Object
org.checkerframework.javacutil.SystemUtil
This file contains basic utility functions.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.google.common.base.Splitter
A splitter that splits on colons.static final com.google.common.base.Splitter
A splitter that splits on commas.static final com.google.common.base.Splitter
A splitter that splits on periods.static final int
The major version number of the Java runtime (JRE), such as 8, 11, or 17.static final com.google.common.base.Splitter
A splitter that splits onFile.pathSeparator
. -
Method Summary
Modifier and TypeMethodDescriptionavailable
(InputStream is) CallsInputStream.available()
, but returns null instead of throwing an IOException.static int
Deprecated.getPathsProperty
(String propName) LikeSystem.getProperty
, but splits on the path separator and never returns null.Returns the release value passed to the compiler or null if release was not passed.Returns the pathname to the tools.jar file, or null if it does not exist.isWhitespaceOnly
(InputStream is, int readLimit) Returns true if the firstreadLimit
bytes of the input stream consist only of whitespace.static int
Reads a Unicode code point from an input stream.
-
Field Details
-
dotSplitter
public static final com.google.common.base.Splitter dotSplitterA splitter that splits on periods. The result contains no empty strings. -
commaSplitter
public static final com.google.common.base.Splitter commaSplitterA splitter that splits on commas. The result contains no empty strings. -
colonSplitter
public static final com.google.common.base.Splitter colonSplitterA splitter that splits on colons. The result contains no empty strings. -
pathSeparatorSplitter
public static final com.google.common.base.Splitter pathSeparatorSplitterA splitter that splits onFile.pathSeparator
. The result contains no empty strings. -
jreVersion
public static final int jreVersionThe major version number of the Java runtime (JRE), such as 8, 11, or 17.
-
-
Method Details
-
getPathsProperty
LikeSystem.getProperty
, but splits on the path separator and never returns null.- Parameters:
propName
- a system property name- Returns:
- the paths in the system property; may be an empty array
-
available
CallsInputStream.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
Returns true if the firstreadLimit
bytes of the input stream consist only of whitespace.- Parameters:
is
- an input streamreadLimit
- how many bytes to look ahead in the input stream- Returns:
- null if
!is.markSupported()
; otherwise, true if the firstreadLimit
characters of the input stream consist only of whitespace
-
readCodePoint
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.use fieldjreVersion
insteadReturns 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
; usegetReleaseValue(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
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
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
-
jreVersion
instead