|
|
||
John O'Conner's BlogModularity in the Java PlatformPosted by joconner on May 07, 2008 at 01:37 PM | Comments (3)JSR 277 is the technical spec for Java Modules, a way to promote the "module" concept in both your own applications and in the Java platform itself. In their JavaOne session this morning, the co-spec leads -- Alex Buckley and Stanley Ho -- clarified that the previous JSR 294 "superpackages" spec has been consumed by this new JSR. JSR 277 includes modularity concepts and features for both development and deployment. In short, the goals are these:
Today, Java development is dominated by packages. Although package names are hierarchical, package membership is not. You can't easily share types and members across packages unless the interfaces or class members are Modules in the JSR 277 definition would allow developers to associate classes and resources in different packages so that those classes can access each other more easily. Modules would logically gather those classes -- even if they exist in different packages -- into a common bag or module, providing the ability for those classes to work more directly with each other. In effect, you get yet another access modifier, something like What's the impact of modules on the Java language and VM?
How about developers? What's this module concept really mean for them? How do developers use it? Not much really changes in how you'll compile or run your applications:
Developers will be able to annotate classes (and modules) to describe modules versions, membership, dependencies, and other attributes. For example, you might use any of the following: @Version @MainClass @Attribute @ImportModules @ImportModule @ImportPolicyClass @ModuleInitializerClass @PlatformBinding @ExportResources Of course, you'll have to check out some of the technical docs and specs for more detailed descriptions of these and other annotations. But the info is out there. See the end of this blog for more information about resources you can use to learn more. JAM files and modules should help deliver you from so-called "JAR hell." JAR hell basically refers to the confusion that developers and applications struggle with when deciding which versions of jar files to use. Yes, jar files can have version numbers, and they usually do. But jar dependencies are difficult to specify, determine, and enforce. And without classloader tricks, you can't use two versions of a JAR file...maybe a new version in one part of your application and an older version in another. Think that's an unreasonable expectation? It's not. Consider the situation you're in with XML parsers, for example. Your app might need one version. But maybe that same app uses a third party library that uses an older version of that same XML parser. Resolving this can be frustrating. The new spec resolves some of this. Different classloaders handle each JAM. The modules system makes sure that:
The JAM specification is still in draft status. The co-spec leads say that the final spec will be available "soon," and I assume that means that implementations are not far behind. To learn more:
Bookmark blog post: CommentsComments are listed in date ascending order (oldest first) | Post Comment
| ||
|
|