Skip to content

Commit

Permalink
fix for gitissue 2
Browse files Browse the repository at this point in the history
  • Loading branch information
RuedigerMoeller committed Mar 26, 2014
1 parent 25e93a5 commit 993f265
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import java.util.zip.ZipFile

apply plugin: 'java'
apply plugin: 'maven'
version="1.53"
version="1.54"

targetCompatibility = 1.7
sourceCompatibility = 1.7
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.ruedigermoeller</groupId>
<artifactId>fst</artifactId>
<version>1.53</version>
<version>1.54</version>

<description>a fast java serialization drop in-replacement + some serialization based utils (Structs, OffHeap Memory)</description>
<url>https://code.google.com/p/fast-serialization/</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public FSTClazzInfo(Class clazz, FSTClazzInfoRegistry infoRegistry, boolean igno
externalizable = false;
cons = FSTUtil.findConstructorForSerializable(clazz);
} else {
throw new RuntimeException("Class "+clazz.getName()+" does not implement Serializable or externalizable");
if (getSer() == null ) {
throw new RuntimeException("Class " + clazz.getName() + " does not implement Serializable or externalizable");
}
}
if ( ! ignoreAnnotations ) {
Predict annotation = (Predict) clazz.getAnnotation(Predict.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package de.ruedigermoeller.serialization.testclasses_old;

import de.ruedigermoeller.serialization.*;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
* Copyright (c) 2012, Ruediger Moeller. All rights reserved.
* <p/>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* <p/>
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
* <p/>
* Date: 26.03.2014
* Time: 21:51
* To change this template use File | Settings | File Templates.
*/
public class IssueGIT2 {

public static void main(String[] args) throws Exception {
ByteBuffer buffer = ByteBuffer.allocate(100);

FSTConfiguration fst = FSTConfiguration.createDefaultConfiguration();
fst.registerSerializer(ByteBuffer.class, new ByteBufferSerializer(), true);

FSTObjectOutput out = fst.getObjectOutput();
out.writeObject(buffer);
System.out.println(out.getWritten());
}

public static class ByteBufferSerializer extends FSTBasicObjectSerializer {

@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo,
FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
ByteBuffer buffer = (ByteBuffer) toWrite;
byte[] array = new byte[buffer.limit()];
buffer.position(0);
buffer.get(array);
out.writeFInt(array.length);
out.write(array);
}

@Override
public Object instantiate(@SuppressWarnings("rawtypes") Class objectClass, FSTObjectInput in,
FSTClazzInfo serializationInfo, FSTClazzInfo.FSTFieldInfo referencee, int streamPositioin) throws IOException,
ClassNotFoundException, InstantiationException, IllegalAccessException {
byte[] array = new byte[in.readFInt()];
in.read(array);
return ByteBuffer.wrap(array);
}

}

}

0 comments on commit 993f265

Please sign in to comment.