This is the mail archive of the java@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]

bug in reflection isolated to simple example


I've isolated the "abnormal program termination" in java.lang.reflect (gdb
return code 03). It's perfectly well repeatable on my machine and platform.
I've extracted the relevant bits and bobs out of org.apache.xmlrpc to
illustrate the bug.

I would summarize the bug as following:

"""
When a method that is invoked through java.lang.reflect.Method.invoke()
throws an exception during its invokation, the java runtime will terminate
saying 'abnormal program termination' and with return code 03.
""".

I know I'm currently still on the GCJ/minGW release candidate, but I think
it would still be worthwhile to verify the bug in 3.3. Can anybody repeat
this bug on his machine or on his platform of choice? If it's repeatable
elsewhere, I will myself submit the trouble ticket, along with supporting
evidence.

By the way, this would be a showstopper (!) not only for native
org.apache.xmlrpc users, but for anyone who uses a framework that is based
on reflection (CORBA, variations on RMI, SOAP, servlets, and so on), because
the slightest exception in the code invoked through reflection would kill
and bring down the container crashing in flames.

Concerning the previous bug, that is, the one in which a parent class
modifies a protected variable in a workerthread, resulting in the child
class not seeing the modifications, I still haven't been able to create a
small example that illustrates the bug. I've just fixed it org.apache.xmlrpc
by creating a workaround using some ugly duct tape. It is a bug, however,
because the bytecode xmlrpc client does work without the workaround, while
the native xmlrpc client doesn't. I'm talking about exactly the same source
code. I'll keep you posted on my efforts to re-create the bug in a
simplified (if possible?) (series of) source file(s).

--------------------cut-here------------------------------------------------
--------------->

import java.lang.reflect.*;

public class Invoker
{

	protected Object mTarget;
	protected Class mTargetClass;

	public Invoker(Object pTarget)
	{
		mTarget=pTarget;
		mTargetClass=pTarget.getClass();
	}

	public Object execute(String pMethodName) throws Throwable
	{
		Class[] argClasses=null; // <-- FOR SIMPLICITY, NO NEED FOR ARGUMENTS
		Object[] argValues =null; // <-- FOR SIMPLICITY,NO NEED FOR ARGUMENTS
		Method method=mTargetClass.getMethod(pMethodName,argClasses);
		Object returnValue=method.invoke(mTarget,argValues);
		return returnValue;
	}
}


public class TestInvoker
{

	public int someTestMethod() throws Exception
	{
		throw new Exception("dummy exception"); // <-- PROVOKES THE CRASH
		//return 5;
	}

	public static void main(String args[]) throws Throwable
	{
		Invoker invoker=new Invoker(new TestInvoker());
		Integer result=(Integer)invoker.execute("someTestMethod");
		System.out.println("result=" + result.toString());
	}
}


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