Java Classloader - how to reference different versions of a jar

前端 未结 5 1152
一个人的身影
一个人的身影 2020-12-03 07:28

This is a common problem. I\'m using 2 libraries A.jar and B.jar and these depend on different versions of the same jar.
Let\'s say tha

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 08:07

    Many libraries are backward compatible. But not all..


    The old way is to try to depend from only one version.

    It is probably safer to compile both with the same version (latest).
    At least you get compile-time errors, instead of runtime errors.

    If needed, you can modify a little bit your library that works with the old dependency...
    This would require access to the source...


    Please note that compile-time compatibility will not guarantee correct runtime behavior either. It is one step, then you can:

    • read the WhatsNew file for the new version of the jar
    • look on the Internet for users reporting compatibility problems
    • write JUnits
    • compare the codes in both jars

提交回复
热议问题