RFR: 8293971: Loading new Media from resources can sometimes fail when loading from FXML

Alexander Matveev almatvee at openjdk.org
Mon Sep 26 23:01:38 UTC 2022


On Mon, 26 Sep 2022 15:14:46 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> There was two problems:
>>  - uri.getPath() was returning null for jar URI, since it is not a standard URI and thus we did not detect file type based on extension.
>>  - Our signature detection for MP3 had a bug and did not detect MP3 correctly. See comments in code.
>>  
>> Fixed by adding function to extract file name from jar URI and also signature detection was fixed for MP3.
>
> modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/MediaUtils.java line 154:
> 
>> 152:         } else if ((buf[0] & 0xff) == 0xff && (buf[1] & 0xe0) == 0xe0 && // sync
>> 153:                 (buf[1] & 0x18) != 0x08 && // not reserved version
>> 154:                 (buf[1] & 0x06) != 0x00) { // not reserved layer
> 
> thank you for providing a descriptive comment!
> 
> I wonder if, in the future, when the list of supported formats grows, we ought to invent some kind of Bit(input)Stream class that would make operating on bit fields easier?

I think we can use java.util.BitSet. We can define BitSet for headers and then use intersects to see if bits are set, but it will be out of scope for this issue.

-------------

PR: https://git.openjdk.org/jfx/pull/902


More information about the openjfx-dev mailing list