为何Java会在反编译时在.class内创建.java

时间:2019-07-19 11:07:04

标签: java jar compilation javac

我需要创建一个jar文件,该文件应该是实用程序类,并且与Java安全性有关。但是,当我尝试将此小罐子添加到我的项目中时,得到the following error

我真的试图理解这一点,而我看到它的唯一途径是因为当我尝试编译此类时,它会“自动包装”。

当我使用this进行反编译时 在线反编译器就像this structure

据我所知,这是因为我使用java.security.cert.X509Certificate import并有一个采用证书并对其进行处理的方法。

如果我不使用X509证书就真的很简单 I get a pretty result with no inner esoteric stuff

因此,如果我真的对证书进行了所有操作,它就会变得正常,但是当我尝试添加一些逻辑时,它却没有充分的理由“自动包装”。为什么会这样?

代码如下:

import java.security.cert.X509Certificate;

public final class AlgorithmUtils
{
    private AlgorithmUtils()
    {

    }

    private static final String URN_GOST_DIGEST_2012_256 = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-256";
    private static final String URN_GOST_SIGN_2012_256 = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102012-gostr34112012-256";

    private static final String URN_GOST_DIGEST_2012_512 = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-512";
    private static final String URN_GOST_SIGN_2012_512 = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102012-gostr34112012-512";

    private static final String URN_GOST_DIGEST = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411";
    private static final String URN_GOST_SIGN = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411";


    private static final String GOST_DIGEST_2012_256_NAME = "GOST3411_2012_256";
    private static final String GOST_DIGEST_2012_512_NAME = "GOST3411_2012_512";
    private static final String GOST_DIGEST_NAME = "GOST3411";

    public static String[] getDigestSignatureAlgorithmNamespaces(/*X509Certificate cert*/) 
    {
        /*switch (cert.getPublicKey().getAlgorithm()) 
        {
            case "GOST3410_2012_256":
                return new String[] {URN_GOST_DIGEST_2012_256, URN_GOST_SIGN_2012_256};
            case "GOST3410_2012_512":
                return new String[] {URN_GOST_DIGEST_2012_512, URN_GOST_SIGN_2012_512};
            case "GOST3410EL":
                return new String[] {URN_GOST_DIGEST, URN_GOST_SIGN};

            default:
                throw new IllegalArgumentException("The algorithm " + cert.getPublicKey().getAlgorithm() + " is not supported yet");
        }*/
        return new String[]{"0", "1"};
    }

    public static String[] getDigestSignatureAlgorithmOIDs(/*X509Certificate cert*/) 
    {
        /*switch (cert.getPublicKey().getAlgorithm()) 
        {
            case "GOST3410_2012_256":
                return new String[] {"1.2.643.7.1.1.2.2", "1.2.643.7.1.1.1.1"};
            case "GOST3410_2012_512":
                return new String[] {"1.2.643.7.1.1.2.3", "1.2.643.7.1.1.1.2"};
            case "GOST3410EL":
                return new String[] {"1.2.643.2.2.9", "1.2.643.2.2.19"};

            default:
                throw new IllegalArgumentException("The algorithm " + cert.getPublicKey().getAlgorithm() + " is not supported yet");
        }*/
        return new String[]{"0", "1"};
    }

    public static String getMessageDigestAlgorithmName(/*X509Certificate cert*/) 
    {
        /*switch (cert.getPublicKey().getAlgorithm()) 
        {
            case "GOST3410_2012_256":
                return GOST_DIGEST_2012_256_NAME;
            case "GOST3410_2012_512":
                return GOST_DIGEST_2012_512_NAME;
            case "GOST3410EL":
                return GOST_DIGEST_NAME;

            default:
                throw new IllegalArgumentException("The algorithm " + cert.getPublicKey().getAlgorithm() + " is not supported yet");
        }*/
        return "0";
    }
}

这与错误的编译有关吗?我对吗?您也可以编译它,看看我在说什么。预先感谢。

0 个答案:

没有答案