-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6
-
1.1.6
-
x86
-
windows_nt
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2020691 | 1.2.0 | Deepa Viswanathan | P4 | Resolved | Fixed | 1.2beta4 |
Name: tb29552 Date: 05/18/98
Firstly, let me point out that there is no JDK1.1.6 option
in "Select a product or tool". Secondly let me describe a bug.
In our product we are using a pure static class TSFactory that has
an array of objects (called objects). Various Java objects can be inserted
and deleted from the array. To insert an object one has to call
TSFactory.addJavaObject(Object)
method. This method generates a next available index, checks if it
is within capacity of the objects array, and if not it doubles the
size of the objects array, and finally adds the object given as the
parameter to the array. Here is the code:
static int addJavaObject( Object obj )
{
if (obj == null)
{
throw new RuntimeException( "Depositing null objects in the factory is illegal" );
}
int index;
synchronized (TSFactory.objects)
{
index = TSFactory.indexManager.getIndex();
if (index >= TSFactory.objects.length)
{
int newSize = (TSFactory.incrm > 0)? TSFactory.objects.length + TSFactory.incrm :
TSFactory.objects.length << 1;
Object[] copy = objects;
objects = new Object[newSize];
System.arraycopy(copy, 0, objects, 0, copy.length);
}
if (index >= TSFactory.objects.length)
{
System.out.println("add " + obj.getClass() + " at " + index + "[0, " + (TSFactory.objects.length-1) + "]");
}
TSFactory.objects[index] = obj;
TSFactory.count++;
}
return index;
}/* addJavaObject */
Notice the "if" statement at the end, which checks if the index
is out of bounds and if so it prints the type of the object, the
location at which is was to be added and the current legal range.
While executing the program with JDK1.1.6 and JIT enabled but without
the last "if" we were getting IndexOutOfBoundsException in
TSFactory.objects[index] = obj;
However, with the printout everything works OK, except that we
are observing the following weird behavior:
add class com.tomsawyer.glt.TSPathDigraph at 500[0, 999]
add class com.tomsawyer.glt.TSDList at 1000[0, 1999]
add class com.tomsawyer.glt.TSDList at 2000[0, 3999]
Notice that the "if" thinks the index is out of bounds, since
it directs the code to the printout line. However printing
indicates that everything is OK. The size of the objects array
is initially 500 and it is doubled as soon as we are trying to
add object 500. At that moment JIT does not refresh the value
of the "object.length" field properly. However a printout
causes it to reload it and then the code can progress without
any exceptions being thrown. Next two printouts are associated
with the case when the objects array grows from 1000 to 2000
and then from 2000 to 4000. In each case JIT did not refresh
the value of the length field.
(Review ID: 29220)
======================================================================
- backported by
-
JDK-2020691 JDK1.1.6 JIT caching bug
-
- Resolved
-