![KryoNet](https://raw.github.com/wiki/EsotericSoftware/kryo/images/logo.jpg)
[![Build Status](https://jenkins.inoio.de/buildStatus/icon?job=kryo)](https://jenkins.inoio.de/job/kryo/)
Kryo is a fast and efficient object graph serialization framework for Java. The goals of the project are speed, efficiency, and an easy to use API. The project is useful any time objects need to be persisted, whether to a file, database, or over the network.
Kryo can also perform automatic deep and shallow copying/cloning. This is direct copying from object to object, not object->bytes->object.
This documentation is for v2+ of Kryo. See [V1Documentation](https://github.com/EsotericSoftware/kryo/wiki/Documentation-for-Kryo-version-1.x) for v1.x.
If you are planning to use Kryo for network communication, the [KryoNet](https://github.com/EsotericSoftware/kryonet) project may prove useful.
## Contents
- [New in release 3.0.0](#new-in-release-300)
- [Installation](#installation)
- [Integration with Maven](#integration-with-maven)
- [Using Kryo without Maven](#using-kryo-without-maven)
- [Quickstart](#quickstart)
- [IO](#io)
- [Unsafe-based IO](#unsafe-based-io)
- [Serializers](#serializers)
- [Registration](#registration)
- [Default serializers](#default-serializers)
- [FieldSerializer](#fieldserializer)
- [KryoSerializable](#kryoserializable)
- [Class fields annotations](#class-fields-annotations)
- [Java Serialization](#using-standard-java-serialization)
- [Reading and writing](#reading-and-writing)
- [References](#references)
- [Object creation](#object-creation)
- [Copying/cloning](#copyingcloning)
- [Context](#context)
- [Compression and encryption](#compression-and-encryption)
- [Chunked encoding](#chunked-encoding)
- [Compatibility](#compatibility)
- [Interoperability](#interoperability)
- [Stack size](#stack-size)
- [Threading](#threading)
- [Pooling Kryo instances](#pooling-kryo-instances)
- [Logging](#logging)
- [Scala](#scala)
- [Objective-C](#objective-c)
- [Benchmarks](#benchmarks)
- [Projects using Kryo](#projects-using-kryo)
- [Contact / Mailing list](#contact--mailing-list)
## New in release 3.0.0
The 3.0.0 release fixes many reported issues and improves stability and performance. The maven groupId is changed from `com.esotericsoftware.kryo` to `com.esotericsoftware`. The Unsafe-based IO serialization format was changed and is incompatible with previous versions (therefore the new major version), the standard serialization format is still compatible.
See [ChangeLog](https://github.com/EsotericSoftware/kryo/blob/master/CHANGES.md) for more details about this release.
## Installation
Kryo JARs are available on the [releases page](https://github.com/EsotericSoftware/kryo/releases) and at [Maven Central](http://search.maven.org/#browse|1975274176). Latest snapshots of Kryo including snapshot builds of master are in the [Sonatype Repository](https://oss.sonatype.org/content/repositories/snapshots/com/esotericsoftware/kryo/kryo).
### Integration with Maven
To use the official release of Kryo, please use the following snippet in your pom.xml
```xml
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>3.0.1</version>
</dependency>
```
If you experience issues because you already have a different version of asm in your classpath, you can use the kryo-shaded jar which has its version of asm included, relocated in a different package:
```xml
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo-shaded</artifactId>
<version>3.0.1</version>
</dependency>
```
If you want to test the latest snapshot of Kryo, please use the following snippet in your pom.xml
```xml
<repository>
<id>sonatype-snapshots</id>
<name>sonatype snapshots repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>3.0.1-SNAPSHOT</version>
</dependency>
```
### Using Kryo without Maven
If you use Kryo without Maven, be aware that Kryo jar file has a couple of external dependencies, whose JARs you need to add to your classpath as well. These dependencies are [MinLog logging library](https://github.com/EsotericSoftware/minlog/) and [Objenesis library](https://code.google.com/p/objenesis/).
## Quickstart
Jumping ahead to show how the library is used:
```java
Kryo kryo = new Kryo();
// ...
Output output = new Output(new FileOutputStream("file.bin"));
SomeClass someObject = ...
kryo.writeObject(output, someObject);
output.close();
// ...
Input input = new Input(new FileInputStream("file.bin"));
SomeClass someObject = kryo.readObject(input, SomeClass.class);
input.close();
```
The Kryo class orchestrates serialization. The Output and Input classes handle buffering bytes and optionally flushing to a stream.
The rest of this document details how this works and advanced usage of the library.
## IO
The Output class is an OutputStream that writes data to a byte array buffer. This buffer can be obtained and used directly, if a byte array is desired. If the Output is given an OutputStream, it will flush the bytes to the stream when the buffer becomes full. Output has many methods for efficiently writing primitives and strings to bytes. It provides functionality similar to DataOutputStream, BufferedOutputStream, FilterOutputStream, and ByteArrayOutputStream.
Because Output buffers when writing to an OutputStream, be sure to call `flush()` or `close()` after writing is complete so the buffered bytes are written to the underlying stream.
The Input class is an InputStream that reads data from a byte array buffer. This buffer can be set directly, if reading from a byte array is desired. If the Input is given an InputStream, it will fill the buffer from the stream when the buffer is exhausted. Input has many methods for efficiently reading primitives and strings from bytes. It provides functionality similar to DataInputStream, BufferedInputStream, FilterInputStream, and ByteArrayInputStream.
To read from a source or write to a target other than a byte array, simply provide the appropriate InputStream or OutputStream.
## Unsafe-based IO
Kryo provides additional IO classes, which are based on the functionalities exposed by the sun.misc.Unsafe class. These classes are UnsafeInput, UnsafeOutput. They are derived from Kryo's Input and Output classes and therefore can be used as a drop-in replacement on those platforms, which properly support sun.misc.Unsafe.
For the case you need to serialize to or deserialize from direct-memory ByteBuffers or even off-heap memory, there are two dedicated classes UnsafeMemoryInput and UnsafeMemoryOutput whose instances can be used for this purpose instead of the usual Input and Output classes.
Using Unsafe-based IO may result in a quite significant performance boost (sometimes up-to an order of magnitude), depending on your application. In particular, it helps a lot when serializing large primitive arrays as part of your object graphs.
### ** DISCLAIMER ABOUT USING UNSAFE-BASED IO **
*Unsafe-based IO is not 100% compatible with Kryo's Input and Output streams when it comes to the binary format of serialized data.*
This means that data written by Unsafe-based output streams can be read only by Unsafe-based input streams, but not by usual Input streams. The same applies on the opposite direction: data written by usual Output streams cannot be correctly read by Unsafe-based input streams.
It should be safe to use Unsafe IO streams as long as both serialization and deserialization are using them and are executed on the same processor architecture (more precisely, if the endianness and internal representation of native integer and floating point types is the same).
Unsafe IO was extensively tested on X86 hardwar
没有合适的资源?快使用搜索试试~ 我知道了~
Bazel-0.15.0 - 源码
共2000个文件
java:1506个
sh:165个
md:140个
需积分: 1 0 下载量 98 浏览量
2024-03-05
13:00:07
上传
评论
收藏 85.52MB ZIP 举报
温馨提示
Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码 Bazel-0.15.0 - 源码
资源推荐
资源详情
资源评论
收起资源包目录
Bazel-0.15.0 - 源码 (2000个子文件)
StdRedirect.c 3KB
realpath.c 3KB
dummy.c 1KB
docs_style.css 685B
zip_headers.h 23KB
transient_bytes.h 11KB
input_jar_scan_entries_test.h 9KB
token_stream.h 9KB
runfiles.h 7KB
launcher.h 5KB
output_jar.h 5KB
combiners.h 4KB
java_launcher.h 4KB
launcher_util.h 4KB
desugar_checking.h 4KB
zlib_interface.h 3KB
input_jar.h 3KB
options.h 3KB
mapped_file.h 2KB
test_util.h 2KB
diag.h 2KB
test_util.h 2KB
data_parser.h 2KB
windows_test_util.h 1KB
test_util.h 1KB
python_launcher.h 1KB
bash_launcher.h 1KB
BlazeFramework.h 883B
Multiplier.h 707B
user-manual.html 170KB
query.html 57KB
build-ref.html 30KB
test-encyclopedia.html 24KB
query-how-to.html 18KB
documentation.html 15KB
cquery.html 12KB
command-line-reference-prefix.html 5KB
footer.html 3KB
header.html 2KB
footer-content.html 2KB
head.html 1KB
search.html 496B
default.html 417B
redirect.html 137B
command-line-reference-suffix.html 23B
BuildEventStreamProtos.java 1.93MB
Build.java 1.65MB
CrosstoolConfig.java 1.48MB
SkylarkDebuggingProtos.java 931KB
AnalysisProtos.java 512KB
ProfileProto.java 371KB
RemoteExecutionLog.java 359KB
InvocationPolicyOuterClass.java 337KB
CommandProtos.java 287KB
Protos.java 261KB
BuildEvent.java 249KB
CommandLineOuterClass.java 218KB
MemoizingEvaluatorTest.java 217KB
BundleMergeProtos.java 209KB
AndroidBinaryTest.java 182KB
TestStatus.java 160KB
ExtraActionInfo.java 152KB
ByteStreamProto.java 141KB
DesugarDeps.java 131KB
Deps.java 122KB
AndroidDeployInfoOuterClass.java 109KB
SkylarkRuleImplementationFunctionsTest.java 107KB
Action.java 101KB
ParallelEvaluatorTest.java 100KB
ObjcRuleTestCase.java 98KB
PlMergeProtos.java 96KB
SkylarkDefinedAspectsTest.java 96KB
ActionResult.java 93KB
WorkerProtocol.java 89KB
BuildViewTestCase.java 87KB
HttpRule.java 86KB
AndroidLibraryTest.java 86KB
SkylarkRuleContextTest.java 84KB
OptionsParserTest.java 80KB
Command.java 78KB
ObjcLibraryTest.java 76KB
Protos.java 75KB
BlazeOptionHandlerTest.java 74KB
JavaSkylarkApiTest.java 73KB
Protos.java 73KB
JavaCompilation.java 73KB
BazelFlagsProto.java 73KB
SkylarkEvaluationTest.java 68KB
CcToolchainFeaturesTest.java 68KB
SkylarkIntegrationTest.java 65KB
FileFunctionTest.java 64KB
BatchUpdateBlobsResponse.java 64KB
Platform.java 62KB
CcLibraryConfiguredTargetTest.java 61KB
SkylarkRuleClassFunctionsTest.java 61KB
AppleBinaryTest.java 61KB
JavaCompileInfo.java 60KB
ObjcSkylarkTest.java 60KB
AndroidDataMergerTest.java 59KB
CppCompileInfo.java 57KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
alin、m
- 粉丝: 159
- 资源: 58
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Java的账号管理系统.zip
- python项目6.爬取豆瓣排行榜电影数据(含GUI界面版).zip
- 微信小程序下拉选择组件
- pythonx项目5.爬取5K分辨率超清唯美壁纸.zip
- python项目4.每天不同时间段通过微信发消息提醒女友.zip
- python课程设计3.淘宝已买到的宝贝数据爬虫(已模拟登录).zip
- 时间序列学习笔记-3-A
- C#ASP.NET医药ERP管理系统源码 药品销售管理系统源码数据库 SQL2008源码类型 WebForm
- python课设项目2.天猫商品数据爬虫(已模拟登录).zip
- (源码)基于Arduino和LCD Smartie的计算机信息显示系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功