Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 2706 invoked from network); 22 May 2007 09:35:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 May 2007 09:35:38 -0000 Received: (qmail 77110 invoked by uid 500); 22 May 2007 09:35:43 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 77089 invoked by uid 500); 22 May 2007 09:35:43 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 77080 invoked by uid 99); 22 May 2007 09:35:43 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 May 2007 02:35:43 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 May 2007 02:35:36 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id B6D53714057 for ; Tue, 22 May 2007 02:35:16 -0700 (PDT) Message-ID: <31708948.1179826516746.JavaMail.jira@brutus> Date: Tue, 22 May 2007 02:35:16 -0700 (PDT) From: "Mikhail Markov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-2417) [classlib][nio] java.nio.MappedByteBuffer.isLoaded() returns true while RI returns false In-Reply-To: <8186488.1165236441141.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-2417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12497774 ] Mikhail Markov commented on HARMONY-2417: ----------------------------------------- I also could not reproduce this issue - it prints the same output both on RI & Harmony on my Linux. +1 to close this issue. > [classlib][nio] java.nio.MappedByteBuffer.isLoaded() returns true while RI returns false > ---------------------------------------------------------------------------------------- > > Key: HARMONY-2417 > URL: https://issues.apache.org/jira/browse/HARMONY-2417 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Artem Aliev > Priority: Minor > > According to J2SE API specifications of java.nio.MappedByteBuffer class > public final boolean isLoaded() > Tells whether or not this buffer's content is resident in physical memory. > A return value of true implies that it is highly likely that all of the > data in this buffer is resident in physical memory and may therefore be > accessed without incurring any virtual-memory page faults or I/O > operations. A return value of false does not necessarily imply that the > buffer's content is not resident in physical memory. > The returned value is a hint, rather than a guarantee, because the > underlying operating system may have paged out some of the buffer's data by > the time that an invocation of this method returns. > Returns: > true if it is likely that this buffer's content is resident in physical > memory > When some MappedByteBuffer was created by FaileChannel.map(...) method then > all bytes from the file are put to the buffer but > MappedByteBuffer.isloaded() returns on Harmony different results on Windows > and Linux. > This method returns: > - On Harmony: false on Windows and true - on Linux > - On RI: always returns false (on Windows and Linux) > Code for reproducing: > ---------------------HT.java-------------- > import java.nio.*; > import java.nio.channels.*; > import java.io.*; > import junit.framework.TestCase; > public class HT extends TestCase { > public void testMap() { > File tempFile = new File("./", "tempFile.txt"); > tempFile.deleteOnExit(); > String testString = "1234567890 - Proba pera"; > try { > FileOutputStream fos = new FileOutputStream(tempFile); > for (int i = 0; i < testString.length(); i++) { > fos.write(testString.charAt(i)); > } > fos.close(); > } catch (IOException e) { > e.printStackTrace(); > fail("Unexpected error on file initialization"); > } > FileInputStream fis = null; > MappedByteBuffer mappedBuf = null; > int fileLength = 0; > try { > fis = new FileInputStream(tempFile); > } catch (FileNotFoundException e) { > e.printStackTrace(); > fail("Unexpected exception: Can't open file"); > } > FileChannel channel = fis.getChannel(); > try { > fileLength = (int) channel.size(); > mappedBuf = channel.map(FileChannel.MapMode.READ_ONLY, 0, > fileLength); > } catch (IOException e) { > e.printStackTrace(); > fail("Unexpected exception: "+e ); > } > System.out.println("File length: "+fileLength+" Buf capacity: > "+mappedBuf.capacity()); > if (fileLength != mappedBuf.capacity()) { > fail("Incorrect capacity"); > } > for (int i = 0; i < fileLength; i++) { > int c1 = mappedBuf.get(); > int c2 = (int)testString.charAt(i); > if (c1 != c2) { > System.out.println("Incorrect char ("+i+") : "+c1 +" must be: > "+c2); > return; > } > } > System.out.println("File and Buffer contain the same chars"); > System.out.println("isLoaded(): "+mappedBuf.isLoaded()); > } > } > --------------------------------------- > Steps to Reproduce: > Create HT class and run it > java -cp .:junit.jar junit.textui.TestRunner HT > Output: > - On Linux (RI) > java version "1.5.0" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64) > BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-linux-ia32, R25.0.0-75, > GC: System optimized over throughput (initial strategy singleparpar)) > .File length: 23 Buf capacity: 23 > File and Buffer contain the same chars > isLoaded(): false > Time: 0.037 > OK (1 test) > - On Linux (Harmony) > Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software > Foundation or its licensors, as applicable. > java version "1.5.0" > pre-alpha : not complete or compatible > svn = rsvn: '.' is not a working copy, (Sep 26 2006), Linux/ia32/gcc 3.3.3, > release build > http://incubator.apache.org/harmony > .File length: 23 Buf capacity: 23 > File and Buffer contain the same chars > isLoaded(): true > F > Time: 0.029 > There was 1 failure: > 1) testMap(HT)junit.framework.AssertionFailedError: isLoaded() > at HT.testMap(HT.java:60) > at java.lang.reflect.VMReflection.invokeMethod(Native Method) > FAILURES!!! > Tests run: 1, Failures: 1, Errors: 0 > Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software > Foundation or its licensors, as applicable. > .File length: 23 Buf capacity: 23 > File and Buffer contain the same chars > isLoaded(): true > F > Time: 0.015 > There was 1 failure: > 1) testMap(HT)junit.framework.AssertionFailedError: isLoaded() > at HT.testMap(HT.java:60) > at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25) > FAILURES!!! > Tests run: 1, Failures: 1, Errors: 0 > - On Windows ( RI ) > java version "1.5.0_06" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) > Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode) > .File length: 23 Buf capacity: 23 > File and Buffer contain the same chars > isLoaded(): false > Time: 0.032 > OK (1 test) > - On Windows (Harmony) > Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software > Foundation or its l > icensors, as applicable. > java version "1.5.0" > pre-alpha : not complete or compatible > svn = rsvn: '.' is not a working copy, (Sep 26 2006), Windows/ia32/msvc 1310, > release buil > d > http://incubator.apache.org/harmony > .File length: 23 Buf capacity: 23 > File and Buffer contain the same chars > isLoaded(): false > Time: 0.031 > OK (1 test) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.