Author Topic: Java debugger and byte array  (Read 351 times)

rjpontefract

  • Senior Community Member
  • Posts: 247
  • Hero Points: 9
Java debugger and byte array
« on: November 14, 2023, 03:16:44 AM »
Using SE 28 on macOS 14.
I was trying to debug code that involved a SHA512 hash that was encoded as BASE64URL.  The code is:
   
       
Code: [Select]
public static void main(String[] args) throws Exception
{
String digest = "2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I87V4Lo8BdCxaA307H0HYkAw";
byte[] digestBytes = Base64.getUrlDecoder().decode(digest);

System.out.println("Digest = " + digest);
System.out.println("DigestBytes = ");
System.out.println(hexDump(digestBytes));
}

The output is as follows:

Code: [Select]
Digest = 2qKVvu1OLulMJAFbVq9ia08h759E8rPUD8QckJAKa_G0hnxDxXzaVNG2_Uhps_I87V4Lo8BdCxaA307H0HYkAw

DigestBytes =
0000  DA A2 95 BE ED 4E 2E E9 4C 24 01 5B 56 AF 62 6B   .....N..L$.[V.bk
0010  4F 21 EF 9F 44 F2 B3 D4 0F C4 1C 90 90 0A 6B F1   O!..D.........k.
0020  B4 86 7C 43 C5 7C DA 54 D1 B6 FD 48 69 B3 F2 3C   ..|C.|.T...Hi..<
0030  ED 5E 0B A3 C0 5D 0B 16 80 DF 4E C7 D0 76 24 03   .^...]....N..v$.

Which is the correct value when decoded.

If I put a breakpoint in SE and look at digestBytes in the locals window, I see a different value (attached screen capture). 

Either I'm doing something stupid or SE is displaying the wrong value.  FWIW it does the same thing with the same values on Windows.  Please can you enlighten me?



Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6688
  • Hero Points: 514
Re: Java debugger and byte array
« Reply #1 on: November 14, 2023, 01:45:16 PM »
If you switch to Decimal output, then you will see sane values. Hexadecimal output seems odd for negative integer types. We will look into this.
« Last Edit: November 14, 2023, 02:06:25 PM by Clark »

rjpontefract

  • Senior Community Member
  • Posts: 247
  • Hero Points: 9
Re: Java debugger and byte array
« Reply #2 on: November 14, 2023, 05:44:37 PM »
Thanks for the reply.  It would be handy to see them in hexadecimal so I hope you can find a fix.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6688
  • Hero Points: 514
Re: Java debugger and byte array
« Reply #3 on: November 14, 2023, 10:07:17 PM »
I’ve checked in a fix for this. this was not hot fixable. The fix will be in 28.0.1. No date set yet. This is a very old issue. I’m surprised nobody noticed until now. This issue is also in the GDB debugger used for debugging C++.

rjpontefract

  • Senior Community Member
  • Posts: 247
  • Hero Points: 9
Re: Java debugger and byte array
« Reply #4 on: November 14, 2023, 11:34:08 PM »
Is there any chance of a preview build for Windows 64 bit?  It would make my current life much easier!

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6688
  • Hero Points: 514
Re: Java debugger and byte array
« Reply #5 on: November 15, 2023, 03:03:59 PM »
Some extra testing would be nice. This isn't 28.0.1. It simply a slightly newer 28.0.0.6

https://drive.google.com/drive/folders/1gjR08T_K0j6IQpHo0wRkFR_tV-3MQ8mO?usp=sharing

rjpontefract

  • Senior Community Member
  • Posts: 247
  • Hero Points: 9
Re: Java debugger and byte array
« Reply #6 on: November 15, 2023, 08:14:31 PM »
Hi Clark, thanks for the new version, initial testing shows that it's now working correctly.  I'll let you know if anything bad happens, but it all looks OK so far.

rjpontefract

  • Senior Community Member
  • Posts: 247
  • Hero Points: 9
Re: Java debugger and byte array
« Reply #7 on: November 23, 2023, 02:38:52 AM »
As a quality of life improvement, would it possible to add leading zeroes to the hex output so that single digit values are not handled differently?


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6688
  • Hero Points: 514
Re: Java debugger and byte array
« Reply #8 on: November 23, 2023, 03:12:45 PM »
I don't follow. Please provide an example.

rjpontefract

  • Senior Community Member
  • Posts: 247
  • Hero Points: 9
Re: Java debugger and byte array
« Reply #9 on: November 23, 2023, 06:52:56 PM »
Here's an example:

Code: [Select]
     
digestBytes        byte[] (32 items)
        [0]             0x36
        [1]             0x3
        [2]             0xF
        [3]             0xCC
        [4]             0x7E
        [5]             0x56

It would be helpful if it was:

Code: [Select]
     
digestBytes        byte[] (32 items)
        [0]             0x36
        [1]             0x03
        [2]             0x0F
        [3]             0xCC
        [4]             0x7E
        [5]             0x56




Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6688
  • Hero Points: 514
Re: Java debugger and byte array
« Reply #10 on: November 23, 2023, 08:51:25 PM »
Thanks. Change checked in.

rjpontefract

  • Senior Community Member
  • Posts: 247
  • Hero Points: 9
Re: Java debugger and byte array
« Reply #11 on: November 23, 2023, 08:56:28 PM »
Awesome, thanks!
I copy and paste the output to another application that needs the leading zero, so this will save me a tedious step adding the leading zeroes manually.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6688
  • Hero Points: 514
Re: Java debugger and byte array
« Reply #12 on: November 24, 2023, 01:45:07 PM »

rjpontefract

  • Senior Community Member
  • Posts: 247
  • Hero Points: 9
Re: Java debugger and byte array
« Reply #13 on: November 26, 2023, 08:49:08 PM »
Thanks Clark, it's much appreciated, the new version works great.