commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Commons Wiki] Update of "MavenGroupIDChange" by sebbapache
Date Wed, 24 Nov 2010 18:27:35 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Commons Wiki" for change notification.

The "MavenGroupIDChange" page has been changed by sebbapache.
The comment on this change is: What is jar hell.
http://wiki.apache.org/commons/MavenGroupIDChange?action=diff&rev1=4&rev2=5

--------------------------------------------------

  
  If there are multiple versions of the same class on the classpath, there's no guarantee
which version will be loaded,  so in general the classpath should only ever contain a single
version of each class.
  
+ == What is jar-hell ? ==
+ Suppose project A depends on the jars B and C, and these in turn depend on jar D. 
+ So the classpath consists of (A,B,C,D). No problem so far.
+ 
+ D is updated to add some new features (call it D2), and jar B is updated to use them (B2).

+ Provided that D2 is binary compatible with D, the a classpath which contains (A,B2,C,D2)
will still allow jar C to work correctly.
+ 
+ Now suppose that D2 is not compatible with D, such that jar C does not operate with jar
D2. The classpath would have to contain both D and D2.
+ However B2 requires the class from D2, wheres C requires the version of the class from jar
D. It's not possible to satisfy both of these.
+ Even for compatible classes in D and D2, there is a problem, because there's no way to determine
whether classes will be loaded from D or D2.
+ 
+ Jar-hell is when the classpath needs to contains multiple copies of the same classes in
different jars.
+ 
  == Maven dependency resolution ==
  Maven assumes that artifacts with the same GroupId and ArtifactId represent the same item,
 and ensures that only one instance of each such artifact is added to the classpath.
  
@@ -25, +38 @@

  
  If the groupId is changed, then org.apache.commons:commons-foo will be treated as a different
artifact,  and the Maven classpath could potentially contain two copies of the same component.
  
- This can cause a problem, for which there are several possible solutions - none of which
are ideal: * use relocation POMs * change the Foo package name
+ This can cause a problem, for which there are several possible solutions - neither of which
is ideal: 
+  * use relocation POMs 
+  * change the Foo package name
  
  === Relocation POMS ===
  A relocation POM can be set up to redirect references from commons-foo:commons-foo to org.apache.commons:commons-foo.
Both would be seen as being the same item, avoiding duplicates on the classpath.
@@ -38, +53 @@

  If the change from commons-foo:commons-foo to org.apache.commons:commons-foo is accompanied
by a change to the Java package name, e.g. to org.apache.commons.foo3, then there will be
no classpath issue, as both Maven and Java treat the artifacts as different.
  
  There are two possible scenarios here
- * The new version of the code is binary incompatible with the old version.
+  * The new version of the code is binary incompatible with the old version.
- * The new version is binary compatible with the old version.
+  * The new version is binary compatible with the old version.
  
  However, the change of Java package name is neither binary nor source-compatible, and can
require a lot of work for users of Commons Foo. This may be acceptable if the new version
has incompatible changes to the API, but not otherwise - why should users (who may not even
use Maven) be forced to change their code just to upgrade to the latest version (James Carman:
the user will thank us when they try to use a library that requires the older version, we
shouldn't discount this too much.  This approach solves the "jar hell" issue) (Sebb: there
is no "jar hell" if the versions are binary compatible)?
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message