简体   繁体   English

以 * 开头的行上的 Java 编译错误

[英]Java compilation errors on lines starting with *

I am fairly new to Java and attempting to use the Java Crypto extension, so far I have this, except Eclipse is throwing errors on the lines with the * and I'm not sure why.我对 Java 还很陌生,并尝试使用 Java Crypto 扩展,到目前为止我已经有了这个,除了 Eclipse 在带有 * 的行上抛出错误,我不知道为什么。 I added in the *... they are not in the code normally.我添加了 *... 它们通常不在代码中。

private static byte[] getKey(byte[] paramArrayOfByte)

    throws NoSuchAlgorithmException
  {
    KeyGenerator localKeyGenerator = KeyGenerator.getInstance("AES");
    try
    {
      SecureRandom localSecureRandom1;
      SecureRandom localSecureRandom2 = SecureRandom.getInstance("SHA1PRNG", "Crypto");
 *    localSecureRandom1 = localSecureRandom2;
 *    localSecureRandom1.setSeed(paramArrayOfByte);
 *    localKeyGenerator.init(128, localSecureRandom1);
      return localKeyGenerator.generateKey().getEncoded();
    }
   catch (NoSuchProviderException localNoSuchProviderException)
    {
      while (true)

 *    SecureRandom localSecureRandom1 = SecureRandom.getInstance("SHA1PRNG");
  }
 }

all fixed, copy and paste error on my part, the infinite loop was for testing.我的所有修复,复制和粘贴错误,无限循环用于测试。

Assuming you introduced the asterisks ( * ) to highlight the problematic lines:假设您引入了星号 ( * ) 来突出显示有问题的行:

  • localSecureRandom1 is not declared on the first line marked, and that should also be the message the compiler gives you. localSecureRandom1没有在标记的第一行声明,这也应该是编译器给你的消息。
  • localSecureRandom1 is then declared in the catch -clause, which doesn't make sense localSecureRandom1然后在catch localSecureRandom1中声明,这没有意义
  • You also have an infinite loop in your catch -clause您的catch子句中也有一个无限循环

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM