|
Message
From: cvs at opencores.org<cvs@o...>
Date: Tue Dec 18 03:52:25 CET 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/12 18:03:52 Modified: jop/java/target/src/test/debug/io RandomAccessByteArrayOutputStream.java Log: Fixed two bugs on the code which access the object content. If the data include the last byte, an exception was being created, even though it was correct to read the last byte. Fixed also the way bytes are being read, to avoid negative numbers (which don't exactly "work" as expected, with OR and mask operations). Method changed: 140: private synchronized int readBytes(int location, int size) Revision Changes Path 1.2 jop/java/target/src/test/debug/io/RandomAccessByteArrayOutputStream.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/debug/io/RandomAccessByteArrayOutputStream.java.diff?r1=1.1&r2=1.2 (In the diff below, changes in quantity of whitespace are not shown.) Index: RandomAccessByteArrayOutputStream.java =================================================================== RCS file: /cvsroot/paulo/jop/java/target/src/test/debug/io/RandomAccessByteArrayOutputStream.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- RandomAccessByteArrayOutputStream.java 11 Dec 2007 13:17:52 -0000 1.1 +++ RandomAccessByteArrayOutputStream.java 18 Dec 2007 02:52:24 -0000 1.2 @@ -25,6 +25,8 @@ import java.io.IOException; import java.io.OutputStream; +import debug.JopDebugKernel; + /** * RandomAccessByteArrayOutputStream.java * @@ -139,13 +141,18 @@ */ private synchronized int readBytes(int location, int size) { +// JopDebugKernel.debugPrint("Read bytes - Location:"); +// JopDebugKernel.debugPrint(location); +// JopDebugKernel.debugPrint(" Size:"); +// JopDebugKernel.debugPrint(size); int value; int i; - if((size < 1) || (size > 4) || (location + size >= buf.length)) + if((size < 1) || (size > 4) || (location + size > buf.length)) { - throw new ArrayIndexOutOfBoundsException("Wrong location or size! " + location); + throw new ArrayIndexOutOfBoundsException("Wrong location(" + location + + ") or size(" + size + ")!"); } value = 0; @@ -153,10 +160,15 @@ { // the first shift does nothing, but the others do. value <<= 8; - value = value | buf[location]; + // be careful! need to cut the first byte ONLY because the machine + // work with int values (see the next "or"). + value = value | (buf[location] & 0x00ff); location++; } +// JopDebugKernel.debugPrint(" value:"); +// JopDebugKernel.debugPrintln(value); + return value; }
|
 |