JBR API is an interface for JBR-specific functionality. It provides a standalone jar with a bunch of API classes and interfaces, allowing client code to be compiled using any JDK, while enjoying JBR-specific features at runtime without worrying about compatibility and runtime errors.
JBR API automatically translates calls to itself into JBR. When needed functionality is unavailable (e.g. when running on other JRE, or incompatible JBR version), this is reported in a safe manner and no linkage errors occur.
Any feature exposed via JBR API begins with a service, which is a basic
unit of JBR API. Each service has two related methods in JBR
class:
JBR.get<NAME>()
- returns service instance if it's supported, or null.JBR.is<NAME>Supported()
- convenience method, equivalent ofJBR.get<NAME>() != null
.
if (JBR.isSomeServiceSupported()) {
JBR.getSomeService().doSomething();
}
// or
SomeService service = JBR.getSomeService();
if (service != null) {
service.doSomething();
}
Note: more details with a list of available services can be found in the javadoc.
JBR API releases follow semantic versioning.
API and implementation versions can be retrieved from JBR
class too:
JBR.getApiVersion()
- version of thejbr-api.jar
currently used.JBR.getImplVersion()
- version of JBR API implemented by the current runtime.
Note: although JBR API version does reflect compatibility of API changes, it is not used for any kind of compatibility checks, including determining service availability. That means that in practice some services will continue to work across multiple major releases.
However, just for the completeness*, when impl.major == api.major && impl.minor >= api.minor, all services currently present are guaranteed to be supported.
*Versions should not be used for any purpose other than logging.