public static Class generateClassImpl(String name,Modifiers modifiers,Class[] interfaces,Class superClass,BSHBlock block,boolean isInterface,CallStack callstack,Interpreter interpreter) throws EvalError {
  try {
    Capabilities.setAccessibility(true);
  }
 catch (  Capabilities.Unavailable e) {
    throw new EvalError("Defining classes currently requires reflective Accessibility.",block,callstack);
  }
  NameSpace enclosingNameSpace=callstack.top();
  String packageName=enclosingNameSpace.getPackage();
  String className=enclosingNameSpace.isClass ? (enclosingNameSpace.getName() + "$" + name) : name;
  String fqClassName=packageName == null ? className : packageName + "." + className;
  String bshStaticFieldName=ClassGeneratorUtil.BSHSTATIC + className;
  BshClassManager bcm=interpreter.getClassManager();
  bcm.definingClass(fqClassName);
  NameSpace classStaticNameSpace=new NameSpace(enclosingNameSpace,className);
  classStaticNameSpace.isClass=true;
  callstack.push(classStaticNameSpace);
  block.evalBlock(callstack,interpreter,true,ClassNodeFilter.CLASSCLASSES);
  Variable[] variables=getDeclaredVariables(block,callstack,interpreter,packageName);
  DelayedEvalBshMethod[] methods=getDeclaredMethods(block,callstack,interpreter,packageName);
  ClassGeneratorUtil classGenerator=new ClassGeneratorUtil(modifiers,className,packageName,superClass,interfaces,variables,methods,isInterface);
  Class clas=bcm.getAssociatedClass(fqClassName);
  if (clas == null) {
    byte[] code=classGenerator.generateClass(Interpreter.getSaveClasses());
    if (Interpreter.getSaveClasses())     saveClasses(className,code);
 else     clas=bcm.defineClass(fqClassName,code);
  }
  if (!Interpreter.getSaveClasses()) {
    classGenerator.initStaticNameSpace(classStaticNameSpace,block);
    enclosingNameSpace.importClass(fqClassName.replace('$','.'));
    classStaticNameSpace.setClassStatic(clas);
    block.evalBlock(callstack,interpreter,true,ClassNodeFilter.CLASSSTATIC);
    if (!clas.isInterface())     installStaticBlock(clas,bshStaticFieldName,classStaticNameSpace,interpreter);
  }
  callstack.pop();
  bcm.doneDefiningClass(fqClassName);
  return clas;
}

public static Class generateClassImpl ( String name , Modifiers modifiers , Class [ ] interfaces , Class superClass , BSHBlock block , boolean isInterface , CallStack callstack , Interpreter interpreter ) throws EvalError { try { Capabilities . setAccessibility ( true ) ; } catch ( Capabilities . Unavailable e ) { throw new EvalError ( "Defining classes currently requires reflective Accessibility." , block , callstack ) ; } NameSpace enclosingNameSpace = callstack . top ( ) ; String packageName = enclosingNameSpace . getPackage ( ) ; String className = enclosingNameSpace . isClass ? ( enclosingNameSpace . getName ( ) + "$" + name ) : name ; String fqClassName = packageName == null ? className : packageName + "." + className ; String bshStaticFieldName = ClassGeneratorUtil . BSHSTATIC + className ; BshClassManager bcm = interpreter . getClassManager ( ) ; bcm . definingClass ( fqClassName ) ; NameSpace classStaticNameSpace = new NameSpace ( enclosingNameSpace , className ) ; classStaticNameSpace . isClass = true ; callstack . push ( classStaticNameSpace ) ; block . evalBlock ( callstack , interpreter , true , ClassNodeFilter . CLASSCLASSES ) ; Variable [ ] variables = getDeclaredVariables ( block , callstack , interpreter , packageName ) ; DelayedEvalBshMethod [ ] methods = getDeclaredMethods ( block , callstack , interpreter , packageName ) ; ClassGeneratorUtil classGenerator = new ClassGeneratorUtil ( modifiers , className , packageName , superClass , interfaces , variables , methods , isInterface ) ; Class clas = bcm . getAssociatedClass ( fqClassName ) ; if ( clas == null ) { byte [ ] code = classGenerator . generateClass ( Interpreter . getSaveClasses ( ) ) ; if ( Interpreter . getSaveClasses ( ) ) saveClasses ( className , code ) ; else clas = bcm . defineClass ( fqClassName , code ) ; } if ( ! Interpreter . getSaveClasses ( ) ) { classGenerator . initStaticNameSpace ( classStaticNameSpace , block ) ; enclosingNameSpace . importClass ( fqClassName . replace ( '$' , '.' ) ) ; classStaticNameSpace . setClassStatic ( clas ) ; block . evalBlock ( callstack , interpreter , true , ClassNodeFilter . CLASSSTATIC ) ; if ( ! clas . isInterface ( ) ) installStaticBlock ( clas , bshStaticFieldName , classStaticNameSpace , interpreter ) ; } callstack . pop ( ) ; bcm . doneDefiningClass ( fqClassName ) ; return clas ; }
if necessary , parse the bshblock for for the class definition and generate the class using classgeneratorutil . this method also initializes the static block namespace and sets it in the class .
