You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[class-parse] Ignore .jnilib files within .jar files (#890)
Fixes: #860
Context: https://bugs.openjdk.java.net/browse/JDK-8127215
A long time ago (2002-ish?), the custom Java distributed on Mac OS X
required that native libraries containing JNI code have a `.jnilib`
file extension, apparently as part of [Java Web Start][0]:
> Java Web Start: Mac OS X Details:
> …
> * Native libraries must be in JARs and end in .jnilib
This was supported up through Apple Java 6.
Some types of support for the `.jnilib` extension was
[removed in OpenJDK 7][1], but `.jar` files containing `.jnilib`
entries can still be found, e.g. in the [`jna-4.5.1.jar` file][2]:

Additionally, `.jnilib` files contain a `0xCAFEBABE` file header, as
found in `.class` files, but it's not a Java `.class` file: it's
otherwise a Mac OS X `.dylib` file:
% hexdump -C com/sun/jna/darwin/libjnidispatch.jnilib | head -1
00000000 ca fe ba be 00 00 00 02 00 00 00 07 00 00 00 03 |................|
% objdump -h com/sun/jna/darwin/libjnidispatch.jnilib
Sections:
Idx Name Size VMA Type
0 __text 0000d3de 0000000000000dc0 TEXT
1 __stubs 000000de 000000000000e19e TEXT
…
Trying to parse a `.jar` file containing such a `.jnilib` entry
results in an `ArgumentOutOfRangeException`:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Xamarin.Android.Tools.Bytecode.AttributeInfo.CreateFromStream(ConstantPool constantPool, Stream stream)
Fix this error by ignoring `.jnilib` files found within a `.jar`.
[0]: https://ia903107.us.archive.org/16/items/Wwdc2002DvdSet/WWDC_2002/PDFs/400/403.pdf
[1]: https://bugs.openjdk.java.net/browse/JDK-8127215
[2]: http://www.java2s.com/example/jar/j/download-jna451jar-file.html
0 commit comments