[New IC] Optimize Java class snapshotting with ASM ClassWriter
To snapshot a Java class (+ its fields and methods), previously we used
Gson to serialize a class field/method to a string via reflection, and
hash that string.
We now use an ASM ClassWriter to write a placeholder class containing
the field/method of interest and hash the bytecode of that class.
One experiment showed that this new approach is ~10 times faster than
the previous approach (140s down to 16s when snapshotting 600 jars).
Test: Updated expectation files for JavaClassSnapshotterTest unit tests
+ Existing integration tests to prevent regression
^KT-52141 In Progress
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@
|
||||
},
|
||||
"local": false
|
||||
},
|
||||
"classAbiHash": 2419143040117344894,
|
||||
"classAbiHash": -6515999856905133685,
|
||||
"supertypes": [
|
||||
{
|
||||
"internalName": "java/lang/Object"
|
||||
|
||||
+5
-9
@@ -12,30 +12,26 @@
|
||||
},
|
||||
"local": false
|
||||
},
|
||||
"classAbiHash": 7253633932031152470,
|
||||
"classAbiHash": -6515999856905133685,
|
||||
"classMemberLevelSnapshot": {
|
||||
"classAbiExcludingMembers": {
|
||||
"abiValue": "{\n \"version\": 52,\n \"access\": 33,\n \"name\": \"com/example/SimpleClass\",\n \"superName\": \"java/lang/Object\",\n \"interfaces\": [],\n \"sourceFile\": \"SimpleClass.java\",\n \"innerClasses\": [],\n \"fields\": [],\n \"methods\": [],\n \"api\": 589824\n}",
|
||||
"name": "com/example/SimpleClass",
|
||||
"abiHash": -1986494095366785349
|
||||
"abiHash": 8734303838782665320
|
||||
},
|
||||
"fieldsAbi": [
|
||||
{
|
||||
"abiValue": "{\n \"access\": 1,\n \"name\": \"publicField\",\n \"desc\": \"Ljava/lang/String;\",\n \"api\": 589824\n}",
|
||||
"name": "publicField",
|
||||
"abiHash": 1021768301411937004
|
||||
"abiHash": 8370167348140025367
|
||||
}
|
||||
],
|
||||
"methodsAbi": [
|
||||
{
|
||||
"abiValue": "{\n \"access\": 1,\n \"name\": \"\\u003cinit\\u003e\",\n \"desc\": \"()V\",\n \"exceptions\": [],\n \"visibleAnnotableParameterCount\": 0,\n \"invisibleAnnotableParameterCount\": 0,\n \"instructions\": {\n \"size\": 0\n },\n \"tryCatchBlocks\": [],\n \"maxStack\": 0,\n \"maxLocals\": 0,\n \"localVariables\": [],\n \"visited\": false,\n \"api\": 589824\n}",
|
||||
"name": "\u003cinit\u003e",
|
||||
"abiHash": 5725188035643409224
|
||||
"abiHash": 2413123887428571534
|
||||
},
|
||||
{
|
||||
"abiValue": "{\n \"access\": 1,\n \"name\": \"publicMethod\",\n \"desc\": \"()Ljava/lang/String;\",\n \"exceptions\": [],\n \"visibleAnnotableParameterCount\": 0,\n \"invisibleAnnotableParameterCount\": 0,\n \"instructions\": {\n \"size\": 0\n },\n \"tryCatchBlocks\": [],\n \"maxStack\": 0,\n \"maxLocals\": 0,\n \"localVariables\": [],\n \"visited\": false,\n \"api\": 589824\n}",
|
||||
"name": "publicMethod",
|
||||
"abiHash": 8210873051092995586
|
||||
"abiHash": 7574889098198027162
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user