Correct way to use VarHandle in Java 9?

It is used for instance in AtomicReference, where previously in Java 8, sun.misc.Unsafe was used: public final void lazySet(V newValue) { unsafe.putOrderedObject(this, valueOffset, newValue); } public final boolean compareAndSet(V expect, V update) { return unsafe.compareAndSwapObject(this, valueOffset, expect, update); } Here the this pointer is used together with a field offset to access the field. But …

Read more

What does “Required filename-based automodules detected.” warning mean?

Automatic module recap An explicit module (i.e. one with a module-info.java) can only access code of modules that it requires (ignoring implied readability for a moment). That’s great if all dependencies are modularized, but what if they are not? How to refer to a JAR that isn’t modular? Automatic modules are the answer: Any JAR …

Read more

How should I name my Java 9 module?

For a while there were two different opinions on your question but during the development of the module system, the community settled on the reverse DNS approach. Unique Module Names – Reverse DNS Here, the assumption is that module names should be globally unique. Given that goal, the most pragmatic way to get there follows …

Read more