fs is a lightweight, high-performance, zero-dependency tool lib for java. It provides:
- Annotations that can be used for code analysis;
- Common utilities and interfaces for bytes, chars, coding, date, enum, exception, logging, math, number, process, random, resource, string, system, thread; reflect, etc.;
- Extensions for functions, values, and options;
- I/O kits and interfaces;
- More light and fast cache interfaces and implementations;
- Kits for collections, maps, arrays, etc.;
- Kits for codec;
- Concurrent supports;
- Network kits and interfaces for http, tcp, udp, etc.;
- Object parsing and conversion;
- Dynamic invocation, supporting reflection, method-handle and asm;
- Dynamic proxy and aspect, supporting JDK dynamic proxy and asm;
- Third-party supporting: asm, protobuf;
fs provides adaptive implementation loading that automatically selects the optimal class version based on the runtime JDK environment (from JDK8 to JDK17). Its main code is based on JDK8, but some interfaces have multiple implementation classes of different jdk versions.
For example, the implementation class of space.sunqian.common.net.http.HttpCaller has two versions: JDK8 and JDK11. The former is based on java.net.HttpURLConnection, and the latter is based on java.net.http.HttpClient.
This ensures:
- Backward Compatibility: Seamlessly runs on older JDK versions (
JDK8+); - Forward Optimization: Leverages newer JDK features when available (up to
JDK17); - Automatic Detection: No manual configuration required -- the library automatically loads the appropriate implementation at runtime;
fs has higher performance than other common libraries in many places, Here are some examples:
Simple Cache (
space.sunqian.common.cache.SimpleCache): SimpleCache only considers common cache functions, so it has higher performance in common functions. Here is the benchmark: CacheBenchmarkCopyProperties (
Fs.copyProperties / space.sunqian.common.object.convert.DataMapper): DataMapper has better performance and more comprehensive support. Here is the benchmark: CopyPropertiesBenchmarkTCP Server (
space.sunqian.common.net.tcp.TcpServer): Rare interface server implementation with slightly better performance than netty. Here is the benchmark: TcpServerBenchmark
Here is the full benchmark result: results.json.
And here is the benchmark result chart: JMH Visualizer.
fs has no strong dependency on any other libraries (except for JDK and its own modules, and fs-all aggregates the classes of all modules without module dependencies). It implements some of the classes under the javax package, such as javax.annotation.Nonnull, and based on this, implements its own null-related annotations: space.sunqian.annotatations.Nonnull and space.sunqian.annotatations.Nullable.
Some functions of fs are based on ASM and protobuf, such as bytecode proxy, aspect, and object conversion about protobuf. But only when needed, ASM and protobuf are tried to be loaded from the current environment. If these features are not used, there is no need to add these dependencies in the current environment.
The test passing rate and jacoco coverage for this library are both 100%:
This library uses gradle as the build tool:
# clone and build git clone -b master https://github.com/fredsuvn/fs.git cd fs && gradle clean build- JavaDoc
- Manuals:
- Develop Manual: dev-manual.adoc
- https://github.com/fredsuvn/fs
- QQ group: 566185308