Java Doc for ClassGeneratorUtil.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » bsh » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jEdit » org.gjt.sp.jedit.bsh 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.gjt.sp.jedit.bsh.ClassGeneratorUtil

ClassGeneratorUtil
public class ClassGeneratorUtil implements Constants(Code)
ClassGeneratorUtil utilizes the ASM (www.objectweb.org) bytecode generator by Eric Bruneton in order to generate class "stubs" for BeanShell at runtime.

Stub classes contain all of the fields of a BeanShell scripted class as well as two "callback" references to BeanShell namespaces: one for static methods and one for instance methods. Methods of the class are delegators which invoke corresponding methods on either the static or instance bsh object and then unpack and return the results. The static namespace utilizes a static import to delegate variable access to the class' static fields. The instance namespace utilizes a dynamic import (i.e. mixin) to delegate variable access to the class' instance variables.

Constructors for the class delegate to the static initInstance() method of ClassGeneratorUtil to initialize new instances of the object. initInstance() invokes the instance intializer code (init vars and instance blocks) and then delegates to the corresponding scripted constructor method in the instance namespace. Constructors contain special switch logic which allows the BeanShell to control the calling of alternate constructors (this() or super() references) at runtime.

Specially named superclass delegator methods are also generated in order to allow BeanShell to access overridden methods of the superclass (which reflection does not normally allow).


author:
   Pat Niemeyer


Inner Class :public static class ConstructorArgs

Field Summary
final static  StringBSHCONSTRUCTORS
    
final static  StringBSHINIT
    
final static  StringBSHSTATIC
    
final static  StringBSHSUPER
     The prefix for the name of the super delegate methods.
final static  StringBSHTHIS
    
final static  intDEFAULTCONSTRUCTOR
     The switch branch number for the default constructor.
final static  StringOBJECT
    
 ModifiersclassModifiers
    
 StringclassName
    
 NameSpaceclassStaticNameSpace
    
 DelayedEvalBshMethod[]constructors
    
 StringfqClassName
     fully qualified class name (with package) e.g.
 Class[]interfaces
    
 booleanisInterface
    
 DelayedEvalBshMethod[]methods
    
 ClasssuperClass
    
 StringsuperClassName
    
 Constructor[]superConstructors
    
 Variable[]vars
    

Constructor Summary
public  ClassGeneratorUtil(Modifiers classModifiers, String className, String packageName, Class superClass, Class[] interfaces, Variable[] vars, DelayedEvalBshMethod[] bshmethods, NameSpace classStaticNameSpace, boolean isInterface)
    
Parameters:
  packageName - e.g.

Method Summary
 booleanclassContainsMethod(Class clas, String methodName, String[] paramTypes)
    
static  voiddoSwitchBranch(int index, String targetClassName, String[] paramTypes, Label endLabel, Label[] labels, int consArgsVar, CodeVisitor cv)
    
public  byte[]generateClass()
     Generate the class bytecode for this class.
 voidgenerateConstructor(int index, String[] paramTypes, int modifiers, ClassWriter cw)
     Generate a constructor.
 voidgenerateConstructorSwitch(int consIndex, int argsVar, int consArgsVar, CodeVisitor cv)
     Generate a switch with a branch for each possible alternate constructor.
static  voidgenerateField(String fieldName, String type, int modifiers, ClassWriter cw)
     Generate a field - static or instance.
static  voidgenerateMethod(String className, String fqClassName, String methodName, String returnType, String[] paramTypes, int modifiers, ClassWriter cw)
     Generate a delegate method - static or instance.
public static  voidgenerateParameterReifierCode(String[] paramTypes, boolean isStatic, CodeVisitor cv)
     Generates the code to reify the arguments of the given method.
static  voidgeneratePlainReturnCode(String returnType, CodeVisitor cv)
    
public static  voidgenerateReturnCode(String returnType, CodeVisitor cv)
     Generates the code to unreify the result of the given method.
static  voidgenerateSuperDelegateMethod(String superClassName, String methodName, String returnType, String[] paramTypes, int modifiers, ClassWriter cw)
     Generate a superclass method delegate accessor method.
static  intgetASMModifiers(Modifiers modifiers)
     Translate bsh.Modifiers into ASM modifier bitflags.
static  ThisgetClassInstanceThis(Object instance, String className)
     Get the instance bsh namespace field from the object instance.
static  ThisgetClassStaticThis(Class clas, String className)
     Get the static bsh namespace field from the class.
public static  ConstructorArgsgetConstructorArgs(String superClassName, This classStaticThis, Object[] consArgs, int index)
     Evaluate the arguments (if any) for the constructor specified by the constructor index.
static  StringgetMethodDescriptor(String returnType, String[] paramTypes)
    
static  String[]getTypeDescriptors(Class[] cparams)
    
public static  voidinitInstance(Object instance, String className, Object[] args)
     Initialize an instance of the class.

Field Detail
BSHCONSTRUCTORS
final static String BSHCONSTRUCTORS(Code)
The bsh static namespace variable that holds the constructor methods



BSHINIT
final static String BSHINIT(Code)
The bsh static namespace variable name of the instance initializer



BSHSTATIC
final static String BSHSTATIC(Code)
The name of the static field holding the reference to the bsh static This (the callback namespace for static methods)



BSHSUPER
final static String BSHSUPER(Code)
The prefix for the name of the super delegate methods. e.g. _bshSuperfoo() is equivalent to super.foo()



BSHTHIS
final static String BSHTHIS(Code)
The name of the instance field holding the reference to the bsh instance This (the callback namespace for instance methods)



DEFAULTCONSTRUCTOR
final static int DEFAULTCONSTRUCTOR(Code)
The switch branch number for the default constructor. The value -1 will cause the default branch to be taken.



OBJECT
final static String OBJECT(Code)



classModifiers
Modifiers classModifiers(Code)



className
String className(Code)



classStaticNameSpace
NameSpace classStaticNameSpace(Code)



constructors
DelayedEvalBshMethod[] constructors(Code)



fqClassName
String fqClassName(Code)
fully qualified class name (with package) e.g. foo/bar/Blah



interfaces
Class[] interfaces(Code)



isInterface
boolean isInterface(Code)



methods
DelayedEvalBshMethod[] methods(Code)



superClass
Class superClass(Code)



superClassName
String superClassName(Code)



superConstructors
Constructor[] superConstructors(Code)



vars
Variable[] vars(Code)




Constructor Detail
ClassGeneratorUtil
public ClassGeneratorUtil(Modifiers classModifiers, String className, String packageName, Class superClass, Class[] interfaces, Variable[] vars, DelayedEvalBshMethod[] bshmethods, NameSpace classStaticNameSpace, boolean isInterface)(Code)

Parameters:
  packageName - e.g. "com.foo.bar"




Method Detail
classContainsMethod
boolean classContainsMethod(Class clas, String methodName, String[] paramTypes)(Code)



doSwitchBranch
static void doSwitchBranch(int index, String targetClassName, String[] paramTypes, Label endLabel, Label[] labels, int consArgsVar, CodeVisitor cv)(Code)



generateClass
public byte[] generateClass()(Code)
Generate the class bytecode for this class.



generateConstructor
void generateConstructor(int index, String[] paramTypes, int modifiers, ClassWriter cw)(Code)
Generate a constructor.



generateConstructorSwitch
void generateConstructorSwitch(int consIndex, int argsVar, int consArgsVar, CodeVisitor cv)(Code)
Generate a switch with a branch for each possible alternate constructor. This includes all superclass constructors and all constructors of this class. The default branch of this switch is the default superclass constructor.

This method also generates the code to call the static ClassGeneratorUtil getConstructorArgs() method which inspects the scripted constructor to find the alternate constructor signature (if any) and evalute the arguments at runtime. The getConstructorArgs() method returns the actual arguments as well as the index of the constructor to call.




generateField
static void generateField(String fieldName, String type, int modifiers, ClassWriter cw)(Code)
Generate a field - static or instance.



generateMethod
static void generateMethod(String className, String fqClassName, String methodName, String returnType, String[] paramTypes, int modifiers, ClassWriter cw)(Code)
Generate a delegate method - static or instance. The generated code packs the method arguments into an object array (wrapping primitive types in bsh.Primitive), invokes the static or instance namespace invokeMethod() method, and then unwraps / returns the result.



generateParameterReifierCode
public static void generateParameterReifierCode(String[] paramTypes, boolean isStatic, CodeVisitor cv)(Code)
Generates the code to reify the arguments of the given method. For a method "int m (int i, String s)", this code is the bytecode corresponding to the "new Object[] { new bsh.Primitive(i), s }" expression.
author:
   Eric Bruneton
author:
   Pat Niemeyer
Parameters:
  cv - the code visitor to be used to generate the bytecode.
Parameters:
  isStatic - the enclosing methods is static



generatePlainReturnCode
static void generatePlainReturnCode(String returnType, CodeVisitor cv)(Code)
Generate return code for a normal bytecode



generateReturnCode
public static void generateReturnCode(String returnType, CodeVisitor cv)(Code)
Generates the code to unreify the result of the given method. For a method "int m (int i, String s)", this code is the bytecode corresponding to the "((Integer)...).intValue()" expression.
Parameters:
  cv - the code visitor to be used to generate the bytecode.
author:
   Eric Bruneton
author:
   Pat Niemeyer



generateSuperDelegateMethod
static void generateSuperDelegateMethod(String superClassName, String methodName, String returnType, String[] paramTypes, int modifiers, ClassWriter cw)(Code)
Generate a superclass method delegate accessor method. These methods are specially named methods which allow access to overridden methods of the superclass (which the Java reflection API normally does not allow).



getASMModifiers
static int getASMModifiers(Modifiers modifiers)(Code)
Translate bsh.Modifiers into ASM modifier bitflags.



getClassInstanceThis
static This getClassInstanceThis(Object instance, String className)(Code)
Get the instance bsh namespace field from the object instance. the class instance This object or null if the object has notbeen initialized.



getClassStaticThis
static This getClassStaticThis(Class clas, String className)(Code)
Get the static bsh namespace field from the class.
Parameters:
  className - may be the name of clas itself or a superclass of clas.



getConstructorArgs
public static ConstructorArgs getConstructorArgs(String superClassName, This classStaticThis, Object[] consArgs, int index)(Code)
Evaluate the arguments (if any) for the constructor specified by the constructor index. Return the ConstructorArgs object which contains the actual arguments to the alternate constructor and also the index of that constructor for the constructor switch.
Parameters:
  consArgs - the arguments to the constructor. These are necessary inthe evaluation of the alt constructor args. e.g. Foo(a) { super(a); } the ConstructorArgs object containing a constructor selectorand evaluated arguments for the alternate constructor



getMethodDescriptor
static String getMethodDescriptor(String returnType, String[] paramTypes)(Code)



getTypeDescriptors
static String[] getTypeDescriptors(Class[] cparams)(Code)



initInstance
public static void initInstance(Object instance, String className, Object[] args)(Code)
Initialize an instance of the class. This method is called from the generated class constructor to evaluate the instance initializer and scripted constructor in the instance namespace.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.