android-lint-performance-probe icon indicating copy to clipboard operation
android-lint-performance-probe copied to clipboard

"Failed to instrument class." when profiling allocations

Open christiandeange opened this issue 4 years ago • 0 comments

  • Gradle 6.8.3
  • JDK 11.0.9
  • Android Gradle Plugin 4.2.0-alpha12
  • Kotlin 1.4.32

Upon running ./gradlew jvmArgs -Pallocations I'm told to add jvmargs:

Note: using the allocation instrumentation agent (-Pallocations)

***********************************************************************************
Please use the following JVM arguments to instrument a Lint invocation from Gradle.
Be careful to quote the arguments as needed.

-javaagent:/Users/chr/.gradle/caches/modules-2/files-2.1/com.google.code.java-allocation-instrumenter/java-allocation-instrumenter/3.1.0/d0bdc21c5e6404726b102998e44c66a738897905/java-allocation-instrumenter-3.1.0.jar

-agentpath:/Applications/YourKit-Java-Profiler-2020.9.app/Contents/Resources/bin/mac/libyjpagent.dylib=disableall,probebootclasspath=/Users/chr/Development/android-lint-performance-probe/build/libs/lint-performance-probe.jar,probe_on=com.android.tools.probes.LintDetectorStats

Instrumentation results will be printed to console after the Lint analysis is done.
***********************************************************************************

I can verify that all of these files exist, and when I profile lint's CPU usage normally. (ie: without -Pallocations) it works just fine.

Nevertheless, when using these arguments like so:

gw :app:lintRelease -Dorg.gradle.jvmargs="-javaagent:/Users/chr/.gradle/caches/modules-2/files-2.1/com.google.code.java-allocation-instrumenter/java-allocation-instrumenter/3.1.0/d0bdc21c5e6404726b102998e44c66a738897905/java-allocation-instrumenter-3.1.0.jar -agentpath:/Applications/YourKit-Java-Profiler-2020.9.app/Contents/Resources/bin/mac/libyjpagent.dylib=disableall,probebootclasspath=/Users/chr/Development/android-lint-performance-probe/build/libs/lint-performance-probe.jar,probe_on=com.android.tools.probes.LintDetectorStats"

I encounter a stacktrace like so:

Failed to instrument class.
java.lang.IllegalArgumentException
        at com.google.monitoring.runtime.instrumentation.asm.ClassReader.<init>(ClassReader.java:160)
        at com.google.monitoring.runtime.instrumentation.asm.ClassReader.<init>(ClassReader.java:143)
        at com.google.monitoring.runtime.instrumentation.asm.ClassReader.<init>(ClassReader.java:418)
        at com.google.monitoring.runtime.instrumentation.StaticClassWriter$ClassInfo.<init>(StaticClassWriter.java:166)
        at com.google.monitoring.runtime.instrumentation.StaticClassWriter$ClassInfo.getSuperclass(StaticClassWriter.java:214)
        at com.google.monitoring.runtime.instrumentation.StaticClassWriter$ClassInfo.isSubclassOf(StaticClassWriter.java:252)
        at com.google.monitoring.runtime.instrumentation.StaticClassWriter$ClassInfo.isAssignableFrom(StaticClassWriter.java:265)
        at com.google.monitoring.runtime.instrumentation.StaticClassWriter.getCommonSuperClass(StaticClassWriter.java:101)
        at com.google.monitoring.runtime.instrumentation.asm.ClassWriter.getMergedType(ClassWriter.java:1729)
        at com.google.monitoring.runtime.instrumentation.asm.Frame.merge(Frame.java:1530)
        at com.google.monitoring.runtime.instrumentation.asm.Frame.merge(Frame.java:1429)
        at com.google.monitoring.runtime.instrumentation.asm.MethodWriter.visitMaxs(MethodWriter.java:1497)
        at com.google.monitoring.runtime.instrumentation.asm.MethodVisitor.visitMaxs(MethodVisitor.java:867)
        at com.google.monitoring.runtime.instrumentation.asm.tree.MethodNode.accept(MethodNode.java:835)
        at com.google.monitoring.runtime.instrumentation.asm.commons.JSRInlinerAdapter.visitEnd(JSRInlinerAdapter.java:187)
        at com.google.monitoring.runtime.instrumentation.asm.MethodVisitor.visitEnd(MethodVisitor.java:878)
        at com.google.monitoring.runtime.instrumentation.asm.MethodVisitor.visitEnd(MethodVisitor.java:878)
        at com.google.monitoring.runtime.instrumentation.asm.ClassReader.readMethod(ClassReader.java:1130)
        at com.google.monitoring.runtime.instrumentation.asm.ClassReader.accept(ClassReader.java:698)
        at com.google.monitoring.runtime.instrumentation.asm.ClassReader.accept(ClassReader.java:500)
        at com.google.monitoring.runtime.instrumentation.AllocationInstrumenter.instrument(AllocationInstrumenter.java:188)
        at com.google.monitoring.runtime.instrumentation.AllocationInstrumenter.instrument(AllocationInstrumenter.java:210)
        at com.google.monitoring.runtime.instrumentation.AllocationInstrumenter.transform(AllocationInstrumenter.java:157)
        at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:246)
        at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
        at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:563)
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
        at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550)
        at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
        at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
        at org.gradle.internal.classloader.TransformingClassLoader.findClass(TransformingClassLoader.java:52)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
        at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
        at org.gradle.internal.service.RelevantMethodsBuilder.<init>(RelevantMethodsBuilder.java:40)
        at org.gradle.internal.service.RelevantMethods.buildRelevantMethods(RelevantMethods.java:59)
        at org.gradle.internal.service.RelevantMethods.getMethods(RelevantMethods.java:51)
        at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:162)
        at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:250)
        at org.gradle.internal.service.DefaultServiceRegistry$1.addProvider(DefaultServiceRegistry.java:231)
        at org.gradle.api.internal.artifacts.DependencyServices.registerBuildServices(DependencyServices.java:43)
        at org.gradle.internal.service.scopes.BuildScopeServices.lambda$new$0(BuildScopeServices.java:208)
        at org.gradle.internal.service.DefaultServiceRegistry.register(DefaultServiceRegistry.java:208)
        at org.gradle.internal.service.scopes.BuildScopeServices.<init>(BuildScopeServices.java:202)
        at org.gradle.initialization.DefaultGradleLauncherFactory.doNewInstance(DefaultGradleLauncherFactory.java:122)
        at org.gradle.initialization.DefaultGradleLauncherFactory.doNewInstance(DefaultGradleLauncherFactory.java:101)
        at org.gradle.initialization.DefaultGradleLauncherFactory.newInstance(DefaultGradleLauncherFactory.java:80)
        at org.gradle.composite.internal.DefaultRootBuildState.<init>(DefaultRootBuildState.java:47)
        at org.gradle.composite.internal.DefaultIncludedBuildRegistry.createRootBuild(DefaultIncludedBuildRegistry.java:90)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:52)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:29)
        at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.lambda$execute$0(BuildTreeScopeLifecycleBuildActionExecuter.java:33)
        at org.gradle.internal.buildtree.BuildTreeState.run(BuildTreeState.java:49)
        at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.execute(BuildTreeScopeLifecycleBuildActionExecuter.java:32)
        at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.execute(BuildTreeScopeLifecycleBuildActionExecuter.java:27)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:104)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:55)
        at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:64)
        at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:37)
        at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildActionExecuter.lambda$execute$0(SessionScopeLifecycleBuildActionExecuter.java:54)
        at org.gradle.internal.session.BuildSessionState.run(BuildSessionState.java:67)
        at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildActionExecuter.execute(SessionScopeLifecycleBuildActionExecuter.java:50)
        at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildActionExecuter.execute(SessionScopeLifecycleBuildActionExecuter.java:36)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:59)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:31)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:41)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:47)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:31)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:65)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:29)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:84)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:834)

christiandeange avatar Apr 27 '21 04:04 christiandeange