[armedbear-devel] is there a good method to read/write java byte arrays?
Mark Evenson
evenson at panix.com
Wed Dec 1 16:44:32 UTC 2010
On 3/17/10 5:32 PM, Alessio Stalla wrote:
> On Wed, Mar 17, 2010 at 5:22 PM, Mark Evenson<evenson at panix.com> wrote:
>> On 3/17/10 5:04 PM, Alessio Stalla wrote:
>> […]
>>
>>> I wrote sys::%make-byte-array-output-stream in order to make the
>>> runtime compiler capable of generating bytecode without using
>>> temporary files; it wasn't meant to be used by the ABCL user, and as
>>> such it's not very polished (for example, the type of a
>>> byte-array-output-stream is simply STREAM). In any case, it's defined
>>> in the ByteArrayOutputStream Java class, and as you correctly noted,
>>> it explicitly sets the element type to (unsigned-byte 8). As a quick
>>> and dirty solution, you could more or less copy-paste that class and
>>> replace "output" with "input" :) (as well as update Autoload.java to
>>> make ABCL know of the new primitives).
>>>
>>> We should probably polish it a bit and release it as an extension.
>>
>> Well, at least we should quickly whip out the inverse version so David
>> doesn't have to rely on hacking Stream.java (although I'm not sure when
>> telling Stream that initAsBinaryStream() means a format of unsigned 8bit
>> bytes will fail).
>>
>> I think we can commit to the interface you've implemented in
>> ByteArrayOutputStream, as those are the basic necessary operations.
>>
>> Or maybe I am not seeing what potential problems there would be with
>> this as a short-term strategy, Alessio?
>
> No problem at all in the implementation per se; however, when we'll
> make it an "official" extension, the interface will change (if
> anything, symbols won't probably be in sys anymore and they won't be
> prefixed with %). Since this functionality will have approximately 1
> user in the near future :), I think it's ok to commit a quick fix for
> David. I'm working on it right now.
I'd like to promote the
%make-byte-array-output-stream/%make-byte-array-input-stream functions
to the EXTENSIONS package, as I seem to have needed them at least twice
in different contexts since we introduced them.
@Alessio: are you satisfied with the interface as they stand?
@All: It looks like we just to have finish the insertion in the type
hierarchy or should they continue to be just instances of STREAM? Not
sure what to do here.
After finishing the type hierarchy, I would merely make a Lisp stub in
EXTENSIONS for now for MAKE-BYTE-ARRAY-OUTPUT-STREAM,
MAKE-BYTE-ARRAY-INPUT-STREAM, GET-OUTPUT-STREAM-BYTES external symbols.
--
"A screaming comes across the sky. It has happened before, but there
is nothing to compare to it now."
More information about the armedbear-devel
mailing list