Skip to content
Commits on Source (5)
Information about openhft-chronicle-bytes
-----------------------------------------
This package was debianized using the mh_make command
from the maven-debian-helper package.
The build system uses Maven but prevents it from downloading
anything from the Internet, making the build compliant with
the Debian policy.
openhft-chronicle-bytes (1.1.15-2) unstable; urgency=medium
* Fix Java 9 compatibility.
* Ignore test failures (Closes: #921291).
-- Andrej Shadura <andrewsh@debian.org> Thu, 28 Feb 2019 14:20:34 +0100
openhft-chronicle-bytes (1.1.15-1) unstable; urgency=medium
* Initial release (Closes: #832915)
-- Emmanuel Bourg <ebourg@apache.org> Sun, 31 Jul 2016 14:46:47 +0200
Source: openhft-chronicle-bytes
Section: java
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Uploaders: Emmanuel Bourg <ebourg@apache.org>
Build-Depends:
debhelper (>= 9),
default-jdk,
junit4,
libintellij-annotations-java,
libmaven-bundle-plugin-java,
libmockito-java,
libopenhft-chronicle-core-java,
libslf4j-java,
libsnappy-java,
maven-debian-helper (>= 2.1)
Standards-Version: 3.9.8
Vcs-Git: https://anonscm.debian.org/git/pkg-java/openhft-chronicle-bytes.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/openhft-chronicle-bytes.git
Homepage: https://github.com/OpenHFT/Chronicle-Bytes
Package: libopenhft-chronicle-bytes-java
Architecture: all
Depends: ${maven:Depends}, ${misc:Depends}
Suggests: ${maven:OptionalDepends}
Description: OpenHFT byte buffer library
Chronicle Bytes has a similar purpose to Java NIO's ByteBuffer with some
extensions. It's build on Chronicle Core's direct memory and OS system
call access and contains all the low level memory access wrappers.
The API supports:
* 64-bit sizes
* UTF-8 and ISO-8859-1 encoded strings.
* thread safe off heap memory operations.
* deterministic release of resources via reference counting.
* compressed data types such as stop bit encoding.
* elastic ByteBuffer wrappers which resize as required.
* parsing text and writing text directly to off heap bytes.
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OpenHFT Chronicle Bytes
Source: https://github.com/OpenHFT/Chronicle-Bytes
Files-Excluded: *.iml
Files: *
Copyright: 2014-2015, Higher Frequency Trading
License: LGPL-3
On Debian systems, the full text of the LGPL-3 license
can be found in the file '/usr/share/common-licenses/LGPL-3'
Files: debian/*
Copyright: 2016, Emmanuel Bourg <ebourg@apache.org>
License: Apache-2.0
On Debian systems, the full text of the Apache-2.0 license
can be found in the file '/usr/share/common-licenses/Apache-2.0'
# List of POM files for the package
# Format of this file is:
# <path to pom file> [option]*
# where option can be:
# --ignore: ignore this POM and its artifact if any
# --ignore-pom: don't install the POM. To use on POM files that are created
# temporarily for certain artifacts such as Javadoc jars. [mh_install, mh_installpoms]
# --no-parent: remove the <parent> tag from the POM
# --package=<package>: an alternative package to use when installing this POM
# and its artifact
# --has-package-version: to indicate that the original version of the POM is the same as the upstream part
# of the version for the package.
# --keep-elements=<elem1,elem2>: a list of XML elements to keep in the POM
# during a clean operation with mh_cleanpom or mh_installpom
# --artifact=<path>: path to the build artifact associated with this POM,
# it will be installed when using the command mh_install. [mh_install]
# --java-lib: install the jar into /usr/share/java to comply with Debian
# packaging guidelines
# --usj-name=<name>: name to use when installing the library in /usr/share/java
# --usj-version=<version>: version to use when installing the library in /usr/share/java
# --no-usj-versionless: don't install the versionless link in /usr/share/java
# --dest-jar=<path>: the destination for the real jar.
# It will be installed with mh_install. [mh_install]
# --classifier=<classifier>: Optional, the classifier for the jar. Empty by default.
# --site-xml=<location>: Optional, the location for site.xml if it needs to be installed.
# Empty by default. [mh_install]
#
pom.xml --no-parent --has-package-version --usj-name=openhft-chronicle-bytes
net.openhft chronicle-bom * * * *
net.openhft third-party-bom * * * *
org.apache.maven.plugins maven-scm-publish-plugin * * * *
org.apache.servicemix.tooling depends-maven-plugin * * * *
# Include here properties to pass to Maven during the build.
# For example:
# maven.test.skip=true
junit junit jar s/.*/4.x/ * *
--- a/pom.xml
+++ b/pom.xml
@@ -111,10 +111,16 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <compilerArgument>-Xlint:deprecation</compilerArgument>
- <source>1.8</source>
- <target>1.8</target>
+ <source>1.9</source>
+ <target>1.9</target>
+ <fork>true</fork>
<encoding>UTF-8</encoding>
+ <compilerArgs>
+ <arg>-Xlint:deprecation</arg>
+ <arg>--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED</arg>
+ <arg>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</arg>
+ <arg>--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED</arg>
+ </compilerArgs>
</configuration>
</plugin>
<!--
--- a/src/main/java/net/openhft/chronicle/bytes/NativeBytesStore.java
+++ b/src/main/java/net/openhft/chronicle/bytes/NativeBytesStore.java
@@ -19,17 +19,22 @@
import net.openhft.chronicle.core.*;
import net.openhft.chronicle.core.annotation.ForceInline;
import net.openhft.chronicle.core.io.IORuntimeException;
+import net.openhft.chronicle.core.Jvm;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import sun.misc.Cleaner;
+import java.lang.ref.Cleaner;
import sun.nio.ch.DirectBuffer;
+import sun.misc.Unsafe;
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
@SuppressWarnings("sunapi")
public class NativeBytesStore<Underlying>
@@ -37,11 +42,22 @@
private static final long MEMORY_MAPPED_SIZE = 128 << 10;
private static final Logger LOGGER = LoggerFactory.getLogger(NativeBytesStore.class);
private static final Field BB_ADDRESS, BB_CAPACITY;
+ private static final Unsafe UNSAFE;
+ private static final Method invokeCleaner;
static {
Class directBB = ByteBuffer.allocateDirect(0).getClass();
BB_ADDRESS = Jvm.getField(directBB, "address");
BB_CAPACITY = Jvm.getField(directBB, "capacity");
+ UNSAFE = getUnsafe();
+ Method tmpCleaner;
+ try {
+ tmpCleaner = UNSAFE.getClass().getDeclaredMethod("invokeCleaner", ByteBuffer.class);
+ tmpCleaner.setAccessible(true);
+ } catch (Throwable t) {
+ tmpCleaner = null;
+ }
+ invokeCleaner = tmpCleaner;
}
@Nullable
@@ -52,12 +68,13 @@
protected long address;
long maximumLimit;
@Nullable
- private Cleaner cleaner;
+ private final static Cleaner cleaner = Cleaner.create();
+ private Cleaner.Cleanable cleanable;
private final ReferenceCounter refCount = ReferenceCounter.onReleased(this::performRelease);
private boolean elastic;
@Nullable
private Underlying underlyingObject;
- private Error releasedHere;
+ Error releasedHere;
private NativeBytesStore() {
}
@@ -75,7 +92,11 @@
long address, long maximumLimit, @Nullable Runnable deallocator, boolean elastic) {
setAddress(address);
this.maximumLimit = maximumLimit;
- cleaner = deallocator == null ? null : Cleaner.create(this, deallocator);
+ if (deallocator != null) {
+ cleanable = cleaner.register(this, deallocator);
+ } else {
+ cleanable = null;
+ }
underlyingObject = null;
this.elastic = elastic;
}
@@ -141,14 +162,27 @@
underlyingObject = (Underlying) bb;
setAddress(((DirectBuffer) bb).address());
this.maximumLimit = bb.capacity();
- cleaner = ((DirectBuffer) bb).cleaner();
+ if (invokeCleaner != null) {
+ cleanable = cleaner.register(this, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ invokeCleaner.invoke(UNSAFE, bb);
+ } catch (Throwable e) {
+
+ }
+ }
+ });
+ } else {
+ cleanable = null;
+ }
}
public void uninit() {
underlyingObject = null;
address = 0;
maximumLimit = 0;
- cleaner = null;
+ cleanable = null;
}
@NotNull
@@ -423,7 +457,7 @@
public void write(
long offsetInRDO, @NotNull ByteBuffer bytes, int offset, int length) {
if (bytes.isDirect()) {
- memory.copyMemory(((DirectBuffer) bytes).address(),
+ memory.copyMemory(((DirectBuffer) bytes).address() + offset,
address + translate(offsetInRDO), length);
} else {
@@ -450,19 +484,21 @@
@Override
public long address(long offset) throws UnsupportedOperationException {
- if (offset < start() || offset >= capacity())
+ if (offset < start() || offset > capacity())
throw new IllegalArgumentException();
return address + translate(offset);
}
private void performRelease() {
+ memory = null;
if (refCount.get() > 0) {
LOGGER.info("NativeBytesStore discarded without releasing ", createdHere);
}
- memory = null;
- if (cleaner != null)
- cleaner.clean();
+ if (releasedHere == null)
+ releasedHere = new Error();
+ if (cleanable != null)
+ cleanable.clean();
}
@NotNull
@@ -626,4 +662,25 @@
}
}
+
+ private static Unsafe getUnsafe() {
+ if (System.getSecurityManager() != null) {
+ return AccessController.doPrivileged(new PrivilegedAction<Unsafe>() {
+ public Unsafe run() {
+ return getUnsafe0();
+ }
+ });
+ }
+ return getUnsafe0();
+ }
+
+ private static Unsafe getUnsafe0() {
+ try {
+ Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
+ theUnsafe.setAccessible(true);
+ return (Unsafe) theUnsafe.get(null);
+ } catch (Throwable t) {
+ throw new RuntimeException("JDK did not allow accessing unsafe", t);
+ }
+ }
}
#!/usr/bin/make -f
%:
dh $@ --buildsystem=maven
override_dh_auto_clean:
dh_auto_clean
rm -f *.bin
override_dh_auto_test:
-dh_auto_test
get-orig-source:
uscan --download-current-version --force-download --repack --rename --compression xz
version=3
https://github.com/OpenHFT/Chronicle-Bytes/tags .*/chronicle-bytes-(.*).tar.gz