java - 在 .class 文件 Intellij 中设置断点

标签 java debugging intellij-idea breakpoints

我正在尝试调试 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),显示以下选项:

store keys

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

import java.security.KeyStore;

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

如何调试 .engineStore() 方法?

最佳答案

如果您想调试它,您需要附加源文件。您无法调试.class 文件。

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

关于java - 在 .class 文件 Intellij 中设置断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33596127/

相关文章:

java - JAXB:如何将映射编码为 <key>value</key>

java - File.mkdirs() 并非一直有效

html - 如何在 HTML 电子邮件代码中将文本放在图像上?

java - IntelliJ IDEA 提示 Maven 类未找到

java - Intellij 无法识别的 TestNG 功能

git - Git/IntelliJ 中的更改列表是什么以及如何摆脱它?

java - 不使用 web.xml 的错误页面

c# - C# 的 @string 文字在 Java 中的对应物是什么?

java - 为什么在 Eclipse 中使用 "step into"时,即使没有步骤过滤器,也不显示对构造函数的调用

java - 我无法将 Tomcat webapp 配置为能够在 Eclipse 上进行调试