jrockit.management
Class MethodIdentifier

java.lang.Object
  extended by jrockit.management.MethodIdentifier
All Implemented Interfaces:
java.io.Serializable

public class MethodIdentifier
extends java.lang.Object
implements java.io.Serializable

A MethodIdentifier is a serializable specification of a method in a JVM. The current implementation however lacks support of different ClassLoaders, which is needed to make a correct discrimination between different methods in the JVM.

This class is primarily used as a way to describe methods in JRockit which should be profiled in one way or another.

Author:
Marcus Hirt
See Also:
Serialized Form

Constructor Summary
MethodIdentifier()
          Constructor normally used by the XML-framework.
MethodIdentifier(javax.management.openmbean.CompositeData cd)
          Constructs a MethodIdentifier from a composite data
MethodIdentifier(java.lang.reflect.Method method)
          Constructs a MethodIdentifier from a Method using reflection.
MethodIdentifier(java.lang.String className, java.lang.String methodName, java.lang.String descriptor)
          Construct a MethodIdentifier from a class name, a method name, and a descriptor.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Indicates whether some other MethodIdentfier is "equal to" this one.
static MethodIdentifier from(javax.management.openmbean.CompositeData cd)
          Returns a MethodIdentifier from composite data
static java.lang.String getAsHumanReadable(MethodIdentifier identifier, boolean qualified)
          Returns a String representing this method in a form convenient for humans.
 java.lang.String getClassName()
          Returns the fully qualified class name of this method (i.e. with package name).
 java.lang.String getDescriptor()
          Returns the descriptor of this MethodIdentfier.
static java.lang.reflect.Method getMethod(java.lang.ClassLoader l, MethodIdentifier methodIdentifier)
          Returns a java method from a methodIdentifier.
static java.lang.reflect.Method getMethod(java.lang.Class c, MethodIdentifier methodIdentifier)
          Returns a java method from a methodIdentifier.
 java.lang.String getMethodName()
          Returns the method name of this MethodIdentfier.
 int hashCode()
          Returns a hash code for this MethodIdentfier
 java.lang.String toHumanReadable(boolean qualified)
          Returns a String representing this MethodIdentfier in a form convenient for humans to read.
 java.lang.reflect.Method toMethod(java.lang.Class c)
          Convenience method that converts this MethodIdentifier identifier to a Method, given the qualifing Class.
 java.lang.reflect.Method toMethod(java.lang.ClassLoader l)
          Converts this MethodIdentifier identifier to a Method, given the qualifing ClassLoader.
 java.lang.String toString()
          Returns a string representation of this MethodIdentfier
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodIdentifier

public MethodIdentifier()
Constructor normally used by the XML-framework.


MethodIdentifier

public MethodIdentifier(javax.management.openmbean.CompositeData cd)
Constructs a MethodIdentifier from a composite data

Parameters:
cd - the composite data to use to construct this MethodIdentifier.

MethodIdentifier

public MethodIdentifier(java.lang.String className,
                        java.lang.String methodName,
                        java.lang.String descriptor)
Construct a MethodIdentifier from a class name, a method name, and a descriptor.

Parameters:
className - the qualified class name.
methodName - the methodName.
descriptor - the formal method descriptor.

MethodIdentifier

public MethodIdentifier(java.lang.reflect.Method method)
Constructs a MethodIdentifier from a Method using reflection.

Parameters:
method - the reflection method to create a MethodIdentifier for.
Method Detail

getClassName

public java.lang.String getClassName()
Returns the fully qualified class name of this method (i.e. with package name).

Returns:
fully qualified class name.

getMethodName

public java.lang.String getMethodName()
Returns the method name of this MethodIdentfier.

Returns:
the method name.

getDescriptor

public java.lang.String getDescriptor()
Returns the descriptor of this MethodIdentfier.

Returns:
the method descriptor.

toString

public java.lang.String toString()
Returns a string representation of this MethodIdentfier

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other MethodIdentfier is "equal to" this one.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Returns a hash code for this MethodIdentfier

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

toHumanReadable

public java.lang.String toHumanReadable(boolean qualified)
                                 throws MalformedDescriptorException
Returns a String representing this MethodIdentfier in a form convenient for humans to read.

Returns:
a human readable String representation
Throws:
MalformedDescriptorException

toMethod

public java.lang.reflect.Method toMethod(java.lang.ClassLoader l)
                                  throws java.lang.ClassNotFoundException,
                                         java.lang.NoSuchMethodException,
                                         MalformedDescriptorException
Converts this MethodIdentifier identifier to a Method, given the qualifing ClassLoader.

Parameters:
l - the ClassLoader which together with this MethodIdentifer, defines which method to retrieve.
Returns:
the Method that this Identifier corresponds to.
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
MalformedDescriptorException

toMethod

public java.lang.reflect.Method toMethod(java.lang.Class c)
                                  throws java.lang.NoSuchMethodException,
                                         MalformedDescriptorException
Convenience method that converts this MethodIdentifier identifier to a Method, given the qualifing Class.

Parameters:
c - the Class which together with this MethodIdentifer, defines which method to retrieve.
Returns:
the Method that this Identifier corresponds to.
Throws:
java.lang.NoSuchMethodException
MalformedDescriptorException

getAsHumanReadable

public static java.lang.String getAsHumanReadable(MethodIdentifier identifier,
                                                  boolean qualified)
                                           throws MalformedDescriptorException
Returns a String representing this method in a form convenient for humans.

Parameters:
identifier - the MethodIdentifier to get the String form for.
qualified - true if you wish for class names to be fully qualified.
Returns:
a String representing this method in a form convenient for humans.
Throws:
MalformedDescriptorException

from

public static MethodIdentifier from(javax.management.openmbean.CompositeData cd)
Returns a MethodIdentifier from composite data

Parameters:
cd -
Returns:
the MethodIdentfier

getMethod

public static java.lang.reflect.Method getMethod(java.lang.ClassLoader l,
                                                 MethodIdentifier methodIdentifier)
                                          throws java.lang.NoSuchMethodException,
                                                 java.lang.ClassNotFoundException,
                                                 MalformedDescriptorException
Returns a java method from a methodIdentifier. The class is needed since we don't know what class we really want to look at. (Different class loaders may have loaded different versions of the same class.)

Parameters:
l - the class loader, owning the method to return.
methodIdentifier - the method identifier, identifying the method.
Returns:
Method the actual method.
Throws:
java.lang.NoSuchMethodException - If the method couldn't be found.
java.lang.ClassNotFoundException - if one of the parameter types couldn't be found.
MalformedDescriptorException

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Class c,
                                                 MethodIdentifier methodIdentifier)
                                          throws java.lang.NoSuchMethodException,
                                                 MalformedDescriptorException
Returns a java method from a methodIdentifier. The class is needed since we don't know what class we really want to look at. (Different class loaders may have loaded different versions of the same class.)

Parameters:
c - the class, owning the method to return. May not be null.
methodIdentifier - the method identifier, identifying the method.
Returns:
Method the actual method.
Throws:
java.lang.NoSuchMethodException - If the method couldn't be found.
MalformedDescriptorException


Copyright © 2004-2005 BEA Systems Inc.