Interface default methods

I am coding feverishly to complete a web interface to the JVM internals like memory, threads etc. This is my first set of default methods in an interface.

I have not read the JLS comparison between this and other inheritance mechanisms but this serves a purpose.

package com.memory.probe;

import java.util.AbstractQueue;
import java.util.concurrent.ArrayBlockingQueue;


import org.apache.log4j.Logger;

public interface Probe {
	Logger l = Logger.getLogger("generation.gc");
	AbstractQueue<Long> abq = new ArrayBlockingQueue<Long>(100);

	default void connectJMXRemote(int port){
	      JMXServiceURL url;
	  	try {
	  		url = new JMXServiceURL(
	  		            "service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi");
	  		JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
	  		l.debug("Remote JMX connection is successful");
	  	} catch (IOException e) {

	default String getTrace(Throwable t){
		return getStackTrace(t);
    static String getStackTrace(Throwable t){
    	StringWriter sw = new StringWriter();
    	PrintWriter pw = new PrintWriter(sw);
    	return sw.toString();


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: