# Array of records in Java and assigned()

**URL:** https://talk.remobjects.com/t/array-of-records-in-java-and-assigned/24887
**Category:** Elements
**Tags:** java
**Created:** [June 8, 2021, 5:29pm UTC](https://talk.remobjects.com/t/array-of-records-in-java-and-assigned/24887 "2021-06-08T17:29:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![arturredzko](https://talk.remobjects.com/user_avatar/talk.remobjects.com/arturredzko/32/16908_2.png) [@arturredzko](https://talk.remobjects.com/u/arturredzko)
#### Post date: [June 8, 2021, 5:29pm UTC](https://talk.remobjects.com/t/array-of-records-in-java-and-assigned/24887/1 "2021-06-08T17:29:21Z")

</div>

Hi  
The last stable release (.2629) was working fine with this code :

```auto
namespace consoleapplication22;

uses
  java.util;

type
  T_R nested in T_Obj = record
    public
      Id : Integer ;
  end;
  
  T_Obj = class
    public
      arr : array of T_R;
      arr2 : array of T_R;
    public
      method Init ;
      begin
        arr2 := new T_R[1];
        arr2[0].Id := 1 ;
        // SetLength
        arr := array of T_R(java.lang.reflect.Array.newInstance( typeOf(T_R), 1 )) ;
        if not assigned(arr[0]) then
          arr[0] := new T_R(); // should go here
        arr[0].Id := 1 ;
      end;
  end;
  
  Program = class
  public
    class method Main(args: array of String): Int32;
    begin
      var o := new T_Obj();
      o.Init;
    end;
  end;
end.

```

New stable (2635) fails checking assigned() condition, assuming that arr[0] is allocated and new T\_R() is not needed. The code fails to set arr[0].Id. Declaring T\_R as a class fixes assigned() check.

Is this a bug or a change by design (so we need to change the declaration)?  
Artur

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [June 8, 2021, 6:52pm UTC](https://talk.remobjects.com/t/array-of-records-in-java-and-assigned/24887/2 "2021-06-08T18:52:24Z")

</div>

Hrmm this looks like a regression. Let me create a bug.

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [June 9, 2021, 5:36am UTC](https://talk.remobjects.com/t/array-of-records-in-java-and-assigned/24887/3 "2021-06-09T05:36:38Z")

</div>

This turned out to be an optimization for assigned(x) → true for valuetypes that should never have hit on Cooper. Fixed!
