JVMTI agent causes RMI applications to exit (b638)

Questions about YourKit Java Profiler
Post Reply
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

JVMTI agent causes RMI applications to exit (b638)

Post by Gibson »

Somehow it looks like the JVMTI agent is setting the RMIReaper thread to be daemon, which means that my RMI application is exiting. Try the following test:
1) Start an rmiregistry on port 1100
2) Run the following code:

Code: Select all

import java.net.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;

public class TestApp extends UnicastRemoteObject {

	public TestApp () throws RemoteException {
	}

	public static void main (String args []) throws Exception {
		System.out.println (register (new TestApp (), InetAddress.getLocalHost ().getHostName (), 1100, "Global"));
		System.in.read (new byte[128]);
		System.out.println ("Exiting main thread");
	}

	static String register (TestApp gate, String machine, int port, String genericname)
		throws AlreadyBoundException, MalformedURLException, RemoteException {
		String shortmachine = machine + ":"+port;
		String name = "//" + shortmachine + "/" + genericname;
		Naming.bind (name, gate);
		return name;
	}
}
If you run it without the agent, it should wait for you to press Enter and then print out "Exiting main thread" and then continue to run. Take a stack trace and you will see that there is 1 non-daemon thread, named RMI-Reaper.

If you run it with -agentlib:yjpagent then if you take a stack trace before hitting Enter you will see that RMI-Reaper is now a daemon thread. Pressing Enter now causes the message "Exiting main thread" to be displayed, followed by application exit.
Vladimir Kondratyev
Posts: 1626
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

Thank you very much for reporting this. The problem will be fixed in the next EAP build #640.
RMIReaper thread to be daemon
That is the reason. In prev builds we have used RMI to communicate between agent and UI. Now all RMI code is removed, but we forgot about this artefact (it was needed to have two RMI registries inside one JVM).
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Post by Gibson »

Cool, looking forward to the next build.
R
Vladimir Kondratyev
Posts: 1626
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

Build #640 is available. Please try it.

Regards,
Vladimir
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Post by Gibson »

Looks fine now, thanks.
Post Reply