-
Notifications
You must be signed in to change notification settings - Fork 106
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
Support diffing Jar bytecode versions #168
base: trunk
Are you sure you want to change the base?
Conversation
Goooler
commented
Aug 25, 2023
@@ -26,13 +27,14 @@ class Class private constructor( | |||
@JvmName("parse") | |||
fun Input.toClass(): Class { | |||
val reader = ClassReader(toByteArray()) | |||
val bytecodeVersion = reader.readShort(0 + 6) |
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'm not sure how to implement this for Dex files.
@@ -7,6 +7,7 @@ import com.jakewharton.diffuse.io.Input | |||
|
|||
class Jar private constructor( | |||
override val filename: String?, | |||
val bytecodeVersion: Short?, |
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.
Unfortunately I think we're going to drown in nuance here. Jars don't have bytecode versions, classes do. And multiple classes within a jar can have different versions. You can conditionally classload classes based on capabilities and those classes could be compiled for two different versions of Java. There's also the multi-version jar standard which puts classes of different versions into META-INF/versions/N/
. The ordering of the classes in the jar (read: zip) could be effectively random so taking the first class may not be indicative of what the majority of classes were compiled with.
I'm happy to discuss strategies for surfacing this information, but as-is I think this is too simple of an implementation. Note that it probably works for 99.99% of jars, but when it fails it fails in a spectacularly wrong way.
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.
Now I count all the byte code versions in a Jar and filter the most one.