Skip to content
CMO & CTO
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

  • Digital Experience
    • Experience Strategy
    • Experience-Driven Commerce
    • Multi-Channel Experience
    • Personalization & Targeting
    • SEO & Performance
    • User Journey & Behavior
  • Marketing Technologies
    • Analytics & Measurement
    • Content Management Systems
    • Customer Data Platforms
    • Digital Asset Management
    • Marketing Automation
    • MarTech Stack & Strategy
    • Technology Buying & ROI
  • Software Engineering
    • Software Engineering
    • Software Architecture
    • General Software
    • Development Practices
    • Productivity & Workflow
    • Code
    • Engineering Management
    • Business of Software
    • Code
    • Digital Transformation
    • Systems Thinking
    • Technical Implementation
  • About
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

Java 9 Modules: Finally Some Structure

Posted on June 20, 2017 By Luis Fernandez

Java 9 modules land with a simple promise: real fences for our code.

If you have shipped large Java apps, you know the drill. The classpath is a mystery box, private stuff leaks out, and a tiny bump in a jar can wake the pager. Project Jigsaw has been years in the making, and it is finally close. The JCP just gave the spec a green light after some heated talk. We now get a standard way to say what we need and what we expose. No more public by accident. No more friends only by a comment on top of a class. We write it down in one place and the compiler enforces it.

Meet the module descriptor: a tiny file named module-info.java at the root of your source. It lists what you export and what you require. That is it. The VM knows your module name, your edges, and what stays inside. The rest is sealed off with strong encapsulation. Reflection cannot sneak into non exported packages unless you open a door. Here is a small sample for a library that ships a public API and hides the rest:

module-info.java

module com.acme.catalog {
    exports com.acme.catalog.api;
    requires java.sql;
}

If you want a dependency to leak through your API, mark it as requires transitive. That way callers of your module see it without adding it on their own. You can also wire services with uses and provides. The ideas are simple and they map to real needs, like plug a payment driver or a search engine that lives behind a clean contract. Here is a quick service setup:

Service API

// com.acme.payment.api
package com.acme.payment.api;
public interface PaymentGateway {
    boolean charge(String account, long cents);
}

Descriptor for the API module

module com.acme.payment.api {
    exports com.acme.payment.api;
    uses com.acme.payment.api.PaymentGateway;
}

Provider module

// com.acme.payment.stripe
module com.acme.payment.stripe {
    requires com.acme.payment.api;
    provides com.acme.payment.api.PaymentGateway
        with com.acme.payment.stripe.StripeGateway;
}

On the app side you ask the ServiceLoader for a PaymentGateway and you get whatever providers are present. No more hand rolled registries. It reads clean, and you can swap pieces during tests without fights.

Migration is the part everyone is poking. You do not need to modularize the whole world on day one. You can run on the module path with plain jars. Each plain jar becomes an automatic module with a name derived from the file. Your app still works, and you can move one module at a time. Watch for split packages since the system does not like the same package spread across modules. If you use deep reflection on internals, add opens for those packages, or make the entire module open while you clean things up. Try to keep that as a short bridge and not the default.

Tooling is catching up fast. IDE builds are already poking the module path. jdeps can tell you who touches what, which helps to carve the first descriptors. The new jlink tool lets you compose a small runtime that carries only the standard modules you need. For a microservice or a tiny desktop app, that trims the size and boots faster. Ship a single folder with your app and a runtime that fits it, and leave the rest behind. That alone can cut noise from support tickets.

My favorite side effect is readability. A module is a story. One file says what I offer, what I consume, and where my edges sit. Juniors can open a project and get the map in a minute. Seniors can refactor guts without fear that a random package gets imported from the other side of the codebase. It nudges teams to think in clear shapes and to stop treating private things as public just because it was easy.

We are not done as a community. Build tools are still smoothing things out. Some popular libs will need a tweak or two. But the core is here, and it feels sane. Start with one module. Add a descriptor. Export only what you must. Push the rest behind the fence. Little by little, your app starts to breathe.

Project Jigsaw gives Java a shared language for boundaries. That is long overdue, and it will pay off in cleaner APIs, smaller runtimes, and code you can actually reason about on a Monday morning.

Ship smaller runtimes.

Read your code like a table of contents.

Code Development Practices Software Engineering coding-practicesjavaspring

Post navigation

Previous post
Next post
  • Digital Experience (94)
    • Experience Strategy (19)
    • Experience-Driven Commerce (5)
    • Multi-Channel Experience (9)
    • Personalization & Targeting (21)
    • SEO & Performance (10)
  • Marketing Technologies (92)
    • Analytics & Measurement (14)
    • Content Management Systems (45)
    • Customer Data Platforms (4)
    • Digital Asset Management (8)
    • Marketing Automation (6)
    • MarTech Stack & Strategy (10)
    • Technology Buying & ROI (3)
  • Software Engineering (310)
    • Business of Software (20)
    • Code (30)
    • Development Practices (52)
    • Digital Transformation (21)
    • Engineering Management (25)
    • General Software (82)
    • Productivity & Workflow (30)
    • Software Architecture (85)
    • Technical Implementation (23)
  • 2025 (12)
  • 2024 (8)
  • 2023 (18)
  • 2022 (13)
  • 2021 (3)
  • 2020 (8)
  • 2019 (8)
  • 2018 (23)
  • 2017 (17)
  • 2016 (40)
  • 2015 (37)
  • 2014 (25)
  • 2013 (28)
  • 2012 (24)
  • 2011 (30)
  • 2010 (42)
  • 2009 (25)
  • 2008 (13)
  • 2007 (33)
  • 2006 (26)

Ab Testing Adobe Adobe Analytics Adobe Target AEM agile-methodologies Analytics architecture-patterns CDP CMS coding-practices content-marketing Content Supply Chain Conversion Optimization Core Web Vitals customer-education Customer Data Platform Customer Experience Customer Journey DAM Data Layer Data Unification documentation DXP Individualization java Martech metrics mobile-development Mobile First Multichannel Omnichannel Personalization product-strategy project-management Responsive Design Search Engine Optimization Segmentation seo spring Targeting Tracking user-experience User Journey web-development

©2025 CMO & CTO | WordPress Theme by SuperbThemes