This is the mail archive of the java-patches@sources.redhat.com 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]

PATCH: object stream dumping


This patch makes the serialized object dumping code conditional on the
value of the Configuration.DEBUG flag. It also changes the code to be
enabled at runtime by setting the "gcj.dumpobjects" system property
rather than by calling a method (we should never add new public methods
to the core java classes defined in the spec).

To get the debugging output, you should do BOTH of the following:

1. configure libgcj with "--enable-libgcj-debug"
2. set "gcj.dumpobjects" to anything other than null or the empty
string. You can do this by calling System.setProperty("gcj.dumpobjects",
"true") in program code or by using "-Dgcj.dumpobjects=true" on the gcj
command line.

ok to commit?

regards

  [ bryce ]

2000-11-24  Bryce McKinlay  <bryce@albatross.co.nz>

	* java/io/ObjectInputStream.java (ObjectInputStream): If DEBUG is set,
	test for gcj.dumpobjects property and enable object stream dumping
	if it is set.
	(dumpElement): No longer native.
	(dumpElementln): Ditto.
	(setDump): Do not define.
	* java/io/natObjectInputStream.cc (dumpElement): Removed.
	(dumpElementln): Removed.
	(setDump): Removed.

Index: natObjectInputStream.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/natObjectInputStream.cc,v
retrieving revision 1.3
diff -u -r1.3 natObjectInputStream.cc
--- natObjectInputStream.cc	2000/11/03 08:04:33	1.3
+++ natObjectInputStream.cc	2000/11/24 04:58:00
@@ -78,40 +78,3 @@
 {
   return klass->getPrivateMethod (name, arg_types);
 }
-
-#ifdef DEBUG
-void
-java::io::ObjectInputStream::setDump (jboolean dump)
-{
-  java::io::ObjectInputStream::dump = dump;
-}
-
-void
-java::io::ObjectInputStream::dumpElement (jstring msg)
-{
-  if (dump)
-    java::lang::System::out->print (msg);
-}
-
-void
-java::io::ObjectInputStream::dumpElementln (jstring msg)
-{
-  if (dump)
-    java::lang::System::out->println (msg);
-}
-#else
-void
-java::io::ObjectInputStream::setDump (jboolean dump)
-{
-}
-
-void
-java::io::ObjectInputStream::dumpElement (jstring msg)
-{
-}
-
-void
-java::io::ObjectInputStream::dumpElementln (jstring msg)
-{
-}
-#endif
Index: ObjectInputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/ObjectInputStream.java,v
retrieving revision 1.4
diff -u -r1.4 ObjectInputStream.java
--- ObjectInputStream.java	2000/11/03 08:04:33	1.4
+++ ObjectInputStream.java	2000/11/24 04:58:01
@@ -27,6 +27,8 @@
 
 package java.io;
 
+import gnu.classpath.Configuration;
+
 import java.lang.reflect.Array;
 import java.lang.reflect.Modifier;
 import java.util.Arrays;
@@ -61,6 +63,21 @@
   public ObjectInputStream (InputStream in)
     throws IOException, StreamCorruptedException
   {
+    if (Configuration.DEBUG)
+      {
+	String val = System.getProperty("gcj.dumpobjects");
+	if (dump == false && val != null && !val.equals(""))
+	  {
+	    dump = true;
+	    System.out.println ("Serialization debugging enabled");
+	  }
+	else if (dump == true && (val == null || val.equals("")))
+	  {
+	    dump = false;
+	    System.out.println ("Serialization debugging disabled");
+	  }
+      }
+
     this.resolveEnabled = false;
     this.isDeserializing = false;
     this.blockDataPosition = 0;
@@ -1509,25 +1526,20 @@
   private boolean isDeserializing;
   private boolean fieldsAlreadyRead;
   private Vector validators;
-
-  private static boolean dump;
-  public native static void setDump (boolean dump);
-  private native void dumpElement (String msg);
-  private native void dumpElementln (String msg);
 
+  private static boolean dump;  
 
-/* FIXME: These 2 methods cause a build error on i686-pc-linux-gnu.
-  private void DEBUG (String msg)
+  private void dumpElement (String msg)
   {
-    System.out.print (msg);
+    if (Configuration.DEBUG && dump)  
+      System.out.print(msg);
   }
-
-
-  private void DEBUGln (String msg)
+  
+  private void dumpElementln (String msg)
   {
-    System.out.println (msg);
+    if (Configuration.DEBUG && dump)
+      System.out.println(msg);
   }
-* end FIXME */
 }
 
 

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