Buggy code:
public final class ClassStreamHandler { private static Unsafe unsafe ; private static Map handlesClasses = new HashMap ( ) ; private static short classCounter = 0 ; private class FieldAndIndex { Field field ; long index ; FieldAndIndex ( Field field , long index ) { } } private static final ReflectionFactory reflFactory = ( ( ReflectionFactory ) ( AccessController . doPrivileged ( new ReflectionFactory . GetReflectionFactoryAction ( ) ) ) ) ; public static final byte HANDLE = 1 ; public static final byte NULL = 0 ; public static final byte CLASS_DEF = 2 ; public static final byte ARRAY = 3 ; public static final byte PRIMITIVE_ARRAY = 4 ; public static final int CLASS = 5 ; static ClassStreamHandler lookup ( Class cls ) { } static ClassStreamHandler lookup ( short s ) { } private final Class clz ; private final List fields ; private final short classId ; private Constructor cons ; private List writeObjectMethod ; private List readObjectMethod ; private ClassStreamHandler ( Class cls ) { } public Class getStreamClass ( ) { } private void fillFields ( Class cls ) { } private static Method getPrivateMethod ( Class cl , String name , Class [ ] argTypes , Class returnType ) { } public void writeFields ( WicketObjectOutputStream woos , Object obj ) { try { for ( int i = 0 ; i < ( fields . size ( ) ) ; i ++ ) { ClassStreamHandler . FieldAndIndex fai = ( ( ClassStreamHandler . FieldAndIndex ) ( fields . get ( i ) ) ) ; Field field = fai . field ; Object value = field . get ( obj ) ; if ( value instanceof Boolean ) { woos . getOutputStream ( ) . writeBoolean ( ( ( Boolean ) ( value ) ) . booleanValue ( ) ) ; continue ; } else if ( value instanceof Byte ) { woos . getOutputStream ( ) . writeByte ( ( ( Byte ) ( value ) ) . intValue ( ) ) ; continue ; } else if ( value instanceof Short ) { woos . getOutputStream ( ) . writeShort ( ( ( Short ) ( value ) ) . intValue ( ) ) ; continue ; } else if ( value instanceof Character ) { woos . getOutputStream ( ) . writeChar ( ( ( Character ) ( value ) ) . charValue ( ) ) ; continue ; } else if ( value instanceof Integer ) { woos . getOutputStream ( ) . writeInt ( ( ( Integer ) ( value ) ) . intValue ( ) ) ; continue ; } else if ( value instanceof Long ) { <START_BUG> woos . getOutputStream ( ) . writeLong ( ( ( Long ) ( value ) ) . intValue ( ) ) ; <END_BUG> continue ; } else if ( value instanceof Float ) { woos . getOutputStream ( ) . writeFloat ( ( ( Float ) ( value ) ) . floatValue ( ) ) ; continue ; } else if ( value instanceof Double ) { woos . getOutputStream ( ) . writeDouble ( ( ( Double ) ( value ) ) . doubleValue ( ) ) ; continue ; } else { woos . writeObject ( value ) ; } } } catch ( IllegalArgumentException ex ) { throw new RuntimeException ( ex ) ; } catch ( IllegalAccessException ex ) { throw new RuntimeException ( ex ) ; } catch ( IOException ex ) { throw new RuntimeException ( ex ) ; } } public short getClassId ( ) { } public Object createObject ( ) throws IllegalAccessException , IllegalArgumentException , InstantiationException , InvocationTargetException { } public void readFields ( WicketObjectInputStream wois , Object object ) { } private static Constructor getSerializableConstructor ( Class cl ) { } private static boolean packageEquals ( Class cl1 , Class cl2 ) { } private static String getPackageName ( Class cl ) { } public boolean invokeWriteMethod ( WicketObjectOutputStream woos , Object obj ) { } public boolean invokeReadMethod ( WicketObjectInputStream wois , Object obj ) { } }

Fix:
woos . getOutputStream ( ) . writeLong ( ( ( Long ) ( value ) ) . longValue ( ) ) ;