没有合适的资源?快使用搜索试试~ 我知道了~
首页JDK 10 核心库官方文档:Java Platform SE 10 Release E91241-01 (2018年)
JDK 10 核心库官方文档:Java Platform SE 10 Release E91241-01 (2018年)
需积分: 5 0 下载量 55 浏览量
更新于2024-06-22
收藏 525KB PDF 举报
本资源是关于Java Platform, Standard Edition (JDK 10) 的核心库文档,编号为E91241-01,发布日期为2018年3月。JDK 10 是Java开发工具包的第十个主要版本,它构建在Java Standard Edition之上,提供了基础的编程框架和技术支持。此文档详细介绍了该版本的核心库,涵盖了Java语言的核心特性、API和工具集。 作为Java开发者的重要参考资料,JDK 10包含了Java语言的类库,如集合框架、I/O流、网络编程、多线程处理以及安全相关模块,这些都是开发Java应用程序的基础。核心库的更新旨在提升性能、优化API设计和增强开发人员体验,例如引入了模块化系统(Modular System)以提高代码组织和管理。 然而,值得注意的是,使用这份文档时必须遵守严格的许可协议。版权归属于Oracle及其关联公司,用户只能按照协议中的条款进行使用,禁止未经许可的复制、修改、分发等行为。此外,文档中的信息可能会随着技术发展和改进而变化,且不承诺无误,如有发现错误,应通过正式渠道向Oracle报告。 对于美国政府用户或代表政府购买和使用的软件,文档还包含了额外的版权通知,强调该软件及相关文档可能受到美国政府使用条款的约束,可能涉及国家安全或特定的保密要求。 JDK 10 Core Libraries文档是Java开发者在开发过程中不可或缺的参考资料,它提供了必要的工具和功能,但同时也强调了知识产权保护和合规性要求,确保所有使用行为都在法律框架内进行。
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/88186478/bga.jpg)
If a class doesn’t match any filter, then it is accepted. If you want to accept only certain
classes, then your filter must reject everything that doesn’t match. To reject all classes
other than those specified, include
!*
as the last pattern in a class filter.
For a complete description of the syntax for the patterns, see the
conf/security/
java.security
file, or see JEP 290.
Pattern-Based Filter Limitations
Pattern-based filters are used for simple acceptance or rejection. These filters have
some limitations. For example:
• Patterns can’t allow different sizes of arrays based on the class.
• Patterns can’t match classes based on the supertype or interfaces of the class.
• Patterns have no state and can’t make choices depending on the earlier classes
deserialized in the stream.
Define a Pattern-Based Filter for One Application
You can define a pattern-based filter as a system property for one application. A
system property supersedes a Security Property value.
To create a filter that only applies to one application, and only to a single invocation of
Java, define the
jdk.serialFilter
system property in the command line.
The following example shows how to limit resource usage for an individual application:
java -
Djdk.serialFilter=maxarray=100000;maxdepth=20;maxrefs=500 com.example.test.Applicatio
n
Define a Pattern-Based Filter for All Applications in a Process
You can define a pattern-based filter as a Security Property, for all applications in a
process. A system property supersedes a Security Property value.
1. Edit the java.security properties file.
• JDK 9 and later: $JAVA_HOME/conf/security/java.security
• JDK 8,7,6: $JAVA_HOME/lib/security/java.security
2. Add the pattern to the
jdk.serialFilter
Security Property.
Define a Class Filter
You can create a pattern-based class filter that is applied globally. For example, the
pattern might be a class name or a package with wildcard.
In the following example, the filter rejects one class from a package (
!
example.somepackage.SomeClass
), and accepts all other classes in the package:
jdk.serialFilter=!example.somepackage.SomeClass;example.somepackage.*;
The previous example filter accepts all other classes, not just those in
example.somepackage.*
. To reject all other classes, add
!*
:
jdk.serialFilter=!example.somepackage.SomeClass;example.somepackage.*;!*
Chapter 2
Creating Pattern-Based Filters
2-4
![](https://csdnimg.cn/release/download_crawler_static/88186478/bgb.jpg)
Define a Resource Limit Filter
A resource filter limits graph complexity and size. You can create filters for the
following parameters to control the resource usage for each application:
• Maximum allowed array size. For example:
maxarray=100000;
• Maximum depth of a graph. For example:
maxdepth=20;
• Maximum references in a graph between objects. For example:
maxrefs=500;
• Maximum number of bytes in a stream. For example:
maxbytes=500000;
Creating Custom Filters
Custom filters are filters you specify in your application’s code. They are set on an
individual stream or on all streams in a process. You can implement a custom filter as
a pattern, a method, a lambda expression, or a class.
Reading a Stream of Serialized Objects
You can set a custom filter on one
ObjectInputStream
, or, to apply the same filter to
every stream, set a process-wide filter. If an
ObjectInputStream
doesn’t have a filter
defined for it, the process-wide filter is called, if there is one.
While the stream is being decoded, the following actions occur:
• For each new object in the stream, the filter is called before the object is
instantiated and deserialized.
• For each class in the stream, the filter is called with the resolved class. It is called
separately for each supertype and interface in the stream.
• The filter can examine each class referenced in the stream, including the class of
objects to be created, supertypes of those classes, and their interfaces.
• For each array in the stream, whether it is an array of primitives, array of strings,
or array of objects, the filter is called with the array class and the array length.
• For each reference to an object already read from the stream, the filter is called so
it can check the depth, number of references, and stream length. The depth starts
at 1 and increases for each nested object and decreases when each nested call
returns.
• The filter is not called for primitives or for java.lang.String instances that are
encoded concretely in the stream.
• The filter returns a status of accept, reject, or undecided.
• Filter actions are logged if logging is enabled.
Unless a filter rejects the object, the object is accepted.
Setting a Custom Filter for an Individual Stream
You can set a filter on an individual ObjectInputStream when the input to the
stream is untrusted and the filter has a limited set of classes or constraints to enforce.
For example, you could ensure that a stream only contains numbers, strings, and
other application-specified types.
Chapter 2
Creating Custom Filters
2-5
![](https://csdnimg.cn/release/download_crawler_static/88186478/bgc.jpg)
A custom filter is set using the setObjectInputFilter method. The custom filter
must be set before objects are read from the stream.
In the following example, the setObjectInputFiltermethod is invoked with the
dateTimeFilter
method. This filter only accepts classes from the java.time package.
The
dateTimeFilter
method is defined in a code sample in Setting a Custom Filter as a
Method.
LocalDateTime readDateTime(InputStream is) throws IOException {
try (ObjectInputStream ois = new ObjectInputStream(is)) {
ois.setObjectInputFilter(FilterClass::dateTimeFilter);
return (LocalDateTime) ois.readObject();
} catch (ClassNotFoundException ex) {
IOException ioe = new StreamCorruptedException("class missing");
ioe.initCause(ex);
throw ioe;
}
}
Setting a Process-Wide Custom Filter
You can set a process-wide filter that applies to every use of ObjectInputStream
unless it is overridden on a specific stream. If you can identify every type and condition
that is needed by the entire application, the filter can allow those and reject the rest.
Typically, process-wide filters are used to reject specific classes or packages, or to
limit array sizes, graph depth, or total graph size.
A process-wide filter is set once using the methods of the
ObjectInputFilter.Config class. The filter can be an instance of a class, a
lambda expression, a method reference, or a pattern.
ObjectInputFilter filter = ...
ObjectInputFilter.Config.setSerialFilter(filter);
In the following example, the process-wide filter is set by using a lambda expression.
ObjectInputFilter.Config.setSerialFilter(info -> info.depth() > 10 ?
Status.REJECTED : Status.UNDECIDED);
In the following example, the process-wide filter is set by using an instance of a class.
ObjectInputFilter.Config.setSerialFilter(FilterClass::dateTimeFilter);
Setting a Custom Filter Using a Pattern
A pattern-based custom filter, which is convenient for simple cases, can be created by
using the ObjectInputFilter.Config.createFilter method. You can create a
pattern-based filter as a system property or Security Property. Implementing a pattern-
based filter as a method or a lambda expression gives you more flexibility.
The filter patterns can accept or reject specific classes, packages, modules, and can
place limits on array sizes, graph depth, total references, and stream size. Patterns
cannot match the supertype or interfaces of the class.
In the following example, the filter allows
example.File
and rejects
example.Directory
classes.
ObjectInputFilter filesOnlyFilter =
ObjectInputFilter.Config.createFilter("example.File;!example.Directory");
This example allows only
example.File
. All other classes are rejected.
Chapter 2
Creating Custom Filters
2-6
剩余58页未读,继续阅读
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/28105908048e4518a28a3457cdef3389_weixin_40191861.jpg!1)
weixin_40191861_zj
- 粉丝: 68
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
会员权益专享
最新资源
- VMP技术解析:Handle块优化与壳模板初始化
- C++ Primer 第四版更新:现代编程风格与标准库
- 计算机系统基础实验:缓冲区溢出攻击(Lab3)
- 中国结算网上业务平台:证券登记操作详解与常见问题
- FPGA驱动的五子棋博弈系统:加速与创新娱乐体验
- 多旋翼飞行器定点位置控制器设计实验
- 基于流量预测与潮汐效应的动态载频优化策略
- SQL练习:查询分析与高级操作
- 海底数据中心散热优化:从MATLAB到动态模拟
- 移动应用作业:MyDiaryBook - Google Material Design 日记APP
- Linux提权技术详解:从内核漏洞到Sudo配置错误
- 93分钟快速入门 LaTeX:从入门到实践
- 5G测试新挑战与罗德与施瓦茨解决方案
- EAS系统性能优化与故障诊断指南
- Java并发编程:JUC核心概念解析与应用
- 数据结构实验报告:基于不同存储结构的线性表和树实现
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)