This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: libgcj-vs-ecj build fixes


This patch fixes a couple of libgcj errors that gcj fails to detect, but which are found when libgcj is built with ecj.

I'm checking this in to the trunk.

Bryce


2006-04-11  Bryce McKinlay  <mckinlay@redhat.com>

	* gnu/gcj/runtime/SystemClassLoader.java (addClass): Get the value
	of package-private field "loadedClasses" using reflection.
	* java/lang/VMCompiler.java (compileClass): Remove unreachable catch
	block.

Index: gnu/gcj/runtime/SystemClassLoader.java
===================================================================
--- gnu/gcj/runtime/SystemClassLoader.java	(revision 112829)
+++ gnu/gcj/runtime/SystemClassLoader.java	(working copy)
@@ -9,8 +9,9 @@
 package gnu.gcj.runtime;
 
 import java.io.*;
+import java.lang.reflect.Field;
 import java.util.StringTokenizer;
-import java.util.HashSet;
+import java.util.HashMap;
 import java.net.URL;
 import java.net.URLClassLoader;
 
@@ -21,6 +22,8 @@
     super(new URL[0], parent);
   }
 
+  private HashMap loadedClasses;
+
   // This is called to register a native class which was linked into
   // the application but which is registered with the system class
   // loader after the VM is initialized.
@@ -37,7 +40,23 @@
 	// precompiled manifest.
 	definePackage(packageName, null, null, null, null, null, null, null);
       }
-    loadedClasses.put(className, klass);
+      
+    // Use reflection to access the package-private "loadedClasses" field.
+    if (this.loadedClasses == null)
+      {
+	try
+	{
+	  Class cl = java.lang.ClassLoader.class;
+	  Field lcField = cl.getDeclaredField("loadedClasses");
+	  lcField.setAccessible(true);
+	  this.loadedClasses = (HashMap) lcField.get(this);
+	}
+	catch (Exception x)
+	{
+	  throw new RuntimeException(x);
+	}      
+      }
+    this.loadedClasses.put(className, klass);
   }
 
   // We add the URLs to the system class loader late.  The reason for
Index: java/lang/VMCompiler.java
===================================================================
--- java/lang/VMCompiler.java	(revision 112829)
+++ java/lang/VMCompiler.java	(working copy)
@@ -198,11 +198,6 @@
 	md.update(data);
 	digest = md.digest();
       }
-    catch (CloneNotSupportedException _)
-      {
-	// Can't happen.
-	return null;
-      }
     catch (NullPointerException _)
       {
 	// If md5Digest==null -- but really this should never happen

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]