org.apache.xmlrpc compiles natively!

Erik Poupaert erik.poupaert@chello.be
Mon Feb 10 20:42:00 GMT 2003


Erik> (1) The main trouble ticket is in java.net.URL.  In libgcj
Erik> url.openConnection() will by default request a http GET, while
Erik> the jdk will request a http POST by default. XML-RPC requires a
Erik> POST.

>>>>> Could you submit a PR for this?
>>>>> I've never looked at this area, and I'm very unlikely to find the time
>>>>> to before 3.3.  A PR is the best way to keep track of the problem.

libgcj/9645 "url.openConnection() will request by default a http GET, while
the jdk requests a POST"
That one was rather easy.

Erik> (2) a second trouble ticket is more complicated.
Erik> When a parent class defines an object field f with no visibility
Erik> modifiers (protected,private, public), gcj will compile it as
Erik> being protected, but for the one or the other reason, it's value
Erik> will remain null. When a method invoked in the parent class
Erik> assigns a value to f, this will not be visible in the subclass.

>>>>> Do you have a simple test case for this?
>>>>> If not, could you try to construct one?

I've tried to make one, but then I noticed that all of this happens in
thread workers (implements Runnable). Therefore, the problem could even be
related to threading. I think it would rather be simpler to show you where
the bug is in org.apache.xmlrpc.

I've taken out the folders org.apache.xmlrpc.applet,org.apache.xmlrpc.fesi,
and org.apache.xmlrpc.secure.
In line 276 of XmlRpcClient.java, class Worker is defined, which extends
XmlRpc. The culprit is the field defined at line 279,  "Object result =
null;". You will find that Object execute(String method, Vector params)
invokes the parse method at line 394. Now, the parent class (XmlRpc.java)
will invoke the abstract method objectParsed(Object what) at line 435, which
sets the value of "object result". This works fine.

XmlRpcClientLite.java extends XmlRpcClient.java and its inner class
LiteWorker extends the Worker class. At one point, its method "Object
execute (String method, Vector params)" invokes the method parse(), which
should set the "Object result" field in its parent class. When I compile
these classes with the JDK, it effectively sets this field. When I compile
it with GCJ, it doesn't.

I've got a simple client and a simple server that demonstrate the bug:

import org.apache.xmlrpc.*;
import java.util.Vector;
import java.util.Hashtable;

public class Client
{

	private static Class x1=java.util.Calendar.class;
	private static Class x2=java.util.Locale.class;
	private static Class x3=gnu.java.locale.Calendar.class;
	private static Class x4=gnu.java.locale.LocaleInformation.class;

	public static void main(String args[]) throws Exception
	{
		try
		{
			XmlRpc.debug=true;
			XmlRpcClientLite proxy=new
XmlRpcClientLite("http://localhost:8084/RPC2");
			Vector params=new Vector();
			params.addElement(new Integer(3));
			params.addElement(new Integer(12));
			Integer result =
				    (Integer) proxy.execute("example.sum", params);
			System.out.println("sum is: " + result.toString());
		 }
		 catch(Exception e)
		 {
			 System.err.println("XML-RPC Client: " + e.toString());
		 }
	}
}

import org.apache.xmlrpc.*;
import java.util.Hashtable;

public class Server
{

	private static Class x1=java.util.Calendar.class;
	private static Class x2=java.util.Locale.class;
	private static Class x3=gnu.java.locale.Calendar.class;
	private static Class x4=gnu.java.locale.LocaleInformation.class;

	public Server() { }

	public int sum(int x, int y)
	{
		System.out.println("returning sum");
		return x+y;
	}

	public static void main(String args[]) throws Exception
	{
		try
		{
			XmlRpc.debug=true;
			WebServer webserver = new WebServer (8084);
			 webserver.addHandler ("example", new Server());
		 }
		 catch(Exception e)
		 {
			 System.out.println("XML-RPC Server: " + e.toString());
		 }
	}
}



More information about the Java mailing list