Loading tools/protologtool/src/com/android/protolog/tool/ProtoLogTool.kt +6 −3 Original line number Original line Diff line number Diff line Loading @@ -39,8 +39,7 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.Executors import java.util.jar.JarOutputStream import java.util.jar.JarOutputStream import java.util.zip.ZipEntry import java.util.zip.ZipEntry import kotlin.math.abs import kotlin.math.absoluteValue import kotlin.random.Random import kotlin.system.exitProcess import kotlin.system.exitProcess object ProtoLogTool { object ProtoLogTool { Loading Loading @@ -72,7 +71,11 @@ object ProtoLogTool { } } private fun processClasses(command: CommandOptions) { private fun processClasses(command: CommandOptions) { val generationHash = abs(Random.nextInt()) // A deterministic hash based on the group jar path and the source files we are processing. // The hash is required to make sure different ProtoLogImpls don't conflict. val generationHash = (command.javaSourceArgs.toTypedArray() + command.protoLogGroupsJarArg) .contentHashCode().absoluteValue // Need to generate a new impl class to inject static constants into the class. // Need to generate a new impl class to inject static constants into the class. val generatedProtoLogImplClass = val generatedProtoLogImplClass = "com.android.internal.protolog.ProtoLogImpl_$generationHash" "com.android.internal.protolog.ProtoLogImpl_$generationHash" Loading Loading
tools/protologtool/src/com/android/protolog/tool/ProtoLogTool.kt +6 −3 Original line number Original line Diff line number Diff line Loading @@ -39,8 +39,7 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.Executors import java.util.jar.JarOutputStream import java.util.jar.JarOutputStream import java.util.zip.ZipEntry import java.util.zip.ZipEntry import kotlin.math.abs import kotlin.math.absoluteValue import kotlin.random.Random import kotlin.system.exitProcess import kotlin.system.exitProcess object ProtoLogTool { object ProtoLogTool { Loading Loading @@ -72,7 +71,11 @@ object ProtoLogTool { } } private fun processClasses(command: CommandOptions) { private fun processClasses(command: CommandOptions) { val generationHash = abs(Random.nextInt()) // A deterministic hash based on the group jar path and the source files we are processing. // The hash is required to make sure different ProtoLogImpls don't conflict. val generationHash = (command.javaSourceArgs.toTypedArray() + command.protoLogGroupsJarArg) .contentHashCode().absoluteValue // Need to generate a new impl class to inject static constants into the class. // Need to generate a new impl class to inject static constants into the class. val generatedProtoLogImplClass = val generatedProtoLogImplClass = "com.android.internal.protolog.ProtoLogImpl_$generationHash" "com.android.internal.protolog.ProtoLogImpl_$generationHash" Loading