diff --git a/CHANGES.md b/CHANGES.md
index ecf33f221d..5951859629 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,13 @@ NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and AL 2.0 (see LICENSE
NOTE: JNI native support is typically incompatible between minor versions, and almost always incompatible between major versions.
+Release 5.12.1
+==============
+
+Bug Fixes
+---------
+* [#1447](https://github.com/java-native-access/jna/issues/1447): Null-check cleanable in `c.s.j.Memory#close` - [@dbwiddis](https://github.com/dbwiddis).
+
Release 5.12.0
==============
diff --git a/README.md b/README.md
index 7c05bc7152..4a35e34c9d 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
Java Native Access (JNA)
========================
-The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://java-native-access.github.io/jna/5.12.0/javadoc/). Please read the [overview](http://java-native-access.github.io/jna/5.12.0/javadoc/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).
+The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://java-native-access.github.io/jna/5.12.1/javadoc/). Please read the [overview](http://java-native-access.github.io/jna/5.12.1/javadoc/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).
JNA provides Java programs easy access to native shared libraries without writing anything but Java code - no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes.
@@ -65,12 +65,12 @@ Pre-built platform support may be found [here](https://github.com/java-native-ac
Download
========
-Version 5.12.0
+Version 5.12.1
JNA
---
-[![Maven Central](https://img.shields.io/maven-central/v/net.java.dev.jna/jna.svg?label=Maven%20Central)](https://search.maven.org/artifact/net.java.dev.jna/jna/5.12.0/jar) [jna-5.12.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.12.0/jna-5.12.0.jar) [jna-jpms-5.12.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-jpms/5.12.0/jna-jpms-5.12.0.jar)
+[![Maven Central](https://img.shields.io/maven-central/v/net.java.dev.jna/jna.svg?label=Maven%20Central)](https://search.maven.org/artifact/net.java.dev.jna/jna/5.12.1/jar) [jna-5.12.1.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.12.1/jna-5.12.1.jar) [jna-jpms-5.12.1.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-jpms/5.12.1/jna-jpms-5.12.1.jar)
This is the core artifact of JNA and contains only the binding library and the
core helper classes.
@@ -78,7 +78,7 @@ core helper classes.
JNA Platform
------------
-[![Maven Central](https://img.shields.io/maven-central/v/net.java.dev.jna/jna-platform.svg?label=Maven%20Central)](https://search.maven.org/artifact/net.java.dev.jna/jna-platform/5.12.0/jar) [jna-platform-5.12.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/5.12.0/jna-platform-5.12.0.jar) [jna-platform-jpms-5.12.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform-jpms/5.12.0/jna-platform-jpms-5.12.0.jar)
+[![Maven Central](https://img.shields.io/maven-central/v/net.java.dev.jna/jna-platform.svg?label=Maven%20Central)](https://search.maven.org/artifact/net.java.dev.jna/jna-platform/5.12.1/jar) [jna-platform-5.12.1.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/5.12.1/jna-platform-5.12.1.jar) [jna-platform-jpms-5.12.1.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform-jpms/5.12.1/jna-platform-jpms-5.12.1.jar)
This artifact holds cross-platform mappings and mappings for a number of commonly used platform
functions, including a large number of Win32 mappings as well as a set of utility classes
@@ -146,12 +146,12 @@ Using the Library
* [Platform Library](https://github.com/java-native-access/jna/blob/master/www/PlatformLibrary.md)
* [Direct Method Mapping](https://github.com/java-native-access/jna/blob/master/www/DirectMapping.md) (Optimization)
* [Frequently Asked Questions (FAQ)](https://github.com/java-native-access/jna/blob/master/www/FrequentlyAskedQuestions.md)
-* [Avoiding Crashes](http://java-native-access.github.io/jna/5.12.0/javadoc/overview-summary.html#crash-protection)
+* [Avoiding Crashes](http://java-native-access.github.io/jna/5.12.1/javadoc/overview-summary.html#crash-protection)
Primary Documentation (JavaDoc)
===============================
-The definitive JNA reference is in the [JavaDoc](http://java-native-access.github.io/jna/5.12.0/javadoc/).
+The definitive JNA reference is in the [JavaDoc](http://java-native-access.github.io/jna/5.12.1/javadoc/).
Developers
==========
diff --git a/build.xml b/build.xml
index 7eb9a25add..e0f2e1d05d 100644
--- a/build.xml
+++ b/build.xml
@@ -64,7 +64,7 @@
-
+
diff --git a/dist/doc.zip b/dist/doc.zip
index 8eb0721a81..7deef4578a 100644
Binary files a/dist/doc.zip and b/dist/doc.zip differ
diff --git a/dist/jna-jpms.jar b/dist/jna-jpms.jar
index dd2867a14a..85c4fdc1d8 100644
Binary files a/dist/jna-jpms.jar and b/dist/jna-jpms.jar differ
diff --git a/dist/jna-min.jar b/dist/jna-min.jar
index 4d2db19128..f713715a3d 100644
Binary files a/dist/jna-min.jar and b/dist/jna-min.jar differ
diff --git a/dist/jna-platform-jpms.jar b/dist/jna-platform-jpms.jar
index 75479833a9..2fae0cd763 100644
Binary files a/dist/jna-platform-jpms.jar and b/dist/jna-platform-jpms.jar differ
diff --git a/dist/jna-platform.jar b/dist/jna-platform.jar
index b3388cff70..d39193e69f 100644
Binary files a/dist/jna-platform.jar and b/dist/jna-platform.jar differ
diff --git a/dist/jna.aar b/dist/jna.aar
index 7806adeacf..6595585d53 100644
Binary files a/dist/jna.aar and b/dist/jna.aar differ
diff --git a/dist/jna.jar b/dist/jna.jar
index f62f94efe4..77f8c7ae04 100644
Binary files a/dist/jna.jar and b/dist/jna.jar differ
diff --git a/dist/jnacontrib/demo-alphamask.jar b/dist/jnacontrib/demo-alphamask.jar
index dc7627eceb..c8875cecc4 100644
Binary files a/dist/jnacontrib/demo-alphamask.jar and b/dist/jnacontrib/demo-alphamask.jar differ
diff --git a/dist/jnacontrib/demo-balloonmanager.jar b/dist/jnacontrib/demo-balloonmanager.jar
index 3a52d1f27f..9394d01da7 100644
Binary files a/dist/jnacontrib/demo-balloonmanager.jar and b/dist/jnacontrib/demo-balloonmanager.jar differ
diff --git a/dist/jnacontrib/demo-balloontips.jar b/dist/jnacontrib/demo-balloontips.jar
index d122065798..7153b4d17d 100644
Binary files a/dist/jnacontrib/demo-balloontips.jar and b/dist/jnacontrib/demo-balloontips.jar differ
diff --git a/dist/jnacontrib/demo-dnd.jar b/dist/jnacontrib/demo-dnd.jar
index 78522e0794..a9b89d3ca6 100644
Binary files a/dist/jnacontrib/demo-dnd.jar and b/dist/jnacontrib/demo-dnd.jar differ
diff --git a/dist/jnacontrib/demo-monitordemo.jar b/dist/jnacontrib/demo-monitordemo.jar
index 64cbf172b7..d20e96cd72 100644
Binary files a/dist/jnacontrib/demo-monitordemo.jar and b/dist/jnacontrib/demo-monitordemo.jar differ
diff --git a/dist/jnacontrib/demo-msoffice.jar b/dist/jnacontrib/demo-msoffice.jar
index f1246e90a3..b1e2adf7e7 100644
Binary files a/dist/jnacontrib/demo-msoffice.jar and b/dist/jnacontrib/demo-msoffice.jar differ
diff --git a/dist/jnacontrib/demo-nativewindowmsg.jar b/dist/jnacontrib/demo-nativewindowmsg.jar
index 7a55e62c42..ad4322ad77 100644
Binary files a/dist/jnacontrib/demo-nativewindowmsg.jar and b/dist/jnacontrib/demo-nativewindowmsg.jar differ
diff --git a/dist/jnacontrib/demo-shapedwindow.jar b/dist/jnacontrib/demo-shapedwindow.jar
index e7dd3d2eb6..f85b58f654 100644
Binary files a/dist/jnacontrib/demo-shapedwindow.jar and b/dist/jnacontrib/demo-shapedwindow.jar differ
diff --git a/dist/jnacontrib/demo-w32printing.jar b/dist/jnacontrib/demo-w32printing.jar
index c0909212b1..3e588c1836 100644
Binary files a/dist/jnacontrib/demo-w32printing.jar and b/dist/jnacontrib/demo-w32printing.jar differ
diff --git a/dist/jnacontrib/demo-w32windowhooks.jar b/dist/jnacontrib/demo-w32windowhooks.jar
index b20cff22e8..e53075941b 100644
Binary files a/dist/jnacontrib/demo-w32windowhooks.jar and b/dist/jnacontrib/demo-w32windowhooks.jar differ
diff --git a/dist/jnacontrib/demo-x11.jar b/dist/jnacontrib/demo-x11.jar
index d6cf63eac9..d4d481f59e 100644
Binary files a/dist/jnacontrib/demo-x11.jar and b/dist/jnacontrib/demo-x11.jar differ
diff --git a/dist/src-full.zip b/dist/src-full.zip
index d10b89d64f..56a0ef74db 100644
Binary files a/dist/src-full.zip and b/dist/src-full.zip differ
diff --git a/dist/src.zip b/dist/src.zip
index 2b6c4267fe..2a2d7c1797 100644
Binary files a/dist/src.zip and b/dist/src.zip differ
diff --git a/src/com/sun/jna/Memory.java b/src/com/sun/jna/Memory.java
index 67d9422902..c83bfed9b5 100644
--- a/src/com/sun/jna/Memory.java
+++ b/src/com/sun/jna/Memory.java
@@ -22,7 +22,6 @@
*/
package com.sun.jna;
-import com.sun.jna.internal.Cleaner;
import java.io.Closeable;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
@@ -32,6 +31,8 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import com.sun.jna.internal.Cleaner;
+
/**
* A Pointer
to memory obtained from the native heap via a
* call to malloc
.
@@ -76,7 +77,7 @@ public static void disposeAll() {
}
}
- private Cleaner.Cleanable cleanable;
+ private final Cleaner.Cleanable cleanable;
protected long size; // Size of the malloc'ed space
/** Provide a view into the original memory. Keeps an implicit reference
@@ -123,6 +124,7 @@ public Memory(long size) {
protected Memory() {
super();
+ cleanable = null;
}
/** Provide a view of this memory using the given offset as the base address. The
@@ -180,9 +182,12 @@ public Memory align(int byteBoundary) {
}
/** Free the native memory and set peer to zero */
+ @Override
public void close() {
peer = 0;
- cleanable.clean();
+ if (cleanable != null) {
+ cleanable.clean();
+ }
}
@Deprecated
@@ -783,6 +788,7 @@ public MemoryDisposer(long peer) {
this.peer = peer;
}
+ @Override
public synchronized void run() {
try {
free(peer);