Is platform enforced versioning mechanism most sorely needed feature of java?

只谈情不闲聊 提交于 2019-12-01 03:51:17

Take a peek at OSGi - it deals with versioning and management of bundles (jars) very nicely.

ALSO: Eclipse (which is built on top of OSGi) has some relatively new API Tools that can help you compare your API against a previous baseline and determine how to appropriately express the next version number of your bundles.

The general eclipse versioning scheme:

v.m.n.q

where

v: high-level version - changes here represent generally breaking changes in the API

m: major changes - new functionality, new API

n: minor changes - same API, behind-the-scenes changes

q: qualifier - useful to mark builds, alpha/beta, etc

OSGi specifies version dependencies using ranges. For example

Require-Bundle: com.javadude.foo;bundle-version="[1.2.0,2.0.0)"

in your MANIFEST.MF specifies that the bundle requires version 1.2.0 or later of bundle com.javadude.foo, up through (but not including) version 2.0.0.

You can also specify dependencies at the package level instead.

I've also been using Java for over a decade but I have to say I haven't found many JAR hell issues at all (even using all the 3rd-party tools you mention)! I found Maven to be a horrible tool, so build everything with ant.

At our company we have a bespoke dependency-resolution ant task based on a simple (small) dependency file for each project, together with defining each project as either an app or a lib (you should only ever depend on a lib; never an app). It works just fine.

We also have ant tasks to modify our eclipse .classpath and IDEA .iml files to generate dependency graphs for our IDEs.

The advantage that .NET has over Java is that the libraries are tied more closely to the OS. The fact that the framework libraries, if they are installed, are easily located in the GAC does simplify things, but you're also pretty much limited to Windows. A better comparison would be Mono, but I don't have any experience there.

Configuration management, at least to me, has always been the big pain of software development. The more you try to take advantage of existing code, the worse it seems to become. The problem itself is not unique to Java, but the proliferation of versions, the amount of time the platform has been around, and the number of platforms supported does seem to make it worse. I just checked and I have 3 versions of the JRE on my box right now -- and I'm not even an active Java developer.

As to your question, I'm not sure if it is the most pressing feature need. Personally, I'd like to see some better support for web services, particularly those requiring authentication headers. The last time I tried to get Java to interact with one of my .NET web services, I nearly tore my hair out. Having used LINQ with C#/.Net, I can also say that would be a pretty cool addition to Java with arguably more productivity gains to be had.

.NET supports side-by-side assemblies, so you can have multiple versions of the same app arround. The GAC is like shared DLLs, but still you can register multiple versions of the same assembly at the GAC and another assembly can request a certain or a greater-than version if I remember well. In JavaEE you do have several class-loader levels btw and you can do some tricks simulating similar versioning

I came across this problem at a site I worked at: built a tool to run through the jar files living on a webserver and find all the nested copies of jar files - and different files with the same names (eg: versions of log4j.jar). It was a hideous mess, including one WAR that had the WebLogic jar inside it.

Not sure what the solution is.

Thing is: java has stuff to manage this - stamped jar files with package versions. And particularly: webstart. Perhaps what's needed is some kind of classloader that does a webstart-type thing.

How about: in the JAR manifest, you specify library dependencies, using well-known names and versions. The classloader - provided by the container or the runtime - would be responsible for getting the versions that you want.

There are plenty of systems (eg: Maven itself) for managing well-known places to download libraries from, as well as fink and whatnot.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!