001 package bsh;
002
003 import bsh.Capabilities.Unavailable;
004 import java.lang.reflect.InvocationTargetException;
005
006 public abstract class ClassGenerator
007 {
008 private static ClassGenerator cg;
009
010 public static ClassGenerator getClassGenerator()
011 throws UtilEvalError
012 {
013 if ( cg == null )
014 {
015 try {
016 Class clas = Class.forName( "bsh.ClassGeneratorImpl" );
017 cg = (ClassGenerator)clas.newInstance();
018 } catch ( Exception e ) {
019 throw new Unavailable("ClassGenerator unavailable: "+e);
020 }
021 }
022
023 return cg;
024 }
025
026 /**
027 Parse the BSHBlock for the class definition and generate the class.
028 */
029 public abstract Class generateClass(
030 String name, Modifiers modifiers,
031 Class [] interfaces, Class superClass, BSHBlock block,
032 boolean isInterface, CallStack callstack, Interpreter interpreter
033 )
034 throws EvalError;
035
036 /**
037 Invoke a super.method() style superclass method on an object instance.
038 This is not a normal function of the Java reflection API and is
039 provided by generated class accessor methods.
040 */
041 public abstract Object invokeSuperclassMethod(
042 BshClassManager bcm, Object instance, String methodName, Object [] args
043 )
044 throws UtilEvalError, ReflectError, InvocationTargetException;
045
046 /**
047 Change the parent of the class instance namespace.
048 This is currently used for inner class support.
049 Note: This method will likely be removed in the future.
050 */
051 public abstract void setInstanceNameSpaceParent(
052 Object instance, String className, NameSpace parent );
053
054 }