|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> services >> [ loader overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.iapi.services.loader
Class ClassInspector

java.lang.Objectorg.apache.derby.iapi.services.loader.ClassInspector
- public final class ClassInspector
- extends java.lang.Object
Methods to find out relationships between classes and methods within a class. All class names within this interface are treated as java language class names, e.g. int, COM.foo.Myclass, int[], java.lang.Object[]. That is java internal class names as defined in the class file format are not understood.
| Field Summary | |
private ClassFactory |
cf
|
private static java.lang.String[] |
nonPrimTypeNames
|
private static java.lang.String[] |
primTypeNames
|
| Constructor Summary | |
ClassInspector(ClassFactory cf)
DO NOT USE! use the method in ClassFactory. |
|
| Method Summary | |
boolean |
accessible(java.lang.String className)
Does the named class exist, and is it accessible? |
boolean |
assignableTo(java.lang.String fromClassName,
java.lang.String toClassName)
Is one named class assignable to another named class or interface? |
protected boolean |
classConvertableFromTo(java.lang.Class fromClass,
java.lang.Class toClass,
boolean mixTypes)
Can we convert a fromClass to toClass. |
java.lang.reflect.Member |
findPublicConstructor(java.lang.String receiverType,
java.lang.String[] parmTypes,
java.lang.String[] primParmTypes,
boolean[] isParam)
Find a public constructor that implements a given signature. |
java.lang.reflect.Member |
findPublicField(java.lang.String receiverType,
java.lang.String fieldName,
boolean staticField)
Find a public field for a class. |
java.lang.reflect.Member |
findPublicMethod(java.lang.String receiverType,
java.lang.String methodName,
java.lang.String[] parmTypes,
java.lang.String[] primParmTypes,
boolean[] isParam,
boolean staticMethod,
boolean repeatLastParameter)
Find a public method that implements a given signature. |
java.lang.Class |
getClass(java.lang.String className)
Get (load) the class for the given class name. |
java.lang.String |
getDeclaringClass(java.lang.reflect.Member method)
Get the declaring class for a method. |
java.lang.String[] |
getParameterTypes(java.lang.reflect.Member method)
Get the parameter types for a method described by a Member as a String[]. |
java.lang.String |
getType(java.lang.reflect.Member member)
Get the Java name of the return type from a Member representing a method or the type of a Member representing a field. |
boolean |
instanceOf(java.lang.String className,
java.lang.Object obj)
Is the given object an instance of the named class? |
private boolean |
isMethodMoreSpecificOrEqual(java.lang.reflect.Member T,
java.lang.reflect.Member U,
boolean[] isParam)
Is method/constructor T more or equally specific than method U. |
static boolean |
primitiveType(java.lang.String typeName)
Determine whether a type is a Java primitive, like int or boolean |
static java.lang.String |
readableClassName(java.lang.Class clazz)
Translate a JVM-style type descriptor to a Java-language-style type name. |
private java.lang.reflect.Member |
resolveMethod(java.lang.Class receiverClass,
java.lang.String methodName,
java.lang.Class[] paramClasses,
java.lang.Class[] primParamClasses,
boolean[] isParam,
boolean staticMethod,
boolean repeatLastParameter,
java.lang.reflect.Member[] methods)
Tricky function to resolve a method. |
private boolean |
signatureConvertableFromTo(java.lang.Class[] fromTypes,
java.lang.Class[] primFromTypes,
java.lang.Class[] toTypes,
boolean[] isParam,
boolean mixTypes)
Can we convert a signature from fromTypes(primFromTypes) to toTypes. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
primTypeNames
private static final java.lang.String[] primTypeNames
nonPrimTypeNames
private static final java.lang.String[] nonPrimTypeNames
cf
private final ClassFactory cf
| Constructor Detail |
ClassInspector
public ClassInspector(ClassFactory cf)
- DO NOT USE! use the method in ClassFactory.
| Method Detail |
instanceOf
public boolean instanceOf(java.lang.String className, java.lang.Object obj) throws java.lang.ClassNotFoundException
- Is the given object an instance of the named class?
assignableTo
public boolean assignableTo(java.lang.String fromClassName, java.lang.String toClassName)
- Is one named class assignable to another named class or interface?
accessible
public boolean accessible(java.lang.String className) throws java.lang.ClassNotFoundException
- Does the named class exist, and is it accessible?
getType
public java.lang.String getType(java.lang.reflect.Member member)
- Get the Java name of the return type from a Member representing
a method or the type of a Member representing a field.
findPublicMethod
public java.lang.reflect.Member findPublicMethod(java.lang.String receiverType, java.lang.String methodName, java.lang.String[] parmTypes, java.lang.String[] primParmTypes, boolean[] isParam, boolean staticMethod, boolean repeatLastParameter) throws java.lang.ClassNotFoundException, org.apache.derby.iapi.error.StandardException
- Find a public method that implements a given signature.
The signature is given using the full Java class names of the types.
A untyped null paramter is indicated by passing in an empty string ("") as its class name.
If receiverType respresents an interface then the methods of java.lang.Object arer included in the candidate list.
If the caller is simply checking to see that a public method with the specified name exists, regardless of the signature, exists, then the caller should pass in a null for parmTypes. (This is useful for checking the validity of a method alias when creating one.)
We use a two-pass algorithm to resolve methods. In the first pass, we use all "object" types to try to match a method. If this fails, in the second pass, an array of "primitive" types (if the parameter has one, otherwise the same object type is used) is passed in, as well as the "object" type array. For each parameter of a method, we try to match it against either the "object" type, or the "primitive" type. Of all the qualified candidate methods found, we choose the closest one to the input parameter types. This involves comparing methods whose parameters are mixed "object" and "primitive" types in the second pass. This is eventually handled in classConvertableFromTo.
findPublicField
public java.lang.reflect.Member findPublicField(java.lang.String receiverType, java.lang.String fieldName, boolean staticField) throws org.apache.derby.iapi.error.StandardException
- Find a public field for a class.
This follows the sematics of the java compiler for locating a field.
This means if a field fieldName exists in the class with package, private or
protected then an error is raised. Even if the field hides a field fieldName
in a super-class/super--interface. See the JVM spec on fields.
findPublicConstructor
public java.lang.reflect.Member findPublicConstructor(java.lang.String receiverType, java.lang.String[] parmTypes, java.lang.String[] primParmTypes, boolean[] isParam) throws java.lang.ClassNotFoundException, org.apache.derby.iapi.error.StandardException
- Find a public constructor that implements a given signature.
The signature is given using the full Java class names of the types.
A untyped null paramter is indicated by passing in an empty string ("") as its class name.
getParameterTypes
public java.lang.String[] getParameterTypes(java.lang.reflect.Member method)
- Get the parameter types for a method described by a Member as a String[].
primitiveType
public static boolean primitiveType(java.lang.String typeName)
- Determine whether a type is a Java primitive, like int or boolean
resolveMethod
private java.lang.reflect.Member resolveMethod(java.lang.Class receiverClass, java.lang.String methodName, java.lang.Class[] paramClasses, java.lang.Class[] primParamClasses, boolean[] isParam, boolean staticMethod, boolean repeatLastParameter, java.lang.reflect.Member[] methods) throws org.apache.derby.iapi.error.StandardException
- Tricky function to resolve a method. If primParamClasses is null
we know it's first pass. First pass try to match as all "object"
types, second pass try to match any combination of "object" and
"primitive" types. Find the closest match among all the qualified
candidates. If there's a tie, it's ambiguous.
getClass
public java.lang.Class getClass(java.lang.String className) throws java.lang.ClassNotFoundException
- Get (load) the class for the given class name.
This method converts any java language class name
into a Class object. This includes cases like String[]
and primitive types.
This will attempt to load the class from the application set.
isMethodMoreSpecificOrEqual
private boolean isMethodMoreSpecificOrEqual(java.lang.reflect.Member T, java.lang.reflect.Member U, boolean[] isParam)
- Is method/constructor T more or equally specific than method U.
See the Java Language Specification section 15.11.2.2.
signatureConvertableFromTo
private boolean signatureConvertableFromTo(java.lang.Class[] fromTypes, java.lang.Class[] primFromTypes, java.lang.Class[] toTypes, boolean[] isParam, boolean mixTypes)
- Can we convert a signature from fromTypes(primFromTypes) to toTypes.
"mixTypes" is a flag to show if object/primitive type conversion is
possible; this is used for comparing two candidate methods in the
second pass of the two pass method resolution.
classConvertableFromTo
protected boolean classConvertableFromTo(java.lang.Class fromClass, java.lang.Class toClass, boolean mixTypes)
- Can we convert a fromClass to toClass.
"mixTypes" is a flag to show if object/primitive type conversion is
possible; this is used for comparing two candidate methods in the
second pass of the two pass method resolution.
readableClassName
public static java.lang.String readableClassName(java.lang.Class clazz)
- Translate a JVM-style type descriptor to a Java-language-style type
name.
getDeclaringClass
public java.lang.String getDeclaringClass(java.lang.reflect.Member method)
- Get the declaring class for a method.
|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> services >> [ loader overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.derby.iapi.services.loader.ClassInspector