VMCompiler.java (md5Digest): New field.
authorTom Tromey <tromey@redhat.com>
Mon, 7 Mar 2005 19:51:10 +0000 (19:51 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 7 Mar 2005 19:51:10 +0000 (19:51 +0000)
* java/lang/VMCompiler.java (md5Digest): New field.
(compileClass): Clone md5Digest instead of looking up a new one.

From-SVN: r96039

libjava/ChangeLog
libjava/java/lang/VMCompiler.java

index 696167fade8647b6a4eb15b7d1d3a6ccaf84a46e..f4729686af4f988e1c56100d89b6c8bd1ba48b7d 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-07  Tom Tromey  <tromey@redhat.com>
+
+       * java/lang/VMCompiler.java (md5Digest): New field.
+       (compileClass): Clone md5Digest instead of looking up a new one.
+
 2005-03-07  Tom Tromey  <tromey@redhat.com>
 
        PR java/20215:
index b3f55603487ab609ae3272559713085af8de966b..784a816c59cef48f431a954ce93908fdfa5c7468 100644 (file)
@@ -79,6 +79,24 @@ final class VMCompiler
 
   private static Vector precompiledMapFiles;
 
+  // We create a single MD5 engine and then clone it whenever we want
+  // a new one.  This is simpler than trying to find a new one each
+  // time, and it avoids potential deadlocks due to class loader
+  // oddities.
+  private static final MessageDigest md5Digest;
+
+  static
+  {
+    try
+      {
+       md5Digest = MessageDigest.getInstance("MD5");
+      }
+    catch (NoSuchAlgorithmException _)
+      {
+       md5Digest = null;
+      }
+  }
+
   static
   {
     gcjJitCompiler = System.getProperty("gnu.gcj.jit.compiler");
@@ -175,11 +193,18 @@ final class VMCompiler
 
     try
       {
-       MessageDigest md = MessageDigest.getInstance("MD5");
+       MessageDigest md = (MessageDigest) md5Digest.clone();
        digest = md.digest(data);
       }
-    catch (NoSuchAlgorithmException _)
+    catch (CloneNotSupportedException _)
+      {
+       // Can't happen.
+       return null;
+      }
+    catch (NullPointerException _)
       {
+       // If md5Digest==null -- but really this should never happen
+       // either, since the MD5 digest is in libgcj.
        return null;
       }