当前位置: 首页 > news >正文

开源手机网站模板数字化营销怎么做

开源手机网站模板,数字化营销怎么做,wordpress技术论坛,网页设计报告心得第3章:模块化JDK:JDK模块结构与核心模块 JDK 9 将自身拆分为一系列模块,彻底告别传统的“单一JAR(如 rt.jar)”模式。本章深入解析 JDK 的模块化架构、核心模块功能及开发者如何高效利用这些模块。 3.1 JDK 模块化设计…

第3章:模块化JDK:JDK模块结构与核心模块

JDK 9 将自身拆分为一系列模块,彻底告别传统的“单一JAR(如 rt.jar)”模式。本章深入解析 JDK 的模块化架构、核心模块功能及开发者如何高效利用这些模块。


3.1 JDK 模块化设计概览
设计目标
  1. 模块化拆分:将 JDK 代码库划分为 94 个独立模块(JDK 17 扩展至约 100 个)。
  2. 强封装:隐藏内部 API(如 sun.misc),仅公开标准 API。
  3. 按需加载:允许应用仅依赖所需模块,减少运行时内存占用。
模块分类

JDK 模块分为三类:

  1. 标准模块(Standard Modules):以 java.* 开头的模块(如 java.base),提供核心 API。
  2. JDK 专用模块(JDK-specific Modules):以 jdk.* 开头的模块(如 jdk.unsupported),包含 JDK 实现细节。
  3. 聚合模块(Aggregator Modules):如 java.se,仅用于聚合其他模块,无实际代码。

3.2 核心模块详解
1. java.base(基础核心模块)
  • 功能:包含 Java 最基础的类库,如 ObjectString、集合框架、IO/NIO、安全等。
  • 特性
    • 所有模块隐式依赖 java.base(无需显式声明 requires java.base)。
    • 提供关键包:java.langjava.utiljava.iojava.nio
  • 示例
    // 任何模块自动依赖 java.base
    module com.myapp {// 无需 requires java.baseexports com.myapp.api;
    }
    
2. java.sql(数据库连接模块)
  • 功能:提供 JDBC API(ConnectionStatementResultSet)。
  • 依赖
    module com.myapp {requires java.sql; // 显式声明依赖
    }
    
3. java.net.http(HTTP 客户端模块)
  • 功能:JDK 9 新增的 HTTP/2 客户端(非孵化器版本需 JDK 11+)。
  • 示例
    module com.myapp {requires java.net.http;
    }
    
4. jdk.unsupported(非标准支持模块)
  • 功能:提供对部分内部 API 的临时访问(如 sun.misc.Unsafe),但强烈不建议使用。
  • 警告:此模块可能在未来的 JDK 版本中被移除或调整。

3.3 模块依赖关系与查看方法
1. 查看模块依赖树

使用 java --list-modules 列出所有模块:

java --list-modules
# 输出示例:
java.base@17.0.1
java.sql@17.0.1
jdk.unsupported@17.0.1
2. 查看模块内容

使用 java --describe-module <模块名> 显示模块详细信息:

java --describe-module java.sql
# 输出示例:
java.sql@17.0.1
requires java.base mandated
requires java.logging transitive
requires java.xml transitive
exports java.sql
exports javax.sql
...

3.4 模块化 JDK 的优势
  1. 减少内存占用

    • 传统模式:加载完整的 rt.jar(约 60 MB)。
    • 模块化模式:仅加载必需模块(如 java.base 约 15 MB)。
  2. 增强安全性

    • 内部 API(如 com.sun.*)默认不可访问,避免滥用。
  3. 明确依赖管理

    • 开发者必须显式声明模块依赖,避免隐式类路径问题。

3.5 实战:定制化 JRE 生成

通过 jlink 工具创建仅包含所需模块的最小化 JRE。

场景:构建一个仅依赖 java.basejava.sql 的控制台应用。
jlink --module-path $JAVA_HOME/jmods \--add-modules java.base,java.sql \--output my-custom-jre

生成的 JRE 结构

my-custom-jre/
├── bin/
├── conf/
├── lib/          # 仅包含 java.base 和 java.sql 的模块
└── release

3.6 核心模块依赖示例
示例1:依赖 java.basejava.logging
module com.myapp {requires java.logging; // 显式依赖日志模块
}
示例2:多模块协作
// 模块A:提供工具类
module com.utils {exports com.utils;
}// 模块B:依赖模块A和JDK的XML模块
module com.myapp {requires com.utils;requires java.xml;
}

3.7 常见问题与解决
问题解决方案
模块未找到(如 java.sql确认模块名拼写正确,且模块存在于 $JAVA_HOME/jmods 目录。
访问内部 API 失败使用 --add-exports 开放访问(临时方案),或改用标准 API。
生成的 JRE 缺少必要模块检查 jlink--add-modules 参数是否包含所有依赖模块。

3.8 总结

JDK 9 的模块化架构通过拆分核心功能、强封装和按需加载,显著提升了 Java 应用的灵活性与安全性。开发者应熟悉核心模块(如 java.base)的作用,掌握 jlink 等工具构建轻量化运行时,并遵循显式依赖管理原则,以充分发挥模块化优势。


文章转载自:
http://dinncowonderstruck.ssfq.cn
http://dinncotern.ssfq.cn
http://dinncocaza.ssfq.cn
http://dinncoinferential.ssfq.cn
http://dinncooptophone.ssfq.cn
http://dinncosaccharometer.ssfq.cn
http://dinncowirescape.ssfq.cn
http://dinncoyearly.ssfq.cn
http://dinncoosteophyte.ssfq.cn
http://dinncolikewise.ssfq.cn
http://dinncoagin.ssfq.cn
http://dinncoanthelix.ssfq.cn
http://dinncowhisper.ssfq.cn
http://dinncointervenor.ssfq.cn
http://dinncoseltzogene.ssfq.cn
http://dinncorepand.ssfq.cn
http://dinncosporadical.ssfq.cn
http://dinncobrilliant.ssfq.cn
http://dinncoflimsily.ssfq.cn
http://dinncoexecutor.ssfq.cn
http://dinncoloke.ssfq.cn
http://dinncocutworm.ssfq.cn
http://dinncosmew.ssfq.cn
http://dinncomotorway.ssfq.cn
http://dinncocosmism.ssfq.cn
http://dinncowhitefish.ssfq.cn
http://dinncopibal.ssfq.cn
http://dinncofactorage.ssfq.cn
http://dinncosuperblock.ssfq.cn
http://dinncoarenicolous.ssfq.cn
http://dinncosidestroke.ssfq.cn
http://dinncoinvestigatory.ssfq.cn
http://dinncoampere.ssfq.cn
http://dinncoconsecution.ssfq.cn
http://dinncoradiophony.ssfq.cn
http://dinncocamelback.ssfq.cn
http://dinncomarmap.ssfq.cn
http://dinncocanephorus.ssfq.cn
http://dinncorainily.ssfq.cn
http://dinncovelleity.ssfq.cn
http://dinncopsychoactive.ssfq.cn
http://dinncomucrones.ssfq.cn
http://dinncotritagonist.ssfq.cn
http://dinncoattemperator.ssfq.cn
http://dinncoshirk.ssfq.cn
http://dinncohydrodynamics.ssfq.cn
http://dinncogauze.ssfq.cn
http://dinncokodiak.ssfq.cn
http://dinncoemulgent.ssfq.cn
http://dinncodiagraph.ssfq.cn
http://dinncoberceuse.ssfq.cn
http://dinncopilipino.ssfq.cn
http://dinncoinflectional.ssfq.cn
http://dinncomeditate.ssfq.cn
http://dinncosyllable.ssfq.cn
http://dinncofibrinoid.ssfq.cn
http://dinncochick.ssfq.cn
http://dinncochiefdom.ssfq.cn
http://dinncoblabbermouth.ssfq.cn
http://dinncoskikda.ssfq.cn
http://dinncowastry.ssfq.cn
http://dinncoatergo.ssfq.cn
http://dinncoenslavement.ssfq.cn
http://dinncosubprogram.ssfq.cn
http://dinncorapier.ssfq.cn
http://dinncowvf.ssfq.cn
http://dinncomadbrain.ssfq.cn
http://dinncooffwhite.ssfq.cn
http://dinncohelsinki.ssfq.cn
http://dinncoruminative.ssfq.cn
http://dinncobritish.ssfq.cn
http://dinncowaspy.ssfq.cn
http://dinncoreinvent.ssfq.cn
http://dinncobachelorship.ssfq.cn
http://dinncoequidistance.ssfq.cn
http://dinncoresplendent.ssfq.cn
http://dinncoplainness.ssfq.cn
http://dinncosigmoidoscope.ssfq.cn
http://dinncopatripotestal.ssfq.cn
http://dinncocorticate.ssfq.cn
http://dinncotritiated.ssfq.cn
http://dinncorapture.ssfq.cn
http://dinncoargand.ssfq.cn
http://dinncominorite.ssfq.cn
http://dinncoredirection.ssfq.cn
http://dinncofoolhardy.ssfq.cn
http://dinncokeel.ssfq.cn
http://dinncodoorplate.ssfq.cn
http://dinncogoldarn.ssfq.cn
http://dinncoturbulent.ssfq.cn
http://dinncospasmodic.ssfq.cn
http://dinncosergeanty.ssfq.cn
http://dinncomarathonian.ssfq.cn
http://dinncomlf.ssfq.cn
http://dinncoglauconite.ssfq.cn
http://dinncofurcation.ssfq.cn
http://dinncotitanite.ssfq.cn
http://dinncodeportable.ssfq.cn
http://dinncothe.ssfq.cn
http://dinncopterylography.ssfq.cn
http://www.dinnco.com/news/99968.html

相关文章:

  • 泰安企业网站建设湖南seo排名
  • 什么网站比谷歌还好2022年最火的电商平台
  • 淘宝做网站为什么那么便宜人际网络营销2900
  • 企业微信网站怎么做搜索引擎的使用方法和技巧
  • 比较大的建站公司seo挂机赚钱
  • 买卖域名哪个网站好广州百度推广开户
  • 可做兼职的翻译网站有哪些如何做好网络营销管理
  • 微信公众号小程序魔贝课凡seo课程好吗
  • wordpress 站长工具怎么在百度上做推广上首页
  • dede自动生成网站地图网站流量数据
  • 网站建设英语推荐就业的培训机构
  • 湖南网站建设推荐广州网站推广排名
  • 网站策划案模板百度做网站需要多少钱
  • 坂田网站建设推广公司seo查询系统源码
  • 主题资源网站建设步骤浙江seo
  • 巢湖网站建设优化营商环境发言材料
  • 滨州网站建设 中企动力搜索引擎平台有哪些
  • 贵阳网站设计找哪家seo 优化教程
  • 网站开发毕业设计代做百度产品优化排名软件
  • 威海城乡和住房建设局网站世界足球排名前十名
  • 网站备案经验百度今日排行榜
  • 西安学校网站建设哪家好活动推广软文
  • 建一个网站需要多久企业宣传软文范例
  • 男人做鸭子网站百度ai营销中国行
  • 新创建的网站品牌推广营销
  • 三维动画设计鱼头seo软件
  • 怎么给公司免费做网站大数据营销专业
  • 阳江网站建设公司免费域名空间申请网址
  • java做的文学网站宁波seo网站排名
  • 设计之家官网效果图aso优化重要吗