Posts Tagged ‘presentation’
Jigsaw arriving – and now what?
The debate is over. The result of fierce discussions has been declared. Jigsaw is knocking at the door. Now the fate of Jigsaw depends on the community. Will the community embrace Jigsaw? Will we be able to leverage the new concepts to our benefit? Will we struggle with new pitfalls?
Let’s step back a second: do we really know what is Jigsaw? Do we really understand the design, its subtleties and implications?
At EclipseCon Europe 2017 I will try to shed a light on some lesser known aspects of Jigsaw. A deep dive into things I learned as a JDT committer while implementing tool support for Java 9.
In search for truth
To set the stage, we’ll first have to figure out, who or what defines Java 9 — or Jigsaw — or JPMS. This is both a question of specification vs. implementation as well as a matter of a specification spread over several documents and artifacts. Let’s try to grok Jigsaw from the legally binding sources, rather then from secondary writing and hearsay (if that is possible).
We will have to relearn some of the basic terms, like: what is a package in Java? Do packages form a hierarchy? (I will show, how both answers, yes and no, are equally right and wrong).
Jigsaw is said to do away with some “undesirable” stuff like split packages, and cyclic dependencies. Really? (Yes and no).
Encapsulation
Of course, with Jigsaw all is about encapsulation – easy to agree on, but what is it that a Java 9 module encapsulates? Only a deep understanding of the flavor of encapsulation will tell us, what exact qualities we gain from following the new discipline (it’s not about security, e.g.), and also what pains will be incurred on the path of migrating to the new model. (Hint: I will be speaking both about compile time and runtime).
Interestingly, the magic potion Jigsaw also brings its own antidote: With tightening the rules of encapsulation, also the opposite becomes necessary: they call it breaking encapsulation, for which I once coined the term “decapsulation“. I should be flattered by how close Java 9 comes to what I call “gradual encapsulation“. So, the talk can not stop at presenting just the new language concepts, also the various extra-lingual means for tuning your architecture need to be inspected through the looking glass. This is also where tools come into focus: how can JDT empower its users to use the new options without the need to dig through the sometimes cryptic syntax of command line parameters?
Loose ends
At this point we shall agree that Jigsaw is a compromise, fulfilling many of its goals and promises, while also missing some opportunities.
I will also have to say a few words about long standing API of JDT, which makes guarantees that are no longer valid in Java 9. This raises the question: what is the migration path for tools that sit on top of JDT? (There is no free lunch).
Finally, it wouldn’t be Java, if overloading wouldn’t make things worse for the newly added concepts. But: haven’t you become fond of hating, when JDT says:
The type org.foo.Bar cannot be resolved. It is indirectly referenced from required .class filesWe may be seeing light at the end of the tunnel: for Jigsaw we had to revamp the guts of our compiler in ways, that could possibly help to – finally – resolve that problem. Wish me luck …
Hope to see you in Ludwigsburg, there’s much to be discussed over coffee and beer
![]() |
Ludwigsburg, Germany · October 24 – 26, 2017 |
Runtime Specialization – At Last
Between a rock and a hard place
Not long ago, I had to pull Object Teams out of the Eclipse simultaneous release train. Reason: the long standing issue of using BCEL for bytecode weaving, for which no Java 8 compatible version has yet been released. With the Eclipse platform moving to Java 8, this had escalated to a true blocker. During the last weeks I investigated two options in parallel:
- Upgrade BCEL to a release candidate of the upcoming 6.0 release.
- Finalize the alternative weaver for OT/J, which is based on ASM, and thus already capable of handling Java 8 byte codes
I soon found out that even BCEL 6.0 will not be a full solution, because it still has no real support for creating StackMapTable attributes for newly generated bytecode, which however is strictly mandatory for running on a JVM 8.
For that reason I then focussed on the OTDRE, the Object Teams Dynamic Runtime Environment. This has been announced long ago, and after all, I promised to show a sneak preview of this feature in my presentation at EclipseCon Europe:
Runtime Specialization
Java has never been so dynamic before
Success at last
Today I can report success in two regards:
- The Object Teams Development Tooling, which itself is a complex OT/J application, can (mostly) run on the new runtime!
- I created a first demo example that shows the new capability of runtime weaving in action – it works! 🙂
This is a major milestone! Running OTDT on top of OTDRE is a real stress test for that new component – once again I realize that dog-fooding an entire IDE on its own technology is quite an exciting exercise. While a few exceptions need to be ironed out before the Neon release, I’m confident now, that we’re finally and really on the home stretch of this effort.
And after all the hard work on Java 8, also OT/J can finally fully leverage the new version, not only in theory, but also in bytecode.
Less than one week to finalize the presentation. You can be sure this will be a fresh story. Join me on Wednesday, Nov 4, in Ludwigsburg:
PS: The “traditional” Object Teams Runtime Environment isn’t dead, yet. I really want to keep it as an option, because both variants (OTRE / OTDRE) have quite different characteristics, and after all this component has matured over more than 10 years. But with one option already (mostly) working, I can probably wait until a proper release of BCEL 6.0, and still have it back in game before the Neon release.
Modularity at JavaOne 2012
| Those planning to attend JavaOne 2012 in San Francisco might be busy right now building their personal session schedule. So here’s what I have to offer:
On Wed., Oct. 3, I’ll speak about
|
|
I guess one of the goals behind moving Jigsaw out of the schedule for Java 8 was: to have more time to improve our understanding of modularity, right? So, why not join me when I discuss how much an object-oriented programming language can help to improve modularity.
When speaking of modularity, I don’t see this as a goal in itself, but as a means for facilitating reuse, and when speaking of reuse I’m particularly interested in reusing a module in a context that was not anticipated by the module provider (that’s what creates new value).
To give you an idea of my agenda, here’re the five main steps of this session:
- Warm-up: Debugging the proliferation of module concepts – will there ever be an end? Much of this follows the ideas in this post of mine.
- Reuse needs adaptation of existing modules for each particular usage scenario. Inheritance, OTOH, promises to support specialization. How come inheritance is not considered the primary architecture level concept for adapting reusable modules?
- Any attempts to apply inheritance as the sole adaptation mechanism in reuse mash-ups results in conflicts which I characterize as the Dominance of the Instantiator. To mend this contention inheritance needs a brother, with similar capabilities but much more dynamic and thus flexible.
- Modularity is about strictly enforced boundaries – good. However, the rules imposed by this regime can only deliver their true power if we’re also able to express limited exceptions.
- Given that creating variants and adapting existing modules is crucial for unanticipated reuse, how can those adaptations themselves be developed as modules?
At each step I will outline a powerful solution as provided by Object Teams.
See you in San Francisco!
|
Edit: The slides and the recording of this presentation are now available online. |
Object Teams with Null Annotations
The recent release of Juno M4 brought an interesting combination: The Object Teams Development Tooling now natively supports annotation-based null analysis for Object Teams (OT/J). How about that? 🙂

The path behind us
Annotation-based null analysis has been added to Eclipse in several stages:
- Using OT/J for prototyping
- As discussed in this post, OT/J excelled once more in a complex development challenge: it solved the conflict between extremely tight integration and separate development without double maintenance. That part was real fun.
- Applying the prototype to numerous platforms
- Next I reported that only one binary deployment of the OT/J-based prototype sufficed to upgrade any of 12 different versions of the JDT to support null annotations — looks like a cool product line
- Pushing the prototype into the JDT/Core
- Next all of the JDT team (Core and UI) invested efforts to make the new feature an integral part of the JDT. Thanks to all for this great collaboration!
- Merging the changes into the OTDT
- Now, that the new stuff was mixed back into the plain-Java implementation of the JDT, it was no longer applicable to other variants, but the routine merge between JDT/Core HEAD and Object Teams automatically brought it back for us. With the OTDT 2.1 M4, annotation-based null analysis is integral part of the OTDT.
Where we are now
Regarding the JDT, others like Andrey, Deepak and Aysush have beaten me in blogging about the new coolness. It seems the feature even made it to become a top mention of the Eclipse SDK Juno M4. Thanks for spreading the word!
Ah, and thanks to FOSSLC you can now watch my ECE 2011 presentation on this topic.
Two problems of OOP, and their solutions
Now, OT/J with null annotations is indeed an interesting mix, because it solves two inherent problems of object-oriented programming, which couldn’t differ more:
1.: NullPointerException is the most widespread and most embarrassing bug that we produce day after day, again and again. Pushing support for null annotations into the JDT has one major motivation: if you use the JDT but don’t use null annotations you’ll no longer have an excuse. For no good reasons your code will retain these miserable properties:
- It will throw those embarrassing NPEs.
- It doesn’t tell the reader about fundamental design decisions: which part of the code is responsible for handling which potential problems?
Why is this problem inherent to OOP? The dangerous operator that causes the exception is this:

right, the tiny little dot. And that happens to be the least dispensable operator in OOP.
2.: Objectivity seems to be a central property on any approach that is based just on Objects. While so many other activities in software engineering are based on the insight that complex problems with many stakeholders involved can best be addressed using perspectives and views etc., OOP forces you to abandon all that: an object is an object is an object. Think of a very simple object: a File. Some part of the application will be interested in the content so it can decode the bytes and do s.t. meaningful with it, another part of the application (maybe an underlying framework) will mainly be interested in the path in the filesystem and how it can be protected against concurrent writing, still other parts don’t care about either but only let you send the thing over the net. By representing the “File” as an object, that object must have all properties that are relevant to any part of the application. It must be openable, lockable and sendable and whatnot. This yields
bloated objects and unnecessary, sometimes daunting dependencies. Inside the object all those different use cases it is involved in can not be separated!
With roles objectivity is replaced by a disciplined form of subjectivity: each part of the application will see the object with exactly those properties it needs, mediated by a specific role. New parts can add new properties to existing objects — but not in the unsafe style of dynamic languages, but strictly typed and checked. What does it mean for practical design challenges? E.g, direct support for feature oriented designs – the direct path to painless product lines etc.
Just like the dot, objectivity seems to be hardcoded into OOP. While null annotations make the dot safe(r), the roles and teams of OT/J add a new dimension to OOP where perspectives can be used directly in the implementation. Maybe it does make sense, to have both capabilities in one language 🙂 although one of them cleans up what should have been sorted out many decades ago while the other opens new doors towards the future of sustainable software designs.
The road ahead
The work on null annotations goes on. What we have in M4 is usable and I can only encourage adopters to start using it right now, but we still have an ambitious goal: eventually, the null analysis shall not only find some NPEs in your program, but eventually the absense of null related errors and warnings shall give the developer the guarantee that this piece of code will never throw NPE at runtime.
What’s missing towards that goal:
- Fields: we don’t yet support null annotations for fields. This is next on our plan, but one particular issue will require experimentation and feedback: how do we handle the initialization phase of an object, where fields start as being null? More on that soon.
- Libraries: we want to support null specifications for libraries that have no null annotations in their source code.
- JSR 308: only with JSR 308 will we be able to annotate all occurrences of types, like, e.g., the element type of a collection (think of
List)
Please stay tuned as the feature evolves. Feedback including bug reports is very welcome!
Ah, and one more thing in the future: I finally have the opportunity to work out a cool tutorial with a fellow JDT committer: How To Train the JDT Dragon with Ayushman. Hope to see y’all in Reston!
Follow-up: Object Teams Tutorial at EclipseCon 2011
At our EclipseCon tutorial we mentioned a bonus excercise, for which we didn’t have the time at the tutorial.
Now it’s time to reveal the solution.
Task
“Implement the following demo-mode for the JDT:
- • When creating a Java project let the user select:
- ❒ Project is for demo purpose only
- • When creating a class in a Demo project:
- insert class name as “Foo1”, “Foo2” …”
So creating classes in demo mode is much easier, and you’ll use the names “Foo1″… anyway 🙂
(See also our slides (#39)).
Granted, this is a toy example, yet it combines a few properties that I frequently find in real life and which cause significant pains without OT/J:
- The added behavior must tightly integrate with existing behavior.
- The added behavior affects code at distant locations,
here two plug-ins are affected:org.eclipse.jdt.uiandorg.eclipse.jdt.core. - The added behavior affects execution at different points in time,
here creation of a project plus creation of a class inside a project. - The added behavior requires to maintain more state at existing objects,
here a JavaProject must remember if it is a demo project.
Despite these characteristics the task can be easily described in a few English sentences. So the solution should be similarly concise and delivered as a single coherent piece.
Strategy
With a little knowledge about the JDT the solution can be outlined as this
- Add a checkbox to the New Java Project wizard
- When the wizard creates the project mark it as a demo project if the box is checked.
- Let the project also count the names of
Foo..classes it has created. - When the new class wizard creates a class inside a demo project pre-set the generated class name and make the name field unselectable.
From this we conclude the need to define 4 roles, playedBy these existing types:
org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne.NameGroup:
the wizard page section where the project name is entered and where we want to add the checkbox.org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageTwo:
the part of the wizard that triggers setup of the JavaProject.org.eclipse.jdt.core.IJavaProject:
this is where we need to add more state (isDemoProject and numFooClasses).org.eclipse.jdt.ui.wizards.NewTypeWizardPage:
this is where the user normally specifies the name for a new class to be created.
Note, that 3 classes in this list resided in org.eclipse.jdt.ui, but IJavaProject is from org.eclipse.jdt.core, which leads us to the next step:
Plug-in configuration
Our solution is developed as an OT/Equinox plug-in, with the following architecture level connections:

This simply says that the same team demohelper.ProjectAdaptor is entitled to bind roles to classes from both org.eclipse.jdt.ui and org.eclipse.jdt.core.
One more detail in these extensions shouldn’t go unmentioned: Don’t forget to set “activation: ALL_THREADS” for the team (otherwise you won’t see any effect …).
Now we’re ready to do the coding.
Implementing the roles
protected class DialogExtender playedBy NameGroup { protected SelectionButtonDialogField isDemoField; void createControl(Composite parent) <- after Control createControl(Composite composite) with { parent <- (Composite) result } private void createControl(Composite parent) { isDemoField= new SelectionButtonDialogField(SWT.CHECK); isDemoField.setLabelText("Project is for demo purpose only"); isDemoField.setSelection(false); isDemoField.doFillIntoGrid(parent, 4); } }
Our first role adds the checkbox. The implementation of createControl is straight-forward UI business. Lines 22,23 hook our role method into the one from the bound base class NameGroup. After the with keyword, we are piping the result from the base method into the parameter parent of the role method (with a cast). This construct is a parameter mapping.
Next we want to store the demo-flag to instances of IJavaProject, so we write this role:
protected class EnhancedJavaProject playedBy IJavaProject { protected boolean isDemoProject; private int numFooClasses = 1; protected String getTypeName() { return "Foo"+(numFooClasses++); } }
Great, now any IJavaProject can play the role EnhancedJavaProject which holds the two additional fields, and we can automatically serve an arbitrary number of class names Foo1 …
In the IDE you will actually see a warning, telling you that binding a role to a base interface currently imposes a few restrictions, but these don’t affect us in this example.
Next comes a typical question: how to transfer the flag from role DialogExtender to role EnhancedJavaProject?? The roles don’t know about each other nor do the bound base classes. The answer is: use a chain of references.
protected class FirstPage playedBy NewJavaProjectWizardPageOne { DialogExtender getFNameGroup() -> get NameGroup fNameGroup; protected boolean isDemoProject() { return getFNameGroup().isDemoField.isSelected(); } } protected class WizardExtender playedBy NewJavaProjectWizardPageTwo { FirstPage getFFirstPage() -> get NewJavaProjectWizardPageOne fFirstPage; markDemoProject <- after initializeBuildPath; private void markDemoProject(EnhancedJavaProject javaProject) { if (getFFirstPage().isDemoProject()) javaProject.isDemoProject = true; } }
Role WizardExtender intercepts the event when the wizard initializes the IJavaProject (line 46). Method initializedBuildPath receives a parameter of type IJavaProject but the OT/J runtime transparently translates this into an instance of type EnhancedJavaProject (this – statically type safe – operation is called lifting). Another indirection is needed to access the checkbox: The base objects are linked like this:
This link structure is lifted to the role level by the callout bindings in lines 35 and 44.
We’re ready for our last role:
protected class NewTypeExtender playedBy NewTypeWizardPage { void setTypeName(String name, boolean canBeModified) -> void setTypeName(String name, boolean canBeModified); void initTypePage(EnhancedJavaProject prj) <- after void initTypePage(IJavaElement element) with { prj <- element.getJavaProject() } private void initTypePage(EnhancedJavaProject prj) { if (prj.isDemoProject) setTypeName(prj.getTypeName(), false); } }
Here we intercept the initialization of the type page of a New Java Project wizard (lines 66,67). Another parameter mapping is used to perform two adjustments in one go: fetch the IJavaProject from the enclosing element and lift it to its EnhancedJavaProject role. This follows the rule-of-thumb that base-type operations (like navigating from IJavaElement to IJavaProject) should happen at the right hand side, so that we are ready to lift the IJavaProject to EnhancedJavaProject when the data flow enters the team.
The EnhancedJavaProject can now be asked for its stored flag (isDemoProject) and it can be asked for a generated class name (getTypeName()). The generated class name is then inserted into the dialog using the callout binding in line 64. Looks like this:

See this? No need to think of a good class name 🙂
Wrap-up
So that’s it. All these roles are collected in one team class and here is the fully expanded outline:

All this is indeed one concise and coherent module. In the tutorial I promised to do this no more than 80 LOC, and indeed the team class has 74 lines including imports and white space.
Or, if you are interested just in how this module connects to the existing implementation, you may use the “binding editor” in which you see all playedBy, callout and callin bindings:

The full sources are also available for download.
have fun



role
callout binding
callin binding.



