Skip to Content
Java 9 模块化开发:核心原则与实践
book

Java 9 模块化开发:核心原则与实践

by Sander Mak, Paul Bakker
June 2018
Beginner to intermediate
251 pages
5h 47m
Chinese
China Machine Press
Content preview from Java 9 模块化开发:核心原则与实践
模块和模块化
JDK
31
版本
前面已经讨论了模块的解析过程,却没有提及版本问题。这看上去可能很奇怪,因
为我们习惯于指定具有依赖关系的版本,如 Maven POM。将
版本选择
version
selection
)放置在 Java 模块系统的范围之外是一个经过深思熟虑的设计决策。在模
块解析过程中版本不起任何作用,5.7 节将会深入讨论这一决策。
模块解析过程以及额外的检查确保了应用程序在一个可靠的环境中运行,降低了运行时
失败的可能性。在第 3 章,将会学习如何在编译和运行自己的模块时构建一个模块路径。
2.8 在不使用模块的情况下使用模块化 JDK
到目前为止,已经学习了模块系统所引入的许多新概念。此时,你可能想知道模块系统
如何影响现有的代码,很显然,这些代码并没有实现模块化。难道真的需要将代码转换
为模块才能开始使用 Java 9 吗?幸好不是这样。Java 9 可以像以前的 Java 版本一样使用,
而不必将代码移动到模块中。模块系统完全适用于现有的应用程序代码,类路径仍然可
以使用。
JDK 本身由模块组成。这两个世界是如何调解的呢?接下来看一下示例 2-5 所示的代
码片段。
示例 2-5
NotInModule.java
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.LogRecord;
public class NotInModule {
public static ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java 資料科學|科學與工程實務方法

Java 資料科學|科學與工程實務方法

Michael Brzustowicz
Java 技术手册(原书第7版)

Java 技术手册(原书第7版)

Benjamin J. Evans, David Flanagan
What's New in Java 11?

What's New in Java 11?

Benjamin Muschko

Publisher Resources

ISBN: 9787111601296