[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Classloading and versioning

adrian@jboss.org do-not-reply at jboss.com
Fri May 16 05:57:47 EDT 2008


"alesj" wrote : 
  | Even if it would, why would that be a problem?
  | Shouldn't there be a way to tell that in-bundle usage is a black box, and scott's usage of ales is impl detail.
  | 
  | Would then there be a way to get runtime CCE if something ales's was exposed through scott and used in foobar?
  | Or how do you detect this at deployment, exposing the possible conflict?

The way to tell the classloader that they are shared and could conflict is by
expressing the export. Once the package is exported anything that imports it
could load it.

Think about it...

foo imports ales from acme1
foo imports scott from acme2
but acme1 also exports scott and acme2 exports ales

The classloader can't make the assumptions you are trying to make.
it doesn't know that ales and scott won't leak across the two different
deployments.
They are exported so it must assume that they will since importers
must need the classes for a reason.

If they are not exported, there's no consistency check required.
The modules are assume to only use the classes as private implementation detail.

Even if they were the same physical classes on disk (and defined as the same
version) you'd get a CCE since the classes are loaded by different classloaders.

The fundamental problem is caused by an incorrect modularisation.
You want to version ales and scott independently so foo
can choose them independently. But you've tied them into
the same bundle making this impossible.

There be no problem if there was an
acme1-ales:1.0.0
acme1-scott:1.0.0
acme2-ales:3.0.0
acme2-scott:4.0.0

foo could then choose acme1-ales:1.0.0 and acme1-scott-4.0.0
as long as acme1-scott-4.0.0 doesn't need to make an incompatible
decision on what version of ales to use (and vice versa).

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4151322#4151322

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4151322



More information about the jboss-dev-forums mailing list