简体   繁体   English

Java Bean Introspector需要桌面模块

[英]Java Beans Introspector requires desktop module

I'm investigating using Jigsaw to reduce the footprint of a microservice. 我正在研究使用Jigsaw来减少微服务的占用空间。 One of the last dependencies I had to find was java.beans.Introspector. 我必须找到的最后一个依赖项是java.beans.Introspector。

Imagine my surprise when I discovered I needed to bring in the whole module java.desktop which contains all sorts of irrelevant stuff like awt, applets, swing etc. 想象一下,当我发现需要引入整个模块java.desktop时,我感到惊讶,该模块包含各种不相关的东西,例如awt,applet,swing等。

This seems crazy to me, surely bean introspection should be a part of the fundamental language and not related to UI functionality. 在我看来,这很疯狂,可以肯定的是,bean的自省应该是基本语言的一部分,并且与UI功能无关。 I think the dependency comes from the embedded Tomcat from Spring Boot so it's not something I can modify myself. 我认为依赖项来自Spring Boot的嵌入式Tomcat,因此我无法自行修改。

The Question: Are modules the finest granularity you can access or is there another way to trim the fat as it were. 问题:模块是您可以访问的最细粒度,还是有另一种方式来减少脂肪。

The dependency exists, because BeanInfo and SimpleBeanInfo have references to Icon and Image from the AWT package. 之所以存在依赖关系,是因为BeanInfoSimpleBeanInfo引用了AWT包中的IconImage Further, PropertyEditor declares the methods getCustomEditor and paintValue​ creating dependencies to the classes Component , Graphics , and Rectangle . 此外, PropertyEditor声明的方法getCustomEditorpaintValue​创建依赖的类ComponentGraphicsRectangle There are also some classes not visible in the API having references to desktop classes, ie the default property editor and persistence delegate implementations shipped for these desktop classes. API中还有一些不可见的类,其中包含对桌面类的引用,即为这些桌面类提供的默认属性编辑器和持久性委托实现。

Since Java modules do not allow packages spread across multiple modules, there is no way to split the functionality into an AWT dependent and a non-dependent module (in a backward compatible manner). 由于Java模块不允许程序包跨多个模块散布,因此无法将功能拆分为AWT依赖模块和非依赖模块(以向后兼容的方式)。 The dynamically loaded artifacts, ie actual bean infos, editors and persistence delegates, could have been moved into another module, but not the BeanInfo and PropertyEditor interfaces and their SimpleBeanInfo and PropertyEditorSupport implementations. 动态加载的工件(即实际的bean信息,编辑器和持久性委托)可以移到另一个模块中,但不能移到BeanInfoPropertyEditor接口及其SimpleBeanInfoPropertyEditorSupport实现中。

There is no finer granularity and no solution to use bean classes without creating that dependency. 没有更好的粒度,没有在不创建依赖项的情况下使用Bean类的解决方案。 This is best illustrated by how the JDK developers dealt with the problems caused by this decision. JDK开发人员如何处理此决定引起的问题可以很好地说明这一点。 Since java.util.logging.LogManager and java.util.jar.Pack200.Packer / Unpacker had support for java.beans.PropertyChangeListener , which caused a dependency to java.desktop , if kept that way, these methods were the first methods ever removed from the standard Java API, as fast as being deprecated in Java 8 for the first time and already removed in Java 9. 由于java.util.logging.LogManagerjava.util.jar.Pack200.Packer / Unpacker支持java.beans.PropertyChangeListener ,这导致对java.desktop的依赖,如果保持这种方式,则这些方法是有史以来的第一个方法从标准Ja​​va API中删除,速度与Java 8中首次弃用并已在Java 9中删除一样快。

I think, if there was a way to declare a dependency to the fundamental bean classes like PropertyChangeListener without creating the unwanted dependency to java.desktop , the JDK developers didn't set that precedent. 我认为,如果有一种方法可以声明对像PropertyChangeListener类的基本bean类的依赖关系, java.desktop创建不必要的依赖关系,那么JDK开发人员就不会设置该先例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 泛型和java.beans.Introspector - Generics and java.beans.Introspector Java.beans.Introspector.getBeanInfo()无法分配writeMethods - Java.beans.Introspector.getBeanInfo() fails to assign writeMethods 使用使用java.beans类的jar(Introspector,BeanInfo或PropertyDescriptor) - Using jars that use java.beans classes (Introspector, BeanInfo or PropertyDescriptor) Spring LibGDX And​​roid应用程序中缺少java.beans.Introspector - Missing java.beans.Introspector in Spring LibGDX Android application java.beans.Introspector getBeanInfo不会拾取任何超接口的属性 - java.beans.Introspector getBeanInfo does not pickup any superinterface's properties 使用 OpenCSV 解析 csv 文件时没有找到类“java.beans.Introspector” - Didn't find class “java.beans.Introspector” when Using OpenCSV to parse csv files 不活动后调用java.beans.Introspector.getBeanInfo时的性能问题 - Performance issues when calling java.beans.Introspector.getBeanInfo after inactivity Java 8和Bean Info Introspector中的接口中的默认方法 - Default method in interface in Java 8 and Bean Info Introspector 对Java模块的帮助:模块'name'读取包'javafx.beans' - Assistance to Java Module: Module 'name' reads package 'javafx.beans' java.desktop 无法解析为模块 - java.desktop cannot be resolved to a module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM