【问题标题】:Setting breakpoints in .class files Intellij在 .class 文件中设置断点 Intellij
【发布时间】:2016-02-09 07:57:36
【问题描述】:

我正在尝试调试this问题中提到的代码,更具体地说,是以下代码的最后一行:

        // client credentials
        KeyStore keyStore = null;

        keyStore = KeyStore.getInstance("PKCS12", "BC");
        keyStore.load(null, null);
        keyStore.setKeyEntry(CryptographyUtils.CLIENT_NAME, endCredential.getPrivateKey(), CryptographyUtils.CLIENT_PASSWORD,
                new Certificate[]{endCredential.getCertificate(), interCredential.getCertificate(), rootCredential.getCertificate()});
        keyStore.store(new FileOutputStream(CryptographyUtils.CLIENT_NAME + ".p12"), CryptographyUtils.CLIENT_PASSWORD);

转到 .store() 的声明(使用 Ctrl + B)打开一个文件 KeyStore.java

public final void store(OutputStream stream, char[] password)
        throws KeyStoreException, IOException, NoSuchAlgorithmException,
            CertificateException
    {
        if (!initialized) {
            throw new KeyStoreException("Uninitialized keystore");
        }
        keyStoreSpi.engineStore(stream, password);
    }

最后一次调用 .engineStore() 实际上将证书写入输出流。转到方法的实现(Ctrl + Alt + B),显示以下选项:

我的代码中包含该方法的导入包来自:

import java.security.KeyStore;

我在 KeyStore.java 中设置了一个断点,并且已经到达。但是,如图所示,放置在反编译的 .class 文件中的断点不是。

如何调试 .engineStore() 方法?

【问题讨论】:

  • 当然,不是你要找的:但如果重点是调试某个方法;并且该方法中的断点不起作用;为什么不在调用该方法的行上放置一个断点;然后做一些“步入”?
  • 我尝试过踏入以及强制踏入。很多类都在实现容器,例如向量和列表,您不可避免地会涉足这些容器。很容易在代码中“迷失”,并且看不到您正在调试的范围。

标签: java debugging intellij-idea breakpoints


【解决方案1】:

如果你想调试,你需要附加source files。你不能调试.class文件。

See this post 了解如何将源代码添加到库配置中。

【讨论】:

  • 我该怎么做?
  • 下载那个jar的源码并添加。
  • 建议的问题已过时。在 intellij 14 中,我看不到帖子中提到的添加源按钮。
  • 你的 Intellij 版本是哪个?
  • 我正在使用 Intellij 14
猜你喜欢
  • 1970-01-01
  • 2012-06-27
  • 1970-01-01
  • 1970-01-01
  • 2012-07-20
  • 1970-01-01
  • 1970-01-01
  • 2012-03-29
  • 1970-01-01
相关资源
最近更新 更多