Java Byte interpretation on 10.0.0.2595

bugs://85484 got closed with status fixed.

Is it possible to get a night build for testing this issue? It’s a big stopper for us to update and we need to upgrade to the latest stable asap.

sure thing; up.

1 Like

Something is wrong with this build :frowning: :

An unhandled exception of type 'java.lang.VerifyError' occurred in tatukgis.jdk.jar.
Additional information: (class: RemObjects/Elements/RTL/String, method: ToUnicodeCodePoints__$mapped signature: (Ljava/lang/String;)Ljava/util/ArrayList;) Register 6 contains wrong type

Test case :

if 'Windows'.equals('Mac') then ;

An unhandled exception of type 'java.lang.VerifyError' occurred in tatukgis.jdk.jar.
Additional information: (class: RemObjects/Elements/RTL/String, method: UnicodeCodePointBeforeIndex__$mapped__ signature: (Ljava/lang/String;I)I) Register 2 contains wrong type

At least initial Byte-SByte tests passed :slight_smile:

exact same test-case we already have?

? I just created a java console project and wrote :

begin
  if 'Windows'.equals('Mac') then ;
end ;

Further tests report more problems with our global functions and ‘java.lang.VerifyError’

Thanks, logged as bugs://85593

Fixed in 20210223-095633-elements-develop. (uploaded to your Personal Downloads)

1 Like

bugs://85593 got closed with status fixed.

Hi
I made more tests and almost all have passed except two cases. This is for Byte again. Here is a test case :

namespace consoleapplication3;

uses
  java.util;

type
  Program = class
  public
    class method Main(args: array of String): Int32;
    begin
      var b : Byte := -30 ; // read from file
      writeLn(b);
      b := b and $ff ;
      test(b);
    end;

    class method test(_b : Byte);
    begin
      writeLn(_b);
      if (_b > 3) then
        writeLn('ok')
      else
        writeLn('not ok') ;
    end ;
  end;

end.


image

  1. I read a byte from a file (get -30)
  2. Printing this value shows 226, I thought ok, just like the old Byte we have on other platforms
  3. To be sure (this was not in our code before) I masked the value with $ff to get unsigned
  4. Printing this value and the debugger shows 226
  5. Now we get inside a test method, printing _b shows -30 although debugger shows 226 in Watch
  6. The If test fails (-30 > 3) although I expected to pass
  7. Extra test if ((_b and $ff) > 3) passes.

This is strange and inconsistent with other cases I was testing. Can you verify this problem, please? We are so close to solving this issue. I will try to prepare more test cases for another issue I found in our tests.

Thanks, logged as bugs://85630

bugs://85630 got closed with status fixed.

I found another issue and test case to fix (that works on our older build and other platforms) :

namespace consoleapplication18;

uses
  java.util;

type
  Program = class
  public

    class method Main(args: array of String): Int32;
    begin
      testColor;
    end;
    
    class function trunc2byte(_iv : Integer) : Byte ;
      begin
        if _iv > 255 then
          Result := 255
        else if _iv < 0 then
          Result := 0
        else
          Result := _iv and $ff ;
      end ;
      
    class method testColor : Int32;
    begin
      var red, green, blue, alpha : Integer;
      
      red   := 170;
      green := 211;
      blue  := 223;
      alpha := 255;
      
      Result := Integer(trunc2byte(255)) shl 24 ;
      // Result: Int32 = $ffffffffff000000
      Result := Integer(trunc2byte(127)) shl 24 ;
      // Result: Int32 = $7f000000
      Result := Integer(trunc2byte(128)) shl 24 ;
      // Result: Int32 = $ffffffff80000000

      Result := Integer((*$FF and *) trunc2byte(red)) shl 16 ;
      // Result: Int32 = $ffffffffffaa0000
      Result := Result or (Integer((*$FF and *) trunc2byte(green)) shl 8) ;
      Result := Result or (Integer((*$FF and *) trunc2byte(blue))) ;
      Result := Result or (Integer((*$FF and *) trunc2byte(alpha)) shl 24) ;
      
      if Result = -5581857 then // $FFAAD3DF
        writeLn('OK:' + Result)
      else
        writeLn('ERR:'+ Result)
    end;

  end;

end.

trunc2byte should return Byte(0-255) but additionally stores a sign flag that affects shifts :

Result := Integer(trunc2byte(255)) shl 24 ;  // Result: Int32 = $ffffffffff000000
Result := Integer(trunc2byte(127)) shl 24 ;  // Result: Int32 = $7f000000
Result := Integer(trunc2byte(128)) shl 24 ;  // Result: Int32 = $ffffffff80000000

The results are incorrect. We have a lot of similar code that works fine on the older build for Java and other platforms (.net, vcl). The fix is to use $FF and trunc2byte but we don’t want to patch huge projects that work (looking for complex Byte + shifts combinations).
I hope that you can fix this issue as this seems to be the last one of the “Java and Byte problems” that stop us from the upgrade.
Thanks, Artur

Thanks, logged as bugs://85698

bugs://85698 got closed with status fixed.