openjava.mop
Class OJClass

java.lang.Object
  |
  +--openjava.mop.OJClass
All Implemented Interfaces:
OJMember
Direct Known Subclasses:
Metaclass, SyntheticClass

public class OJClass
extends Object
implements OJMember

The OJClass class represents a class metaobject. If the class has its valid .class file in CLASSPATH, the metaobject can behave like java.lang.Class. If the class has its valid .oj file in the packages where some classes are being compiled by OpenJava system, or in the packages explicitly specified by something like OpenJava compiler option or environment variable, the metaobject can have information about source code just as stamements, expressions, and etc.

Additionaly, you can overrides the methods for introspection.

     OJClass[] getDeclaredClasses()
     OJMethod[] getDeclaredMethods()
     OJField[] getDeclaredFields()
     OJConstructor[] getDeclaredConstructors()
     OJMethod getAcceptableMethod(OJClass,String,OJClass[])
     OJMethod getAcceptableConstructor(OJClass,String,OJClass[])
 

Since:
%SOFTWARE% 1.0
Version:
1.0
Author:
Michiaki Tatsubori
See Also:
Class, OJMethod, OJField, OJConstructor

Field Summary
private  OJClassImp substance
           
 
Fields inherited from interface openjava.mop.OJMember
DECLARED, PUBLIC
 
Constructor Summary
(package private) OJClass()
          For dummy type of null object.
  OJClass(Class java_class, MetaInfo metainfo)
          Generates a metaobject from byte code.
  OJClass(Environment outer_env, OJClass declarer, ClassDeclaration ptree)
          Generates a metaobject from source code.
private OJClass(OJClass componentType)
          For arrays
 
Method Summary
 OJClass addClass(OJClass clazz)
           
protected  OJConstructor addConstructor(OJConstructor constr)
           
 OJField addField(OJField field)
           
protected  void addInterface(OJClass clazz)
           
protected  OJMethod addMethod(OJMethod method)
           
(package private) static OJClass[] arrayForClasses(Class[] jclasses)
           
static OJClass arrayOf(OJClass componentType)
           
 Expression expandAllocation(Environment env, AllocationExpression expr)
           
 Expression expandArrayAccess(Environment env, ArrayAccess expr)
           
 Expression expandArrayAllocation(Environment env, ArrayAllocationExpression expr)
           
 Expression expandAssignmentExpression(Environment env, AssignmentExpression expr)
           
 Expression expandCastedExpression(Environment env, CastExpression decl)
           
 Expression expandCastExpression(Environment env, CastExpression decl)
           
 Expression expandExpression(Environment env, Expression expr)
           
 Expression expandFieldRead(Environment env, FieldAccess expr)
           
 Expression expandFieldWrite(Environment env, AssignmentExpression expr)
           
 Expression expandMethodCall(Environment env, MethodCall expr)
           
 TypeName expandTypeName(Environment env, TypeName expr)
           
 Statement expandVariableDeclaration(Environment env, VariableDeclaration decl)
           
static OJClass forClass(Class javaClass)
          Converts a OJClass object to an OJClass object.
static OJClass forName(String name)
          Returns the OJClass object associated with the class with the given string name.
static OJClass forObject(Object obj)
           
static OJClass forParseTree(Environment env, OJClass declaringClass, ClassDeclaration ptree)
          Converts ParseTree objects to an OJClass object.
 OJConstructor getAcceptableConstructor(OJClass[] parameterTypes, OJClass situation)
          Can be overriden
 OJMethod getAcceptableMethod(String name, OJClass[] parameterTypes, OJClass situation)
          Can be overriden
 OJClass[] getAllClasses()
           
 OJField getAllField(String name)
          Deprecated.  
 OJField[] getAllFields()
           
 OJMethod getAllMethod(String name, OJClass[] parameterTypes)
          Deprecated.  
 OJMethod[] getAllMethods()
           
 OJMethod[] getAllMethods(String name)
          Deprecated.  
 Class getByteCode()
           
 OJClass[] getClasses()
          Returns an array containing OJClass objects representing all the public classes and interfaces that are members of the class represented by this OJClass object.
 OJClass[] getClasses(OJClass situation)
          Returns an array containing OJClass objects representing all the classes and interfaces which are members of the class represented by this OJClass object, accessible from the situation represented by the given OJClass object.
 ClassLoader getClassLoader()
           
 Class getCompatibleJavaClass()
           
 OJClass getComponentType()
          Returns the OJClass representing the component type of an array.
 OJConstructor getConstructor(OJClass[] parameterTypes)
          Returns a OJConstructor object that reflects the specified public constructor of the class represented by this OJClass object.
 OJConstructor getConstructor(OJClass[] parameterTypes, OJClass situation)
          Returns a OJConstructor object that reflects the specified constructor accesible from the situation represented by the given OJClass object.
 OJConstructor[] getConstructors()
          Returns an array containing OJConstructor objects reflecting all the public constructors of the class represented by this OJClass object.
 OJConstructor[] getConstructors(OJClass situation)
          Returns an array containing OJConstructor objects reflecting all the constructors of the class represented by this OJClass object, accesible from the situation represented by the given OJClass object.
 OJClass[] getDeclaredClasses()
          Returns an array of OJClass objects reflecting all the classes and interfaces declared as members of the class represented by this OJClass object.
 OJConstructor getDeclaredConstructor(OJClass[] parameterTypes)
          Returns a OJConstructor object that reflects the specified constructor of the class or interface represented by this OJClass object.
 OJConstructor[] getDeclaredConstructors()
          Returns an array of OJConstructor objects reflecting all the constructors declared by the class represented by this OJClass object.
 OJField getDeclaredField(String name)
          Returns a OJField object that reflects the specified declared field of the class or interface represented by this OJClass object.
 OJField[] getDeclaredFields()
          Returns an array of OJField objects reflecting all the fields declared by the class or interface represented by this OJClass object.
 OJMethod getDeclaredMethod(String name, OJClass[] parameterTypes)
          Returns a OJMethod object that reflects the specified declared method of the class or interface represented by this OJClass object.
 OJMethod[] getDeclaredMethods()
          Returns an array of OJMethod objects reflecting all the methods declared by the class or interface represented by this OJClass object.
 OJClass getDeclaringClass()
          If the class or interface represented by this OJClass object is a member of another class, returns the OJClass object representing the class in which it was declared.
static SyntaxRule getDeclSuffixRule(String keyword)
           
 Environment getEnvironment()
          Obtains an environment of this class object.
 OJField getField(String name)
          Returns a OJField object that reflects the specified public member field of the class or interface represented by this OJClass object.
 OJField getField(String name, OJClass situation)
          Returns a OJField object that reflects the specified member field accesible from the situation represented by the given OJClass object.
 OJField[] getFields()
          Returns an array containing OJField objects reflecting all the accessible public fields of the class or interface represented by this OJClass object.
 OJField[] getFields(OJClass situation)
          Returns an array containing OJField objects reflecting all the fields of the class or interface represented by this OJClass object, accessible from the situation represented by the given OJClass object.
 OJClass[] getInheritableClasses()
          Deprecated.  
 OJClass[] getInheritableClasses(OJClass situation)
           
 OJConstructor[] getInheritableConstructors(OJClass situation)
           
 OJField[] getInheritableFields()
          Deprecated.  
 OJField[] getInheritableFields(OJClass situation)
           
 OJMethod[] getInheritableMethods()
          Deprecated.  
 OJMethod[] getInheritableMethods(OJClass situation)
           
 OJClass[] getInheritedClasses()
           
 OJField[] getInheritedFields()
           
 OJMethod[] getInheritedMethods()
           
 OJClass[] getInterfaces()
          Determines the interfaces implemented by the class or interface represented by this object.
 String getMetaInfo(String key)
           
 Enumeration getMetaInfoElements()
           
 Enumeration getMetaInfoKeys()
           
 OJMethod getMethod(String name, OJClass[] parameterTypes)
          Returns a OJMethod object that reflects the specified public member method of the class or interface represented by this OJClass object.
 OJMethod getMethod(String name, OJClass[] parameterTypes, OJClass situation)
          Returns a OJMethod object that reflects the specified member method accesible from the situation represented by the given OJClass object.
 OJMethod[] getMethods()
          Returns an array containing OJMethod objects reflecting all the public member methods of the class or interface represented by this OJClass object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces.
 OJMethod[] getMethods(OJClass situation)
          Returns an array containing OJMethod objects reflecting all the member methods of the class or interface represented by this OJClass object, accesible from the situation represented by the given OJClass object.
 OJModifier getModifiers()
          Returns the Java language modifiers and the user defined modifiers for this class or interface, as a OJModifier object.
 String getName()
          Returns the fully-qualified name of the entity (class, interface, array class, primitive type, or void) represented by this OJClass object, as a String.
 String getPackage()
          Gets the package name for this class as a String.
 URL getResource(String name)
           
 InputStream getResourceAsStream(String name)
           
 Object[] getSigners()
           
 String getSimpleName()
          Returns the simple name of the class, interface or array class represented by this OJClass object, as a String.
 ClassDeclaration getSourceCode()
           
 ParseTree getSuffix(String keyword)
          Obtains an parse tree of suffix in extended syntax starting with the specified keyword.
 OJClass getSuperclass()
          Returns the OJClass representing the superclass of the entity (class, interface, primitive type or void) represented by this OJClass.
static SyntaxRule getTypeSuffixRule(String keyword)
           
 boolean isAlterable()
           
 boolean isArray()
          Determines if this OJClass object represents an array class.
private static boolean isArrayName(String name)
           
 boolean isAssignableFrom(OJClass clazz)
          Determines if the class or interface represented by this OJClass object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified OJClass parameter.
 boolean isExecutable()
           
 boolean isInSamePackage(OJClass c)
          Determines if the specified class object is in the same package as this class object.
 boolean isInstance(Object obj)
           
 boolean isInterface()
          Determines if the specified OJClass object represents an interface type.
 boolean isPrimitive()
          Determines if the specified OJClass object represents a primitive type.
 boolean isPrimitiveWrapper()
          Determines if the specified OJClass object represents a wrapper class for a primitive type.
static boolean isRegisteredKeyword(String keyword)
           
static boolean isRegisteredModifier(String keyword)
           
private static OJClass lookupFromByteCode(String name)
           
private static OJClass lookupFromMetaInfo(Class javaClass)
           
 OJClass makeCopy(String qname)
          Generate a copy of this class object with the specified name.
protected static Expression makeExpression(Environment env, String str)
          Generates a expression parse tree from a given String object under the given environment.
protected  Expression makeExpression(String str)
          Generates an expression parse tree from a given String object under the environment of this class object.
protected static Statement makeStatement(Environment env, String str)
          Generates a statement parse tree from a given String object under the given environment.
protected  Statement makeStatement(String str)
          Generates a statement parse tree from a given String object under the environment of this class object.
protected static StatementList makeStatementList(Environment env, String str)
          Generates a statement list parse tree from a given String object under the given environment.
protected  StatementList makeStatementList(String str)
          Generates a statement list parse tree from a given String object under the environment of this class object.
private static String nameForJavaClassName(String jcname)
           
private static String nameToJavaClassName(String ojcname)
           
 Object newInstance()
           
private static OJClass[] overridesOn(OJClass[] declareds, OJClass[] bases)
           
private static OJField[] overridesOn(OJField[] declareds, OJField[] bases)
           
private static OJMethod[] overridesOn(OJMethod[] declareds, OJMethod[] bases)
           
private static OJConstructor pickupAcceptableConstructor(OJConstructor[] src_constrs, OJClass[] parameterTypes)
           
private static OJMethod pickupAcceptableMethod(OJMethod[] src_methods, String name, OJClass[] parameterTypes)
           
private static OJConstructor pickupConstructor(OJConstructor[] src_constrs, OJClass[] parameterTypes)
           
private static OJField pickupField(OJField[] src_fields, String name)
           
private static OJMethod pickupMethod(OJMethod[] src_methods, String name, OJClass[] parameterTypes)
           
private static OJMethod[] pickupMethodsByName(OJMethod[] src_methods, String name)
           
private static int primitiveTypeWidth(OJClass ptype)
           
 OJClass primitiveWrapper()
          Obtains the wrapper class if this class represents a primitive type.
protected  String putMetaInfo(String key, String value)
           
protected  OJClass removeClass(OJClass clazz)
           
protected  OJConstructor removeConstructor(OJConstructor constr)
           
 OJField removeField(OJField field)
           
protected  OJMethod removeMethod(OJMethod method)
           
private static OJClass[] removeTheDefaults(OJClass[] src_classes)
           
private static OJConstructor[] removeTheDefaults(OJConstructor[] src_constrs)
           
private static OJField[] removeTheDefaults(OJField[] src_fields)
           
private static OJMethod[] removeTheDefaults(OJMethod[] src_methods)
           
private static OJClass[] removeTheNonPublics(OJClass[] src_classes)
           
private static OJConstructor[] removeTheNonPublics(OJConstructor[] src_constrs)
           
private static OJField[] removeTheNonPublics(OJField[] src_fields)
           
private static OJMethod[] removeTheNonPublics(OJMethod[] src_methods)
           
private static OJClass[] removeThePrivates(OJClass[] src_classes)
           
private static OJConstructor[] removeThePrivates(OJConstructor[] src_constrs)
           
private static OJField[] removeThePrivates(OJField[] src_fields)
           
private static OJMethod[] removeThePrivates(OJMethod[] src_methods)
           
static String replaceDotWithDollar(String base, int i)
           
 OJField resolveException(NoSuchMemberException e, String name)
           
 OJMethod resolveException(NoSuchMemberException e, String name, OJClass[] argtypes)
           
(package private)  void setDeclaringClass(OJClass parent)
           
protected  OJClass[] setInterfaces(OJClass[] classes)
           
protected  String setName(String simple_name)
          not implemented yet
protected  OJClass setSuperclass(OJClass clazz)
           
 Signature signature()
           
private static String stripBrackets(String ojcname)
           
(package private) static Class[] toClasses(OJClass[] classes)
           
 String toString()
          Converts the object to a string.
 void translateDefinition()
           
 ClassDeclaration translateDefinition(Environment env, ClassDeclaration decl)
           
 OJClass unwrappedPrimitive()
          Obtains the real type class if this class represents a primitive wrapper type.
 void waitTranslation(OJClass clazz)
          Waits a callee-side translation on another class metaobject to be done.
 void writeMetaInfo(Writer out)
          inner use only
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

substance

private OJClassImp substance
Constructor Detail

OJClass

public OJClass(Environment outer_env,
               OJClass declarer,
               ClassDeclaration ptree)
Generates a metaobject from source code.

This constructor will be invoked by the OpenJava system. In inheriting this class, you must call this consturctor from a constructor with the same signature in your class.

For example, in defining a subclass YourClass derived from this class, at least you have to write as follows:

 public YourClass( Environment outer_env, OJClass declarer,
                   ClassDeclaration ptree ) {
     super( outer_env, declarer, ptree );
 }
 

Parameters:
outer_env - environment of this class metaobject
declarer - the class metaobject declaring this class metaobject.
ptree - the parse tree representing this class metaobject.

OJClass

public OJClass(Class java_class,
               MetaInfo metainfo)
Generates a metaobject from byte code.

This constructor will be invoked only by the OpenJava system. In inheriting this class, you must call this consturctor from a constructor with the same signature in your class.

For example, in defining a subclass YourClass derived from this class, at least you have to write as follows:

 public YourClass( Class java_class, MetaInfo metainfo ) {
     super( java_class, metainfo );
 }
 


OJClass

private OJClass(OJClass componentType)
For arrays


OJClass

OJClass()
For dummy type of null object. This should be called only once by OJSystem.initConstants().

Method Detail

arrayOf

public static OJClass arrayOf(OJClass componentType)

forName

public static OJClass forName(String name)
                       throws OJClassNotFoundException
Returns the OJClass object associated with the class with the given string name. Given the fully-qualified name for a class or interface, this method attempts to locate, load and link the class. If it succeeds, returns the Class object representing the class. If it fails, the method throws a OJClassNotFoundException.

For example, the following code fragment returns the runtime OJClass descriptor for the class named java.lang.Thread:

Returns:
the OJClass descriptor for the class with the specified name.
Throws:
OJClassNotFoundException - if the class could not be found.
Since:
%SOFTWARE% 1.0

lookupFromByteCode

private static final OJClass lookupFromByteCode(String name)

replaceDotWithDollar

public static final String replaceDotWithDollar(String base,
                                                int i)

isArrayName

private static final boolean isArrayName(String name)

stripBrackets

private static final String stripBrackets(String ojcname)

nameForJavaClassName

private static final String nameForJavaClassName(String jcname)

nameToJavaClassName

private static final String nameToJavaClassName(String ojcname)

arrayForClasses

static OJClass[] arrayForClasses(Class[] jclasses)

toClasses

static Class[] toClasses(OJClass[] classes)

forClass

public static OJClass forClass(Class javaClass)
Converts a OJClass object to an OJClass object.

This method returns the same OJClass object whenever it is invoked for the same Classobject. It gurantees one-to-one correspondence between Class and OJClass.


lookupFromMetaInfo

private static final OJClass lookupFromMetaInfo(Class javaClass)

forParseTree

public static OJClass forParseTree(Environment env,
                                   OJClass declaringClass,
                                   ClassDeclaration ptree)
                            throws AmbiguousClassesException,
                                   ClassNotFoundException
Converts ParseTree objects to an OJClass object. The generated OJClass object is to be registered as globally asscessible class but not to appear as generated source code.

AmbiguousClassesException
ClassNotFoundException

forObject

public static OJClass forObject(Object obj)

makeExpression

protected static final Expression makeExpression(Environment env,
                                                 String str)
                                          throws MOPException
Generates a expression parse tree from a given String object under the given environment.

Parameters:
env - an environment for the source code.
str - a fragment of source code representing an expression.
Returns:
an expression parse tree
MOPException

makeExpression

protected final Expression makeExpression(String str)
                                   throws MOPException
Generates an expression parse tree from a given String object under the environment of this class object.

Parameters:
str - a fragment of source code representing an expression.
Returns:
an expression parse tree
MOPException

makeStatement

protected static final Statement makeStatement(Environment env,
                                               String str)
                                        throws MOPException
Generates a statement parse tree from a given String object under the given environment.

Parameters:
env - an environment for the source code.
str - a fragment of source code representing a statement.
Returns:
a statement parse tree
MOPException

makeStatement

protected final Statement makeStatement(String str)
                                 throws MOPException
Generates a statement parse tree from a given String object under the environment of this class object.

Parameters:
str - a fragment of source code representing a statement.
Returns:
a statement parse tree
MOPException

makeStatementList

protected static final StatementList makeStatementList(Environment env,
                                                       String str)
                                                throws MOPException
Generates a statement list parse tree from a given String object under the given environment.

Parameters:
env - an environment for the source code.
str - a fragment of source code representing a statement list.
Returns:
a statement list parse tree
MOPException

makeStatementList

protected final StatementList makeStatementList(String str)
                                         throws MOPException
Generates a statement list parse tree from a given String object under the environment of this class object.

Parameters:
str - a fragment of source code representing a statement list.
Returns:
a statement list parse tree
MOPException

toString

public String toString()
Converts the object to a string. The string representation is the string "class" or "interface", followed by a space, and then by the fully qualified name of the class in the format returned by getName. If this OJClass object represents a primitive type, this method returns the name of the primitive type. If this OJClass object represents void this method returns "void".

Overrides:
toString in class Object
Returns:
a string representation of this class object.

getEnvironment

public Environment getEnvironment()
Obtains an environment of this class object. This environment has information about members and outr environments such as packages but not local information like local variable in methods of this class.

Specified by:
getEnvironment in interface OJMember
Returns:
an environment of this class object.

newInstance

public Object newInstance()
                   throws InstantiationException,
                          IllegalAccessException,
                          CannotExecuteException
InstantiationException
IllegalAccessException
CannotExecuteException

isInstance

public boolean isInstance(Object obj)

isAssignableFrom

public boolean isAssignableFrom(OJClass clazz)
Determines if the class or interface represented by this OJClass object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified OJClass parameter. It returns true if so; otherwise it returns false. If this OJClass object represents a primitive type, this method returns true if the type represented by this OJClass object can accept the type represented by the specified OJClass parameter; otherwise it returns false.

Specifically, this method tests whether the type represented by the specified OJClass parameter can be converted to the type represented by this OJClass object via an identity conversion or via a widening reference/primitive conversion.

The behavior about primitive types is different from the method of the same name of java.lang.Class.

Throws:
NullPointerException - if the specified class parameter is null.

primitiveTypeWidth

private static int primitiveTypeWidth(OJClass ptype)

isInterface

public boolean isInterface()
Determines if the specified OJClass object represents an interface type.

Returns:
true if this object represents an interface; false otherwise.

isArray

public boolean isArray()
Determines if this OJClass object represents an array class.

Returns:
true if this object represents an array class; false otherwise.

isPrimitive

public boolean isPrimitive()
Determines if the specified OJClass object represents a primitive type.

There are nine predefined OJClass objects to represent the eight primitive types and void. These are created by the Java Virtual Machine, and have the same names as the primitive types that they represent, namely boolean, byte, char, short, int, long, float, and double.

These objects may be accessed via the following public static final variables, and are the only OJClass objects for which this method returns true.

Returns:
true if this object represents a primitive type; false otherwise.
See Also:
OJSystem.BOOLEAN, OJSystem.CHAR, OJSystem.BYTE, OJSystem.SHORT, OJSystem.INT, OJSystem.LONG, OJSystem.FLOAT, OJSystem.DOUBLE, OJSystem.VOID

isPrimitiveWrapper

public boolean isPrimitiveWrapper()
Determines if the specified OJClass object represents a wrapper class for a primitive type.

Returns:
true if this object represents a wrapper class for a primitive type; false otherwise.

primitiveWrapper

public OJClass primitiveWrapper()
Obtains the wrapper class if this class represents a primitive type.

For example this method returns java.lang.Integer for int.

Returns:
The wrapper class for this primitive type. null for void.

unwrappedPrimitive

public OJClass unwrappedPrimitive()
Obtains the real type class if this class represents a primitive wrapper type.

For example this method returns int for java.lang.Integer.

Returns:
The real primitive type for this primitive wrapper class.

getName

public String getName()
Returns the fully-qualified name of the entity (class, interface, array class, primitive type, or void) represented by this OJClass object, as a String.

If this OJClass object represents a class of arrays, then the internal form of the name consists of the name of the element type in Java signature format, followed by one or more "[]" characters representing the depth of array nesting. This representation differs from that of java.lang.Class.forName(). Thus:

 OJClass.forClass( (new int[3][4]).getClass() ).getName()
 
returns "java.lang.Object[]" and:
 OJClass.forClass( (new int[3][4]).getClass() ).getName()
 
returns "int[][]".

The class or interface name classname is given in fully qualified form as shown in the example above.

Specified by:
getName in interface OJMember
Returns:
the fully qualified name of the class or interface represented by this object.

getSimpleName

public String getSimpleName()
Returns the simple name of the class, interface or array class represented by this OJClass object, as a String. Thus:
 OJClass.forClass( (new Object[3]).getClass() ).getName()
 
returns "Object".

Returns:
the simple name of the class or interface represented by this object.

getPackage

public String getPackage()
Gets the package name for this class as a String. Null is returned if its package was not specified in source code of this class.

Returns:
the package name of the class, or null if its package was not specified in source code.

isInSamePackage

public boolean isInSamePackage(OJClass c)
Determines if the specified class object is in the same package as this class object.

If null is given, this method returns alway false.

Parameters:
c - the class object to test against this class object.
Returns:
true in case that both class is is the sample package.

getClassLoader

public ClassLoader getClassLoader()
                           throws CannotInspectException
CannotInspectException

getSuperclass

public OJClass getSuperclass()
Returns the OJClass representing the superclass of the entity (class, interface, primitive type or void) represented by this OJClass. If this OJClass represents either the java.lang.Object class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the OJClass object representing the java.lang.Object class is returned.

Returns:
the superclass of the class represented by this object.

getInterfaces

public OJClass[] getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object.

If this object represents a class, the return value is an array containing objects representing all interfaces implemented by the class. The order of the interface objects in the array corresponds to the order of the interface names in the implements clause of the declaration of the class represented by this object. For example, given the declaration:

 class Shimmer implements FloorWax, DessertTopping { ... }
 
suppose the value of clazz is an class object for the class Shimmer; the value of the expression:
 clazz.getInterfaces()[0]
 
is the OJClass object that represents interface FloorWax; and the value of:
 clazz.getInterfaces()[1]
 
is the OJClass object that represents interface DessertTopping.

If this object represents an interface, the array contains objects representing all interfaces extended by the interface. The order of the interface objects in the array corresponds to the order of the interface names in the extends clause of the declaration of the interface represented by this object.

If this object represents a class or interface that implements no interfaces, the method returns an array of length 0.

If this object represents a primitive type or void, the method returns an array of length 0.

To be getDeclaredInterfaces().

Returns:
an array of interfaces implemented by this class object.

getComponentType

public OJClass getComponentType()
Returns the OJClass representing the component type of an array. If this class does not represent an array class this method returns null.

Returns:
the class object representing the type of component of this array.

getModifiers

public OJModifier getModifiers()
Returns the Java language modifiers and the user defined modifiers for this class or interface, as a OJModifier object.

If the underlying class is an array class, then its public, private and protected modifiers are the same as those of its component type. If this OJClass represents a primitive type or void, its public modifier is always true, and its protected and private modifers are always false. If this object represents an array class, a primitive type or void, then its final modifier is always true and its interface modifer is always false. The values of its other modifiers are not determined by this specification.

Specified by:
getModifiers in interface OJMember
Returns:
the OJModifier object representing the modifiers of this class object
See Also:
OJModifier

getSuffix

public ParseTree getSuffix(String keyword)
Obtains an parse tree of suffix in extended syntax starting with the specified keyword. Returned openjava.ptree.ParseTree object has a structure built by an openjava.syntax.SyntaxRule object returned via the method getDeclSuffixRule(String).

Returns:
the parse tree
See Also:
getDeclSuffixRule(String), SyntaxRule

getSigners

public Object[] getSigners()
                    throws CannotExecuteException
CannotExecuteException

getDeclaringClass

public OJClass getDeclaringClass()
If the class or interface represented by this OJClass object is a member of another class, returns the OJClass object representing the class in which it was declared. This method returns null if this class or interface is not a member of any other class. If this OJClass object represents an array class, a primitive type, or void, then this method returns null.

Specified by:
getDeclaringClass in interface OJMember
Returns:
the class object declaring this class object.

getAllClasses

public final OJClass[] getAllClasses()

getAllFields

public final OJField[] getAllFields()

getAllMethods

public final OJMethod[] getAllMethods()

getInheritedClasses

public OJClass[] getInheritedClasses()

getInheritedFields

public OJField[] getInheritedFields()

getInheritedMethods

public final OJMethod[] getInheritedMethods()

getInheritableClasses

public final OJClass[] getInheritableClasses()
Deprecated.  

Use getInheritableClasses(OJClass)

See Also:
getInheritableClasses(OJClass)

getInheritableFields

public final OJField[] getInheritableFields()
Deprecated.  

Use getInheritableFields(OJClass)

See Also:
getInheritableFields(OJClass)

getInheritableMethods

public final OJMethod[] getInheritableMethods()
Deprecated.  

Use getInheritableMethods(OJClass)

See Also:
getInheritableMethods(OJClass)

getInheritableClasses

public OJClass[] getInheritableClasses(OJClass situation)

getInheritableFields

public OJField[] getInheritableFields(OJClass situation)

getInheritableMethods

public OJMethod[] getInheritableMethods(OJClass situation)

getInheritableConstructors

public OJConstructor[] getInheritableConstructors(OJClass situation)

overridesOn

private static final OJClass[] overridesOn(OJClass[] declareds,
                                           OJClass[] bases)

overridesOn

private static final OJField[] overridesOn(OJField[] declareds,
                                           OJField[] bases)

overridesOn

private static final OJMethod[] overridesOn(OJMethod[] declareds,
                                            OJMethod[] bases)

removeThePrivates

private static final OJClass[] removeThePrivates(OJClass[] src_classes)

removeThePrivates

private static final OJField[] removeThePrivates(OJField[] src_fields)

removeThePrivates

private static final OJMethod[] removeThePrivates(OJMethod[] src_methods)

removeThePrivates

private static final OJConstructor[] removeThePrivates(OJConstructor[] src_constrs)

removeTheDefaults

private static final OJClass[] removeTheDefaults(OJClass[] src_classes)

removeTheDefaults

private static final OJField[] removeTheDefaults(OJField[] src_fields)

removeTheDefaults

private static final OJMethod[] removeTheDefaults(OJMethod[] src_methods)

removeTheDefaults

private static final OJConstructor[] removeTheDefaults(OJConstructor[] src_constrs)

removeTheNonPublics

private static final OJClass[] removeTheNonPublics(OJClass[] src_classes)

removeTheNonPublics

private static final OJField[] removeTheNonPublics(OJField[] src_fields)

removeTheNonPublics

private static final OJMethod[] removeTheNonPublics(OJMethod[] src_methods)

removeTheNonPublics

private static final OJConstructor[] removeTheNonPublics(OJConstructor[] src_constrs)

pickupMethodsByName

private static final OJMethod[] pickupMethodsByName(OJMethod[] src_methods,
                                                    String name)

pickupField

private static final OJField pickupField(OJField[] src_fields,
                                         String name)

pickupMethod

private static final OJMethod pickupMethod(OJMethod[] src_methods,
                                           String name,
                                           OJClass[] parameterTypes)

pickupConstructor

private static final OJConstructor pickupConstructor(OJConstructor[] src_constrs,
                                                     OJClass[] parameterTypes)

pickupAcceptableMethod

private static final OJMethod pickupAcceptableMethod(OJMethod[] src_methods,
                                                     String name,
                                                     OJClass[] parameterTypes)

pickupAcceptableConstructor

private static final OJConstructor pickupAcceptableConstructor(OJConstructor[] src_constrs,
                                                               OJClass[] parameterTypes)

getClasses

public OJClass[] getClasses()
Returns an array containing OJClass objects representing all the public classes and interfaces that are members of the class represented by this OJClass object. This includes public class and interface members inherited from superclasses and public class and interface members declared by the class. This method returns an array of length 0 if this OJClass object has no public member classes or interfaces. This method also returns an array of length 0 if this OJClass object represents a primitive type, an array class, or void.


getFields

public OJField[] getFields()
Returns an array containing OJField objects reflecting all the accessible public fields of the class or interface represented by this OJClass object. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface has no accessible public fields, or if it represents an array class, a primitive type, or void.

Specifically, if this OJClass object represents a class, this method returns the public fields of this class and of all its superclasses. If this OJClass object represents an interface, this method returns the fields of this interface and of all its superinterfaces.

The implicit length field for array classs is reflected by this method.

See Also:
OJField

getMethods

public OJMethod[] getMethods()
Returns an array containing OJMethod objects reflecting all the public member methods of the class or interface represented by this OJClass object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if this OJClass object represents a class or interface that has no public member methods, or if this OJClass object represents an array class, primitive type, or void.

See Also:
OJMethod

getConstructors

public OJConstructor[] getConstructors()
Returns an array containing OJConstructor objects reflecting all the public constructors of the class represented by this OJClass object. An array of length 0 is returned if the class has no public constructors, or if the class is an array class, or if the class reflects a primitive type or void.

See Also:
OJConstructor

getField

public OJField getField(String name)
                 throws NoSuchMemberException
Returns a OJField object that reflects the specified public member field of the class or interface represented by this OJClass object. The name parameter is a String specifying the simple name of the desired field.

Throws:
NoSuchMemberException - if a field with the specified name is not found.
See Also:
OJField

getMethod

public OJMethod getMethod(String name,
                          OJClass[] parameterTypes)
                   throws NoSuchMemberException
Returns a OJMethod object that reflects the specified public member method of the class or interface represented by this OJClass object. The name parameter is a String specifying the simple name the desired method. The parameterTypes parameter is an array of OJClass objects that identify the method's formal parameter types, in declared order. If parameterTypes is null, it is treated as if it were an empty array.

Throws:
NoSuchMemberException - if a matching method is not found or if then name is "<init>"or "<clinit>".
See Also:
OJMethod

getConstructor

public OJConstructor getConstructor(OJClass[] parameterTypes)
                             throws NoSuchMemberException
Returns a OJConstructor object that reflects the specified public constructor of the class represented by this OJClass object. The parameterTypes parameter is an array of OJClass objects that identify the constructor's formal parameter types, in declared order.

The constructor to reflect is the public constructor of the class represented by this OJClass object whose formal parameter types match those specified by parameterTypes.

Throws:
NoSuchMemberException - if a matching method is not found.
See Also:
OJConstructor

getClasses

public final OJClass[] getClasses(OJClass situation)
Returns an array containing OJClass objects representing all the classes and interfaces which are members of the class represented by this OJClass object, accessible from the situation represented by the given OJClass object. This includes class and interface members inherited from superclasses and declared class and interface members accessible from the given situation. This method returns an array of length 0 if this OJClass object has no public member classes or interfaces. This method also returns an array of length 0 if this OJClass object represents a primitive type, an array class, or void.

The accessiblity depends on the package of the class, modifiers of each members, and the package of the situation.


getFields

public final OJField[] getFields(OJClass situation)
Returns an array containing OJField objects reflecting all the fields of the class or interface represented by this OJClass object, accessible from the situation represented by the given OJClass object. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface has no accessible public fields, or if it represents an array class, a primitive type, or void.

Specifically, if this OJClass object represents a class, this method returns the public fields of this class and of all its superclasses. If this OJClass object represents an interface, this method returns the fields of this interface and of all its superinterfaces.

The accessiblity depends on the package of the class, modifiers of each members, and the package of the situation.

The implicit length field for array classs is reflected by this method.

See Also:
OJField

getMethods

public final OJMethod[] getMethods(OJClass situation)
Returns an array containing OJMethod objects reflecting all the member methods of the class or interface represented by this OJClass object, accesible from the situation represented by the given OJClass object. Returned methods include those declared by the class or interface and and those inherited from superclasses and superinterfaces. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if this OJClass object represents a class or interface that has no public member methods, or if this OJClass object represents an array class, primitive type, or void.

The accessiblity depends on the package of the class, modifiers of each members, and the package of the situation.

See Also:
OJMethod

getConstructors

public final OJConstructor[] getConstructors(OJClass situation)
Returns an array containing OJConstructor objects reflecting all the constructors of the class represented by this OJClass object, accesible from the situation represented by the given OJClass object. An array of length 0 is returned if the class has no public constructors, or if the class is an array class, or if the class reflects a primitive type or void.

The accessiblity depends on the package of the class, modifiers of each members, and the package of the situation.

See Also:
OJConstructor

getField

public OJField getField(String name,
                        OJClass situation)
                 throws NoSuchMemberException
Returns a OJField object that reflects the specified member field accesible from the situation represented by the given OJClass object. The name parameter is a String specifying the simple name of the desired field.

Throws:
NoSuchMemberException - if a field with the specified name is not found.
See Also:
OJField

getMethod

public OJMethod getMethod(String name,
                          OJClass[] parameterTypes,
                          OJClass situation)
                   throws NoSuchMemberException
Returns a OJMethod object that reflects the specified member method accesible from the situation represented by the given OJClass object. The name parameter is a String specifying the simple name the desired method. The parameterTypes parameter is an array of OJClass objects that identify the method's formal parameter types, in declared order. If parameterTypes is null, it is treated as if it were an empty array.

Throws:
NoSuchMemberException - if a matching method is not found.
See Also:
OJMethod

getConstructor

public OJConstructor getConstructor(OJClass[] parameterTypes,
                                    OJClass situation)
                             throws NoSuchMemberException
Returns a OJConstructor object that reflects the specified constructor accesible from the situation represented by the given OJClass object. The parameterTypes parameter is an array of OJClass objects that identify the constructor's formal parameter types, in declared order.

The constructor to reflect is the constructor of the class represented by this OJClass object whose formal parameter types match those specified by parameterTypes.

Throws:
NoSuchMemberException - if a matching method is not found.
See Also:
OJConstructor

getAllField

public final OJField getAllField(String name)
                          throws NoSuchMemberException
Deprecated.  

Use c.getField(name,c)

NoSuchMemberException
See Also:
getField(String,OJClass)

getAllMethods

public final OJMethod[] getAllMethods(String name)
Deprecated.  


getAllMethod

public final OJMethod getAllMethod(String name,
                                   OJClass[] parameterTypes)
                            throws NoSuchMemberException
Deprecated.  

Use c.getMethod(name,ptypes,c)

NoSuchMemberException
See Also:
getMethod(String,OJClass[],OJClass)

getAcceptableMethod

public OJMethod getAcceptableMethod(String name,
                                    OJClass[] parameterTypes,
                                    OJClass situation)
                             throws NoSuchMemberException
Can be overriden

NoSuchMemberException

getAcceptableConstructor

public OJConstructor getAcceptableConstructor(OJClass[] parameterTypes,
                                              OJClass situation)
                                       throws NoSuchMemberException
Can be overriden

NoSuchMemberException

getDeclaredClasses

public OJClass[] getDeclaredClasses()
Returns an array of OJClass objects reflecting all the classes and interfaces declared as members of the class represented by this OJClass object. This includes public, protected, default (package) access, and private classes and interfaces declared by the class, but excludes inherited classes and interfaces. This method returns an array of length 0 if the class declares no classes or interfaces as members, or if this OJClass object represents a primitive type, an array class, or void.

This method may be overriden to provide proper information in the extended language.


getDeclaredFields

public OJField[] getDeclaredFields()
Returns an array of OJField objects reflecting all the fields declared by the class or interface represented by this OJClass object. This includes public, protected, default (package) access, and private fields, but excludes inherited fields. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no fields, or if this OJClass object represents a primitive type, an array class, or void.

This method may be overriden to provide proper information in the extended language.

See Also:
OJField

getDeclaredMethods

public OJMethod[] getDeclaredMethods()
Returns an array of OJMethod objects reflecting all the methods declared by the class or interface represented by this OJClass object. This includes public, protected, default (package) access, and private methods, but excludes inherited methods. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no methods, or if this OJClass object represents a primitive type, an array class, or void. The class initialization method <clinit> is not included in the returned array. If the class declares multiple public member methods with the same parameter types, they are all included in the returned array.

This method may be overriden to provide proper information in the extended language.

See Also:
OJMethod

getDeclaredConstructors

public OJConstructor[] getDeclaredConstructors()
Returns an array of OJConstructor objects reflecting all the constructors declared by the class represented by this OJClass object. These are public, protected, default (package) access, and private constructors. The elements in the array returned are not sorted and are not in any particular order. If the class has a default constructor, it is included in the returned array. This method returns an array of length 0 if this OJClass object represents an interface, a primitive type, an array class, or void.

This method may be overriden to provide proper information in the extended language.

See Also:
OJConstructor

getDeclaredField

public final OJField getDeclaredField(String name)
                               throws NoSuchMemberException
Returns a OJField object that reflects the specified declared field of the class or interface represented by this OJClass object. The name parameter is a String that specifies the simple name of the desired field. Note that this method will reflect the length field of an array class.

Throws:
NoSuchMemberException - if a field with the specified name is not found.
See Also:
OJField

getDeclaredMethod

public final OJMethod getDeclaredMethod(String name,
                                        OJClass[] parameterTypes)
                                 throws NoSuchMemberException
Returns a OJMethod object that reflects the specified declared method of the class or interface represented by this OJClass object. The name parameter is a String that specifies the simple name of the desired method, and the parameterTypes parameter is an array of OJClass objects that identify the method's formal parameter types, in declared order. If more than one method with the same parameter types is declared in a class, and one of these methods has a return type that is more specific than any of the others, that method is returned; otherwise one of the methods is chosen arbitrarily.

Throws:
NoSuchMemberException - if a matching method is not found.
See Also:
OJMethod

getDeclaredConstructor

public final OJConstructor getDeclaredConstructor(OJClass[] parameterTypes)
                                           throws NoSuchMemberException
Returns a OJConstructor object that reflects the specified constructor of the class or interface represented by this OJClass object. The parameterTypes parameter is an array of OJClass objects that identify the constructor's formal parameter types, in declared order.

Throws:
NoSuchMemberException - if a matching method is not found.
See Also:
OJConstructor

getResourceAsStream

public InputStream getResourceAsStream(String name)
                                throws CannotInspectException
CannotInspectException

getResource

public URL getResource(String name)
                throws CannotInspectException
CannotInspectException

makeCopy

public OJClass makeCopy(String qname)
                 throws MOPException
Generate a copy of this class object with the specified name.

Parameters:
qname - a qualified name for the new copy.
MOPException

isExecutable

public boolean isExecutable()

isAlterable

public boolean isAlterable()

getByteCode

public Class getByteCode()
                  throws CannotExecuteException
CannotExecuteException

getSourceCode

public ClassDeclaration getSourceCode()
                               throws CannotAlterException
CannotAlterException

getCompatibleJavaClass

public Class getCompatibleJavaClass()

signature

public Signature signature()
Specified by:
signature in interface OJMember

setDeclaringClass

void setDeclaringClass(OJClass parent)
                 throws CannotAlterException
CannotAlterException

waitTranslation

public final void waitTranslation(OJClass clazz)
                           throws MOPException
Waits a callee-side translation on another class metaobject to be done.

Parameters:
clazz - a class metaobject to wait
MOPException

setName

protected String setName(String simple_name)
                  throws CannotAlterException
not implemented yet

CannotAlterException

setSuperclass

protected OJClass setSuperclass(OJClass clazz)
                         throws CannotAlterException
CannotAlterException

setInterfaces

protected OJClass[] setInterfaces(OJClass[] classes)
                           throws CannotAlterException
CannotAlterException

addInterface

protected void addInterface(OJClass clazz)
                     throws CannotAlterException
CannotAlterException

addClass

public OJClass addClass(OJClass clazz)
                 throws CannotAlterException
CannotAlterException

removeClass

protected OJClass removeClass(OJClass clazz)
                       throws CannotAlterException
CannotAlterException

addField

public OJField addField(OJField field)
                 throws CannotAlterException
CannotAlterException

removeField

public OJField removeField(OJField field)
                    throws CannotAlterException
CannotAlterException

addMethod

protected OJMethod addMethod(OJMethod method)
                      throws CannotAlterException
CannotAlterException

removeMethod

protected OJMethod removeMethod(OJMethod method)
                         throws CannotAlterException
CannotAlterException

addConstructor

protected OJConstructor addConstructor(OJConstructor constr)
                                throws CannotAlterException
CannotAlterException

removeConstructor

protected OJConstructor removeConstructor(OJConstructor constr)
                                   throws CannotAlterException
CannotAlterException

translateDefinition

public void translateDefinition()
                         throws MOPException
MOPException

translateDefinition

public ClassDeclaration translateDefinition(Environment env,
                                            ClassDeclaration decl)
                                     throws MOPException
MOPException

expandFieldRead

public Expression expandFieldRead(Environment env,
                                  FieldAccess expr)

expandFieldWrite

public Expression expandFieldWrite(Environment env,
                                   AssignmentExpression expr)

expandMethodCall

public Expression expandMethodCall(Environment env,
                                   MethodCall expr)

expandTypeName

public TypeName expandTypeName(Environment env,
                               TypeName expr)

expandAllocation

public Expression expandAllocation(Environment env,
                                   AllocationExpression expr)

expandArrayAllocation

public Expression expandArrayAllocation(Environment env,
                                        ArrayAllocationExpression expr)

expandArrayAccess

public Expression expandArrayAccess(Environment env,
                                    ArrayAccess expr)

expandAssignmentExpression

public Expression expandAssignmentExpression(Environment env,
                                             AssignmentExpression expr)

expandExpression

public Expression expandExpression(Environment env,
                                   Expression expr)

expandVariableDeclaration

public Statement expandVariableDeclaration(Environment env,
                                           VariableDeclaration decl)

expandCastExpression

public Expression expandCastExpression(Environment env,
                                       CastExpression decl)

expandCastedExpression

public Expression expandCastedExpression(Environment env,
                                         CastExpression decl)

resolveException

public OJField resolveException(NoSuchMemberException e,
                                String name)
                         throws NoSuchMemberException
NoSuchMemberException

resolveException

public OJMethod resolveException(NoSuchMemberException e,
                                 String name,
                                 OJClass[] argtypes)
                          throws NoSuchMemberException
NoSuchMemberException

isRegisteredKeyword

public static boolean isRegisteredKeyword(String keyword)

getDeclSuffixRule

public static SyntaxRule getDeclSuffixRule(String keyword)

getTypeSuffixRule

public static SyntaxRule getTypeSuffixRule(String keyword)

isRegisteredModifier

public static boolean isRegisteredModifier(String keyword)

getMetaInfo

public final String getMetaInfo(String key)

getMetaInfoKeys

public final Enumeration getMetaInfoKeys()

getMetaInfoElements

public final Enumeration getMetaInfoElements()

putMetaInfo

protected final String putMetaInfo(String key,
                                   String value)
                            throws CannotAlterException
CannotAlterException

writeMetaInfo

public final void writeMetaInfo(Writer out)
                         throws IOException
inner use only

IOException

SourceForge.net_Logo