Top Description Fields Methods
org.apache.derby.iapi.services.compiler

public Interface JavaFactory

Known Direct Implementers
org.apache.derby.impl.services.bytecode.BCJava
Imports
org.apache.derby.iapi.services.loader.ClassFactory

JavaFactory provides generators for Java constructs. Once Java constructs have been connected into a complete class definition, the class can be generated from them. The generated class is created as a byte-code array that can then be loaded by a class loader or, in our case, the class utilities wrapper around our special class loader.

Each method shows the equivalent Java in the line starting "Java:" in the header comment. Items in the java code that begin with # refer to parameters used in constructing the object. So, for example, newReturnStatement takes a parameter named value; its Java code is: Java: return #value;

This represents the fact that newReturnStatement returns a object that represents a return statement that returns the value represented by the parameter named value.

Revisit

when StandardException is moved to BasicServices, all of these want to support it so they can throw real NotImplementedYet exceptions. It is expected that alot of this interface can be not-implemented for engines that do not need this complete treatment of the language.

Known Java constructs missing from this interface include:

This interface also does not do real compilation -- there are no checks for things like initialization before use of variables, inclusion of catchs on throws, dead code, etc. Its purpose is to let other parts of the system piece together what they know is valid code and get bytecode out of doing that.

Also, implementations will require that the constructs be built appropriately or they may fail to produce a valid class. For example, newStaticMethodCall must be used to call static methods only, not non-static local instance methods.

Implementations may be more, or less strict. You are best off assuming you have to piece together each java construct and be as explicit as possible. So, constructors must be created with newConstructor, not newMethodBuilder; constructors must include the explicit call to super(...) or this(...), as their first statement; all methods and constructors must contain a final return statement at the end of their code path(s). Method calls will derive the method to call based on the type of the argument, so you must cast arguments as the system will not search for a close method and coerce arguments appropriately. This includes coercing them to be some superclass or interface that they already are.

Field Summary

Modifier and TypeField and Description
public static final String

Method Summary

Modifier and TypeMethod and Description
public ClassBuilder

Returns:

the class builder.
newClassBuilder
(ClassFactory
ClassFactory to be used for class resolution (debug only) and loading of the generated class.
cf
,
String
the name of the package the class is in including the trailing 'dot' if it is not the empty package. Pass the empty package as "".
packageName
,
int
the | of the Modifier constants representing the visibility and control of this method.
modifiers
,
String
the name of the class or interface
className
,
String
the name of the superclass or superinterface
superClass
)

a class.</verbatim>

Field Detail

JAVA_FACTORY_PROPERTYback to summary
public static final String JAVA_FACTORY_PROPERTY

Method Detail

newClassBuilderback to summary
public ClassBuilder newClassBuilder(ClassFactory cf, String packageName, int modifiers, String className, String superClass)

a class. Once it is created, fields, methods, interfaces, static initialization code, and constructors can be added to it. Java: package #packageName; #modifiers #className extends #superClass { } // modifiers is the | of the JVM constants for // the modifiers such as static, public, etc.

Parameters
cf:ClassFactory

ClassFactory to be used for class resolution (debug only) and loading of the generated class.

packageName:String

the name of the package the class is in including the trailing 'dot' if it is not the empty package. Pass the empty package as "".

modifiers:int

the | of the Modifier constants representing the visibility and control of this method.

className:String

the name of the class or interface

superClass:String

the name of the superclass or superinterface

Returns:ClassBuilder

the class builder.

See Also
java.lang.reflect.Modifier