From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13058 invoked by alias); 3 Oct 2009 04:30:31 -0000 Received: (qmail 13045 invoked by uid 22791); 3 Oct 2009 04:30:30 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-qy0-f196.google.com (HELO mail-qy0-f196.google.com) (209.85.221.196) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 03 Oct 2009 04:30:24 +0000 Received: by qyk34 with SMTP id 34so1395121qyk.14 for ; Fri, 02 Oct 2009 21:30:23 -0700 (PDT) Received: by 10.224.52.138 with SMTP id i10mr1778518qag.38.1254544223210; Fri, 02 Oct 2009 21:30:23 -0700 (PDT) Received: from quillintosh.local (c-6106e055.1135-1-64736c21.cust.bredbandsbolaget.se [85.224.6.97]) by mx.google.com with ESMTPS id 2sm529756qwi.28.2009.10.02.21.30.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 02 Oct 2009 21:30:22 -0700 (PDT) Message-ID: <4AC6D35A.5020608@gmail.com> Date: Sat, 03 Oct 2009 04:30:00 -0000 From: Erik Larsson User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: java@gcc.gnu.org Subject: Re: ByteBuffer.asReadOnlyBuffer() and direct byte buffers References: <4AC0208F.2040109@gmail.com> In-Reply-To: <4AC0208F.2040109@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-10/txt/msg00009.txt.bz2 Hi, Should I report this somewhere else? - Erik Erik Larsson wrote: > Hi group, > > In the process of trying to run my JNI-enabled library in gcj/gij I > discovered what seems to be a bug in libgcj's direct ByteBuffer > implementation. > > When calling ByteBuffer.asReadOnlyBuffer() for a direct byte buffer, > gij throws at me: > ------ > Exception in thread "main" java.nio.InvalidMarkException > at java.nio.Buffer.reset(libgcj.so.10) > at java.nio.DirectByteBufferImpl.duplicate(libgcj.so.10) > at java.nio.DirectByteBufferImpl.asReadOnlyBuffer(libgcj.so.10) > at Test.main(Test.java:18) > ------ > > Test code is attached. The InvalidMarkException goes away if you call > ByteBuffer.mark() before calling .asReadOnlyBuffer(), but > .asReadOnlyBuffer() shouldn't require a defined mark (it doesn't for > regular buffers). > > gij version: > ------ > gij (GNU libgcj) version 4.4.1 > > Copyright (C) 2007 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There > is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR > PURPOSE. > ------ > > OS: Ubuntu 9.10 (prerelease), i386 > > I did a little research, and it seems this bug was reported against > Classpath in 2005, along with a fix: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22934 > > The GNU Classpath code contains what seems to be a fix in the current > revision of DirectByteBufferImpl (duplicate() method): > > http://cvs.savannah.gnu.org/viewvc/classpath/java/nio/DirectByteBufferImpl.java?revision=1.24&root=classpath&view=markup > > > ...but gcc's libjava doesn't have that particular line ('if (this.mark > != -1)'): > > http://gcc.gnu.org/viewcvs/trunk/libjava/java/nio/DirectByteBufferImpl.java?revision=141271&view=markup > > > Regards, > > - Erik