Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/Xamarin.Android.Tools.Bytecode/ClassPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ public void Load (Stream jarStream, bool leaveOpen = false)

using (var jar = CreateZipArchive (jarStream, leaveOpen)) {
foreach (var entry in jar.Entries) {
if (entry.Length == 0)
if (!ShouldLoadEntry (entry))
continue;
using (var s = entry.Open ()) {
if (!ClassFile.IsClassFile (s) || entry.Name.EndsWith (".jnilib", StringComparison.OrdinalIgnoreCase))
continue;
}

using (var entry_stream = entry.Open ())
using (var s = new BufferedStream (entry_stream)) {
try {
Expand All @@ -86,6 +83,22 @@ public void Load (Stream jarStream, bool leaveOpen = false)
}
}

static bool ShouldLoadEntry (ZipArchiveEntry entry)
{
if (entry.Length == 0)
return false;

if (entry.Name == "module-info.class")
return false;

if (entry.Name.EndsWith (".jnilib", StringComparison.OrdinalIgnoreCase))
return false;

using var s = entry.Open ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of #1092, should this instead use BufferedStream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want it in this case, as we are reading a single value from the Stream and then closing it. If we use BufferedStream it would need to read xKB into the buffer instead of the single 4 byte read.


return ClassFile.IsClassFile (s);
}

static ZipArchive CreateZipArchive (Stream jarStream, bool leaveOpen)
{
var encoding = new UTF8Encoding (encoderShouldEmitUTF8Identifier: false);
Expand Down