-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #3549: Load .tasty from jar if necessary #3550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3549: Load .tasty from jar if necessary #3550
Conversation
Array.empty | ||
} | ||
} | ||
val tastyBytes = classfile match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose something along the line of:
val tastyBytes = classfile.underlyingSource match {
case None =>
??? // virtual file?
case Some(jar: ZipArchive) => // We are in a jar
val jarArchive = JarArchive.open(File(jar.jpath))
val tastyFile = File(jarFile.jpath).resolve(classfile.name).changeExtension("tasty")
val bytes = readBytes(tastyFile)
jarArchive.close()
bytes
case _ =>
readBytes(File(classfile.jpath).changeExtension("tasty"))
}
It's weird to pattern match on FileZipArchive#LeakyEntry
. This is internal implementation detail, should probably be private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also can you add a comment: // TODO: simplify when #3552 is fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the code snippet: underlyingSource
seems to return None
only for virtual files. In the case there is no underlyingSource
, we cannot do anything...
if (attrLen == 0) { // A tasty attribute implies the existence of the .tasty file | ||
def readBytes(file: io.Path): Array[Byte] = { | ||
val plainFile = new PlainFile(file) | ||
if (plainFile.exists) new AbstractFileReader(plainFile).nextBytes(plainFile.sizeOption.get) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is toByteArray
defined on AbstractFile
912ff90
to
f8cc80a
Compare
f8cc80a
to
df9a82d
Compare
df9a82d
to
4774922
Compare
No description provided.