Java enums in .2509

Hi
New preview build breaks Java enums compatibility. Now in my projects, I get errors :

(E43) No static member "values" on type "TGIS_Lock"	
(E44) No member "ordinal" on type "TGIS_Lock"	
(E59) Duplicate constructor with same signature "constructor (_val: TGIS_Lock)"	
(E407) No overloaded constructor with these parameters for type "TGIS_Lock", best matching overload is "constructor (_val: TGIS_Lock)"	
(E44) No member "compareTo" on type "TGIS_Lock"	

All these errors refer to simple enum, e.g.

TGIS_Lock = {$IFDEF OXYGENE} public {$ENDIF} (
      None,
      Extent,
      Projection
  ) ;

The current stable release works fine. Are you changing Java enums or it’s just a preview bug?

We changed enums so they work on Java as they do on the other platforms, but IIRC that change was (for now) reverted due to a regression. (But maybe I’m wrong and overlooked the final fix going back in).

Hi

I’ve just checked build .2513 and the change is here. You said that enums should work the same way as on the other platforms, but they don’t. I can resolve errors with ordinal, values, etc. and unify code to .net, but the error with constructor still exists (.net works fine). Here is sample code :

namespace consoleapplication4;

uses
  java.util;

type

  TMyEnum1 = public (
    one,
    two
  ) ;
  
  TMyEnum2 = public (
    one,
    two,
    three
  ) ;
  
  TClass = public class
  public
    constructor Create( _a : TMyEnum1 );
    begin
      
    end;
    constructor Create( _b : TMyEnum2 );
    begin
      
    end;
    constructor Create( _c : Integer );
    begin
      
    end;    
  end;

  Program = class
  public

    class method Main(args: array of String): Int32;
    begin
      var e : TMyEnum1 := TMyEnum1.one;
      var c : TClass := new TClass(e);
    
    end;

  end;

end.

I get errors like :
Duplicate constructor with same signature "constructor (_b: TMyEnum2)
Duplicate constructor with same signature "constructor (_c: Integer)
.

I didn’t set my enums to be of Integer so this is not flags case.
This is a breaking change for us (more than 100 errors in single project) and we cannot update the compiler (previous stable works fine). So if you fix this error, we can unify the code to .net (less defines) and will be happy :slight_smile:

Thanks, logged as bugs://84312

Just to be clear (other than the overloading issue), you are good with the solution of making the enums act exactly the same on all platforms?

bugs://84312 got closed with status fixed.