diff options
author | Tom Tromey <tromey@cygnus.com> | 2000-11-27 04:05:23 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-11-27 04:05:23 +0000 |
commit | 2721806e9811dee451f847eba2e9655979ad4065 (patch) | |
tree | cb35dd525aae041b32949744d19afafd5d184626 /libjava/prims.cc | |
parent | 18205ca3b63fa0536ce6db35b4f1e264bdda5276 (diff) | |
download | gcc-2721806e9811dee451f847eba2e9655979ad4065.zip gcc-2721806e9811dee451f847eba2e9655979ad4065.tar.gz gcc-2721806e9811dee451f847eba2e9655979ad4065.tar.bz2 |
prims.cc (_Jv_NewObjectArray): Use const_cast to initialize length field of array.
* prims.cc (_Jv_NewObjectArray): Use const_cast to initialize
length field of array.
(_Jv_NewPrimArray): Likewise.
* gcj/array.h (__JArray): `length' field now const. Added
constructor.
From-SVN: r37771
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r-- | libjava/prims.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc index b6ac7f8..c6b8d20 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -411,8 +411,10 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) obj = (jobjectArray) _Jv_AllocArray (size, klass); if (__builtin_expect (! obj, false)) JvThrow (no_memory); - obj->length = count; - jobject *ptr = elements (obj); + // Cast away const. + jsize *lp = const_cast<jsize *> (&obj->length); + *lp = count; + jobject *ptr = elements(obj); // We know the allocator returns zeroed memory. So don't bother // zeroing it again. if (init) @@ -446,7 +448,9 @@ _Jv_NewPrimArray (jclass eltype, jint count) __JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count, klass); if (__builtin_expect (! arr, false)) JvThrow (no_memory); - arr->length = count; + // Cast away const. + jsize *lp = const_cast<jsize *> (&arr->length); + *lp = count; // Note that we assume we are given zeroed memory by the allocator. return arr; |