Metadata change way as mentioned by mojo-chan is not reliable, because JPEG decoder is not obligated to respect metadata.
Lossless rotation of the JPEG data is always reliable, provided the image dimensions meet certain criteria (divisible by 16 should always work, divisible by 8 in some cases as well).
Moderate file size change after lossless rotation (depending on entropy coding method) is normal!
This is because the final lossless entropy coding stage sees different data order after rearrangement of data for rotation.
This is similar to text compression with zip: Rearrange words or letters in a text and you get different compressed file size, because compression depends on data order.
More puzzling:
Even the decoded pixels of a losslessly rotated JPEG image may not match with rearrangement, because also the lossy parts of the decoding process depend on data order.
All what the JPEG lossless rotation feature promises is data match after applying the reverse operation on the JPEG data, internally represented as DCT (Discrete Cosine Transform) coefficients.
This is important to know if you want to verify lossless rotation by decoded pixel comparison: First reverse the operation on the JPEG file, then compare the decoded pixels (with the same decoder!). Do not decode the original and rotated files and then rotate the pixel image. Need not match.
Regards
Guido
JPEG developer