|
From: <sp...@us...> - 2011-07-12 13:44:19
|
Revision: 3572
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3572&view=rev
Author: spasi
Date: 2011-07-12 13:44:13 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Fixed bounds checking to work with .sliced mapped objects.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
Modified: trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-12 13:29:04 UTC (rev 3571)
+++ trunk/LWJGL/src/java/org/lwjgl/test/mapped/MappedObjectTests1.java 2011-07-12 13:44:13 UTC (rev 3572)
@@ -89,17 +89,34 @@
vecs.view = 0;
}
- // test bound check
+ // test bounds checking
{
assert (vecs.view == 0);
try {
+ vecs.view = 49;
+ assert vecs.view == 49;
+ vecs.view = 0;
vecs.view = 50;
System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
vecs.view = 0;
} catch (IndexOutOfBoundsException e) {
// expected, ignore
}
+
assert (vecs.view == 0);
+
+ try {
+ vecs.view = 10;
+ MappedFloat vecs2 = vecs.slice();
+ vecs.view = 0;
+
+ vecs2.view = 39;
+ assert vecs2.view == 39;
+ vecs2.view = 40;
+ System.out.println("org.lwjgl.util.mapped.Checks is false or there is a bug in bounds checking.");
+ } catch (IndexOutOfBoundsException e) {
+ // expected, ignore
+ }
}
// test dup
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 13:29:04 UTC (rev 3571)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObject.java 2011-07-12 13:44:13 UTC (rev 3572)
@@ -97,7 +97,7 @@
}
final void checkAddress(final long address) {
- if ( preventGC.capacity() < (address + stride - baseAddress) )
+ if ( preventGC.capacity() < (address - MappedObjectUnsafe.getBufferBaseAddress(preventGC) + stride) )
throw new IndexOutOfBoundsException();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|