使用Shade插件重定位功能的缺点 [英] Downsides of using Shade plugin relocation feature

查看:203
本文介绍了使用Shade插件重定位功能的缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要解决应用程序中的jar冲突,我使用了阴影插件的重定位功能.它对我有用,但是我觉得这是一个hack.我想了解使用重定位功能(如果有)的弊端.

To resolve jar conflicts in my application, I use the shaded plugin's relocation feature. It works for me, but i feel it is a hack. I would like to understand the downsides of using the relocation feature if any.

推荐答案

主要问题是,在直接定义软件包名称(而不仅仅是导入)的情况下,它可能会失败.例如,如果您使用反射并通过其名称(包括程序包名称)实例化一个类,它将生成错误的类.当在清单中定义包装时(可能有一个转换器),可能会发生类似的问题.有关更多信息,请参见插件信息.

The main issue is that it can fail in cases where the package name is directly defined (not just imported). For example, if you are using reflection and instantiating the a class by its name (including the package name) it will generate the wrong one. Similar problems can occur when the the package is defined in a manifest (there is a transformer for that). See the plugin info for more information.

另一个可能出现问题的地方是使用相同依赖关系的第三方依赖关系.考虑例如提供的包装A.如果程序包A依赖于已重定位的程序包,它将在运行时使用提供的实例而不是已重定位的实例.这可能会导致无法预料的影响.

Another place where this could be an issue is with a third party dependency which uses the same dependency. Consider for example package A which is provided. If package A depends on the relocated package it will in the run time use the provided instance instead of the relocated one. This can lead to unforeseen effects.

另一个问题是,在某些情况下,程序包可能包含一些初始化/静态信息(例如,它一次下载了一些信息或具有一些大的静态表).在这种情况下,重要的是要了解现在有两个完全独立的软件包实例.

An additional issue is that in some cases, the package may contain some initialized/static information (e.g. it downloads some info once or has some big static table). In these cases it is important to understand that there are now TWO completely separate instances of the package.

这篇关于使用Shade插件重定位功能的缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆