From 0fb4eeefdcc40aa41a30d09f4b5a9dcf011047b5 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Sun, 31 Jul 2016 17:00:08 +0100 Subject: [PATCH] Update Chronicle Map to using bom 1.13.12 --- pom.xml | 5 ++- .../impl/SerializationBuilder.java | 38 ++++++++++--------- .../map/impl/stage/data/ZeroBytesStore.java | 21 +++++++--- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 7cb339398..0b2b643d7 100755 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,8 @@ ~ along with this program. If not, see . --> - + net.openhft @@ -46,7 +47,7 @@ net.openhft chronicle-bom pom - 1.12.26 + 1.13.12-SNAPSHOT import diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/impl/SerializationBuilder.java b/src/main/java/net/openhft/chronicle/hash/serialization/impl/SerializationBuilder.java index 4f8c515ab..adff42e7b 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/impl/SerializationBuilder.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/impl/SerializationBuilder.java @@ -26,7 +26,7 @@ import net.openhft.chronicle.values.ValueModel; import net.openhft.chronicle.values.Values; import net.openhft.chronicle.wire.Marshallable; -import java.io.*; +import java.io.Externalizable; import java.lang.reflect.Modifier; import java.nio.ByteBuffer; @@ -35,6 +35,20 @@ import static net.openhft.chronicle.hash.serialization.SizeMarshaller.stopBit; public final class SerializationBuilder implements Cloneable { + public final Class tClass; + public final boolean sizeIsStaticallyKnown; + boolean serializesGeneratedClasses = false; + private SizeMarshaller sizeMarshaller = stopBit(); + private SizedReader reader; + private DataAccess dataAccess; + + @SuppressWarnings("unchecked") + public SerializationBuilder(Class tClass) { + this.tClass = tClass; + configureByDefault(tClass); + sizeIsStaticallyKnown = constantSizeMarshaller(); + } + private static boolean concreteClass(Class c) { return !c.isInterface() && !Modifier.isAbstract(c.getModifiers()); } @@ -50,22 +64,6 @@ public final class SerializationBuilder implements Cloneable { } } - public final Class tClass; - private SizeMarshaller sizeMarshaller = stopBit(); - private SizedReader reader; - private DataAccess dataAccess; - - public final boolean sizeIsStaticallyKnown; - - boolean serializesGeneratedClasses = false; - - @SuppressWarnings("unchecked") - public SerializationBuilder(Class tClass) { - this.tClass = tClass; - configureByDefault(tClass); - sizeIsStaticallyKnown = constantSizeMarshaller(); - } - @SuppressWarnings("unchecked") private void configureByDefault(Class tClass) { if (tClass.isPrimitive()) { @@ -98,7 +96,11 @@ public final class SerializationBuilder implements Cloneable { if (concreteClass(tClass) && Byteable.class.isAssignableFrom(tClass)) { reader(new ByteableSizedReader<>((Class) tClass)); dataAccess((DataAccess) new ByteableDataAccess<>((Class) tClass)); - sizeMarshaller(constant(((Byteable) OS.memory().allocateInstance(tClass)).maxSize())); + try { + sizeMarshaller(constant(((Byteable) OS.memory().allocateInstance(tClass)).maxSize())); + } catch (InstantiationException e) { + throw new IllegalStateException(e); + } } else if (tClass == CharSequence.class) { reader((SizedReader) CharSequenceSizedReader.INSTANCE); dataAccess((DataAccess) new CharSequenceUtf8DataAccess()); diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/data/ZeroBytesStore.java b/src/main/java/net/openhft/chronicle/map/impl/stage/data/ZeroBytesStore.java index 3d2bd69a0..1e7afa497 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/data/ZeroBytesStore.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/data/ZeroBytesStore.java @@ -23,11 +23,27 @@ import net.openhft.chronicle.core.OS; import org.jetbrains.annotations.Nullable; import java.nio.BufferOverflowException; +import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; public enum ZeroBytesStore implements BytesStore { INSTANCE; + @Override + public int peekUnsignedByte(long offset) { + return 0; + } + + @Override + public int readVolatileInt(long offset) throws BufferUnderflowException { + return 0; + } + + @Override + public boolean isDirectMemory() { + return false; + } + @Override public byte readByte(long offset) { return 0; @@ -63,11 +79,6 @@ public enum ZeroBytesStore implements BytesStore { OS.memory().setMemory(address, size, (byte) 0); } - @Override - public boolean isNative() { - return false; - } - @Override public boolean sharedMemory() { return false;