Using sun.misc.Unsafe in Java 9

The Java 9 EA version is out and we can now see how to use sun.misc.Unsafe. I led the public campaign to retain access to it in Java 9 which was ultimately successful, leading to the amendments to JEP 260.

So, how did things end up?

Getting Set Up

First you need to download Java 9 EA. For an IDE I use IntelliJ IDEA. You need the new 2017.1 Public Preview which came out 27 February 2017. Earlier versions don’t work with Java 9.

The jdk.unsupported module

sun.misc.Unsafe is now available in the jdk.unsupported module. This module is present in the full JRE and JDK images.

Here is the module declaration for jdk.unsupported:

As you can see sun.misc is exported.

Using It

I have a sample project with a package java9unsafe and a module with the same name.

To use Unsafe, you need to add jdk.unsupported to your code’s module declaration:

Fortunately, IDEA will detect the declaration if missing and suggest adding it for you when you hover over your import statement.

Then you can use Unsafe. Note you have to indirectly get at the Unsafe instance via reflection otherwise you get a security exception.

And the answer: The address size is: 8



Hazelcast blasts pass competitors in performance, as measured by their own tools!

We should start calling Hazelcast, Hazelfast. Hazelcast 3.6 EA shipped last week, and it is very fast. Compared to what, you ask? Well, compared to everything. How do we know this? Well, our competitors made their own comparative benchmarking tools, YardStick and RadarGun. And we ran them against Hazelcast as we were developing 3.6. We were getting faster anyway thanks to our dedicated performance team, but there is nothing like competition to spur improvement.

Hazelcast versus Infinispan/JBoss Data Grid

On RadarGun, the Infinispan tool, we are faster in all tests with the biggest margin begin 80%.

See the full benchmark results here.

Source code for the benchmark is here: See the results of the Radar-Gun Benchmark

Hazelcast versus Apache Ignite/GridGain

On YardStick, the GridGain tool, we are faster in all tests with the biggest margin being 90% faster.

Source code for each benchmark is on GitHub:

See the full benchmark here.

Oracle Coherence

It turns out that it is a breach of Oracle’s OTN license to publish benchmarks. So we can’t comment at all on our benchmark results compared to Oracle Coherence. But, there is no such restriction on publishing a Benchmark Suite. We can send it to you and you can run it yourself.

Hazelcast 3.2.2 Released

We just released Hazelcast 3.2.2. This release is a stable, production-ready maintenance release.

Stabilizer Testing

This release was tested using our new production simulator, Hazelcast Stabilizer for 48 hours with the following configurations:

small       = [12 instance, memberWorkerCount 4, clientWorkerCount 8]
medium  = [26 instance, memberWorkerCount 6, clientWorkerCount 20]
large       = [50 instance, memberWorkerCount 10, clientWorkerCount 40]

This first one just used the MapTest, but on the next release we will include more.

Patch Release 3.2.2 – Closed Issues


Hazelcast 3.3-EA Released

We just released Hazelcast-3.3-EA with the following new features:

  • Heartbeat for Java client
  • filterless Tomcat 6&7 Web Sessions Clustering (Enterprise only)
  • Enterprise WAN Replication (Enterprise only)
  • Replicated Map

Download Enterprise version here or open source version here.

We anticipate the RC version will be out mid-June.


How JSR107 Caching Annotations are meant to be used

I am getting a few questions lately on JSR107 caching annotations and whether implementations of JSR107 are providing them.
Caching annotations can be added to your Java classes and will invoke caching operations as the method. For example below is an annotated BlogManager.
@CacheDefaults(cacheName = "blgMngr")
public class BlogManagerImpl implements BlogManager {private static Map<String, Blog> map = new HashMap<String, Blog>();@CacheResult
public Blog getEntryCached(String title) {
return map.get(title);

public Blog getEntryRaw(String title) {
return map.get(title);

* @see manager.BlogManager#clearEntryFromCache(java.lang.String)
public void clearEntryFromCache(String title) {

public void clearEntry(String title) {
map.put(title, null);

public void clearCache() {

public void createEntry(Blog blog) {
map.put(blog.getTitle(), blog);

public Blog getEntryCached(String randomArg, @CacheKey String title,
String randomArg2) {
return map.get(title);

Caching annotations, though defined in JSR107, are not meant to be provided by a CachingProvider such as Hazelcast. Instead they must be provided by the dependency injection containers: Spring, Guice, CDI (for Java EE). This will happen with EE in 8 which is a couple of years away. Spring support is coming in 4.1 and is available now for developers to play with in snapshot. See for how to use it.
While it will take time for the DIs to add support, in the JSR107 RI we have written a module for each of them. That code can be added to your existing DI Container and it will enable caching annotations processing. See

I will be joining Hazelcast as CTO

I am very excited to announce that I will be joining the world-class team at Hazelcast as CTO.

Hazelcast ( develops, distributes and supports the leading open source in-memory data grid. The product, also called Hazelcast, is a free open source download under the Apache license that any developer can include in minutes to enable them to build elegantly simple mission-critical, transactional, and terascale in-memory applications. The company provides commercially licensed Enterprise extensions, Hazelcast Management Console and professional open source training, development support and deployment support. The company is privately held and headquartered in Palo Alto, California.

What this means for Hazelcast Users

I will join my efforts to those of Hazelcast CEO Talip Ozturk and the team and bring my deep knowledge of caching to Hazlecast to complement that of the team. I will be out and about at conferences and visiting customers.

With the team we will be figuring out what great features to add to Hazelcast and how to improve the leading open source In-Memory Data Grid.

We will also be bring to market Enterprise Extensions which add high value features based around the Hazelcast core.

Hazelcast has made an announcement that puts this move into their own words.

What this means for Terracotta BigMemory Users

We will develop a comparative caching/operational store project and product based on Hazelcast core.   This will then be an alternative for BigMemory users.

What this means for Ehcache Users

The ownership of Ehcache was transferred to Terracotta 4 and a half years ago when I joined them who then took over maintenance of it.

While Ehcache remains widely used today, the open source version is only suitable for single node caching. This is not that useful for most production contexts so it is not directly competitive with Hazelcast or for that matter In-Memory Data Grids, which deal with clusters of computers.

I expect Ehcache will implement JCache and that in the future those ISVs and open source frameworks which currently define Ehcache as their caching layer will instead define it using JCache, of which Ehcache will be one provider.

Hazelcast is already developing their JCache implementation, which is already up on GitHub.

What this means for JCache

JCache is the new standard for caches and IMDGs. It includes a key-value API suitable for caches and operational stores. Importantly it was designed primarily for IMDGs. Listeners, loaders, writers and other user-defined classes are expected to be executed somewhere in the cluster, not in process.  And the spec defines and single and batch EntryProcessors, the defining feature of IMDG, which enables in-situ computation.

I will continue to act as spec lead on new maintenance releases of JCache. And I will also work with the Java EE 8 expert group who are including JCache in Java EE8. And I will be working with open source frameworks and ISVs as they move to add a JCache layer to their architectures.

Hazelcast will be one of the first to market with an implementation of JCache which should be available in a production-ready implementation in February.

As it is Apache 2 open source, I encourage open source frameworks and ISVs to include Hazelcast in their distributions as they add JCache. That way they can ship with an out of the box IMDG built in without locking themselves or their users/customers into a single vendor.

Crimson and Clover

As part of work to do provide coverage reports for the TCK of JCache we had to add a coverage tool. As we are open source I spent some time playing with coverage tools.

We build with Maven 3. For reasons do with usage of the TCK, we have four standalone modules: jsr107soec, jsr107tck, RI and Demo. Within the jsr107tck and RI there is a parent pom and children with back references to their parents. To easily run the four top level modules we have an aggregate module which is not declared as a parent in the poms of the four top level modules. It looks like this.

An unusual aspect of this arrangements is that all tests for the RI are contained in the jsr107tck module. The RI itself has no tests.

My approach was to spend a few hours with first the open source coverage tools, Emma and Cobertura, and then to move on to Clover which I have used before, if needed.

Emma’s Maven plugin is old and needs a work around for Java 7. But got it basically working but could not get it to deal with our complicated structure.

Then I tried Cobertura. Version 2.6 of the Maven module was released just in August. It worked fine with Java 7. But once again I found it difficult to make progress with our complicated structure. I was thinking the best approach would be to give all modules the same coverage database location. In Cobertura you do this with a system property. e.g. -Dnet.sourceforge.cobertura.datafile=/path/cobertura.ser . I didn’t get this working.

I then tried Clover, and got up and running. I specified the same clover.db location for all modules. I needed to add this to the aggregate pom, and each top level pom. For those top level modules with children, defining it in the parent was sufficient. I added the following to each of those poms.

Then to run a build with clover instrumentation:
mvn clean com.atlassian.maven.plugins:maven-clover2-plugin:setup install

And to run the clover report:
mvn com.atlassian.maven.plugins:maven-clover2-plugin:clover

Note the wordy module definitions. You can use the short name of clover2 if you add the following to your settings.xml:


The first example then becomes:
mvn clean clover2:setup install

It would be great if they could change the User Guide to point out this step as it mars what is otherwise a very smooth experience.

Lambda Hello World

I was recently checking Lambda expressions out to ensure the forthcoming JCache spec would work Ok with them. I just wanted a really simple example that worked through the different syntactical forms and ended up putting a Hello World type example myself.

* Hello world!
public class App {

static void print(Something something) {
System.out.println(something.doSomeThing("Hello World"));

interface Something {

String doSomeThing(String word);

public static void main(String[] args) {
print(new Something() {

public String doSomeThing(String word) {
return word.concat(" - it is no fun to AnonymousInnerClass");

//expression form. No return
print((String s) -> s.concat(" = it is fun to Lambda"));

//block. Need return as interface method has return.
print((String s) -> {return s.concat(" = it is fun to Lambda");});

//expression. No type required as Interface defines it.
print((s) -> s.concat(" = it is fun to Lambda"));

//creating a concrete instance of a functional interface via assignment
Something something = (s) -> s.replace("the", "thee");
System.out.println(something.doSomeThing("What the!"));

java.util.function.Predicate predicate = new


JSR107 JCache enters Public Draft Review

On 5 July 2013, JSR107 went into Public Draft Review and which will last until 4 August.

Visit the JSR home page on GitHub to get the code. Or read the spec.

I encourage anyone interested in Java caching to take a look and give us feedback which you can do by posting an issue on GitHub for specific things or for more general feedback posting to the JSR107 Google Groups mailing list.

JSR107 enters Early Draft Review after nearly 12 years

On 23 October 2012 the JCP posted the Early Draft specification and API for JSR107. See This is almost 12 years since the JSR kicked off. Note that this material was uploaded to the JCP in February this year but was delayed while the legal complications of having two companies as shared spec leads got sorted out. That is now done and will not be an issue going forward in the process.
We will now be working intensively to drive this to completion in its own right and for inclusion in Java ## 7. We expect to be final in early 2013.
We need your review
In the meantime the early draft review period is open until 22 November. Please visit the home of the project at and send your comments to or create issues at For a quick into see
We have also just added a few new artifacts up on GitHub:
– A very simple demo which can be used when giving talks.
– ehcache-jcache – an implementation of the 0.5 specification that works with the latest version of ehcache.
Remaining JCP 2.7 Process Steps
The review period ends 22 November. Once we have a public draft, we will submit that for 30 days’ review. A EC ballot will be held in the last week of the public draft period before we move on to complete the RI and TCK and seek final approval.
Java EE 7 Deadline
We have sought clarification from the EE JSR on their deadline. It is fast approaching. We therefore intend to go hard.