Buffers not Serializable in Java?

D

Dagon

Why are Buffers not Serializable in Java?

Wild guess:

Buffers are often used for managing resources outside the Java language, and
it would add a lot of complexity to force all implementations to be able to
freeze and restore their state.

Nothing stops you from writing a subclass that is Serializable.
 
L

Lew

bob said:
Why are Buffers not Serializable in Java?
(One presumes to assume that you refer here to 'java.nio.Buffer'.)

Why should they be?

What would a serialized 'Buffer' mean, exactly?

A 'Buffer' is a holder for serialized data already, is it not?

It's sort of like serializing a Reader or a Writer. It boils down to what one considers state for the type.

Anyway, 'Buffer' is intended as a staging area between things, a conduit for serialization. You would simply transmit the contents of the 'Buffer'.

Now one gives you the benefit of the doubt that you really want to serialize one of the subtypes of 'Buffer', since you can't instantiate an abstract class.

Near as I can tell, you can quite readily serialize the 'array()' results given back by these subtypes are all serializable, so you're only one method call away.

Now, please answer in return, why in the world do you want to serialize a 'Buffer'?
 
R

Roedy Green

Why are Buffers not Serializable in Java?

Are not buffers usually associated with a file? How could the frozen
Buffer capture enough so that if it were thawed in some other computer
it would behave anything like the original?
--
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top