gpt4 book ai didi

java - 如何使用 JDB 在嵌套类中正确设置断点?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:31:36 34 4
gpt4 key购买 nike

package com.android.internal.telephony.dataconnection;

public abstract class DcTrackerBase extends Handler {
protected BroadcastReceiver mIntentReceiver = new BroadcastReceiver ()
{
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (DBG) log("onReceive: action=" + action);
[...]

在上面的代码中,使用jdb,我想在onReceive 方法上设置一个断点。我使用了以下命令:

> stop in com.android.internal.telephony.dataconnection.DcTrackerBase$mIntentReceiver.onReceive

我从 jdb 得到这个:

> Deferring breakpoint com.android.internal.telephony.dataconnection.DcTrackerBase$mIntentReceiver.onReceive.
It will be set after the class is loaded.

我知道该类已经加载,所以我想 jdb 没有找到我想要的方法。那我应该如何设置我的断点呢?

最佳答案

争论的方法名称是错误的。

在 JDB 中,发出此命令来检查 DcTrackerBase 类:

> class com.android.internal.telephony.dataconnection.DcTrackerBase
Class: com.android.internal.telephony.dataconnection.DcTrackerBase
extends: android.os.Handler
subclass: com.android.internal.telephony.dataconnection.DcTracker
nested: com.android.internal.telephony.dataconnection.DcTrackerBase$1

正如我们所见,嵌套类 DcTrackerBase$1 可能是我们的 BroadcastReceiver 类。要验证,请发出以下命令:

> class com.android.internal.telephony.dataconnection.DcTrackerBase$1
Class: com.android.internal.telephony.dataconnection.DcTrackerBase$1
extends: android.content.BroadcastReceiver

就是这样!要正确设置断点,我们键入:

> stop in com.android.internal.telephony.dataconnection.DcTrackerBase$1.onReceive
Set breakpoint com.android.internal.telephony.dataconnection.DcTrackerBase$1.onReceive

关于java - 如何使用 JDB 在嵌套类中正确设置断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27047894/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com