Java Doc for MethodBuilder.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » services » compiler » 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 » Database DBMS » db derby 10.2 » org.apache.derby.iapi.services.compiler 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.derby.iapi.services.compiler.MethodBuilder

All known Subclasses:   org.apache.derby.impl.services.bytecode.BCMethod,
MethodBuilder
public interface MethodBuilder (Code)
MethodBuilder is used to generate the code for a method.

The code for a method is built in a way that corresponds to the layout of the stack machine that is the Java Virtual Machine. Values are pushed on the stack, moved about on the stack and then popped off the stack by operations such as method calls. An understanding of hoe the JVM operates is useful before using this class.

All the method descriptions below are generating bytecode to achieved the desired behaviour when the generated class is loaded. None of this class's methods calls actually invoke methods or create objects described by the callers.





Method Summary
public  voidaddThrownException(String exceptionClass)
     Declare the method throws an exception.
public  intcallMethod(short type, String declaringClass, String methodName, String returnType, int numArgs)
     Call a method.
public  intcallMethod(Object methodDescriptor)
     Call a method previously described by describeMethod().
public  voidcallSuper()
     Call super().
public  voidcast(String className)
     Cast the top stack value.
public  voidcomplete()
     Indicate the method is complete.
public  voidcompleteConditional()
     Complete a conditional which completes the false code path.
public  voidconditionalIf()
     Initiate a conditional sequence. The top value on the stack must be a boolean and will be popped.
public  voidconditionalIfNull()
     Initiate a conditional sequence. The top value on the stack (a reference) is popped and compared to 'null'. If the value is null then the code following this call until the startElseCode() will be executed at runtime, otherwise the code following startElseCode() until the completeConditional() is called.
E.g.
public  ObjectdescribeMethod(short opcode, String declaringClass, String methodName, String returnType)
     Return an object that efficiently (to the implementation) describes a zero-argument method and can be used with the single argument callMethod().
public  voiddup()
     Duplicate the top value on the stack.
public  voidendStatement()
     End a statement.
public  voidgetArrayElement(int element)
     Pop an array refrence off the stack and push an element from that array.
public  voidgetField(LocalField field)
     Push the contents of the local field onto the stack. This call pushes the this instance required to access the field itself.
 Stack ...
public  voidgetField(String declaringClass, String fieldName, String fieldType)
     Push the contents of the described field onto the stack.
public  StringgetName()
     return the name of the method.
public  voidgetParameter(int id)
     Push a parameter value.
 Stack ...
public  voidgetStaticField(String declaringClass, String fieldName, String fieldType)
     Push the contents of the described static field onto the stack.
 Stack ...
public  voidisInstanceOf(String className)
     Pop the top stack value and push a boolean that is the result of an instanceof check on the popped reference.
public  voidmethodReturn()
     Return from a method, optionally with a value. Must only be called if zero or one item exists on the stack.
public  voidpop()
     Pop the top value off the stack
 Stack ..., value =>
 ...
public  voidpush(byte value)
     Push a byte constant onto the stack
 Stack ...
public  voidpush(boolean value)
     Push a boolean constant onto the stack
 Stack ...
public  voidpush(short value)
     Push a short constant onto the stack
 Stack ...
public  voidpush(int value)
     Push a int constant onto the stack
 Stack ...
public  voidpush(long value)
     Push a long constant onto the stack
 Stack ...
public  voidpush(float value)
     Push a float constant onto the stack
 Stack ...
public  voidpush(double value)
     Push a double constant onto the stack
 Stack ...
public  voidpush(String value)
     Push a String constant onto the stack
 Stack ...
public  voidpushNewArray(String className, int size)
     Create an instance of an array and push it onto the stack.
public  voidpushNewComplete(int numArgs)
     Complete the sequence that was started with pushNewStart().
public  voidpushNewStart(String className)
     Initiate a sequence that calls a constructor, equivalent to the new operator in Java. After this call, the caller must push any arguments and then complete the construction with a call to pushNewComplete().
public  voidpushNull(String className)
     Push a typed null onto the stack
 Stack ...
public  voidpushThis()
     Push this onto the stack.
 Stack ...
public  voidputField(LocalField field)
     Pop the top stack value and store it in the local field.
public  voidputField(String fieldName, String fieldType)
     Pop the top stack value and store it in the instance field of this class.
public  voidputField(String declaringClass, String fieldName, String fieldType)
     Pop the top stack value and store it in the field.
public  voidsetArrayElement(int element)
     Pop an array reference off the stack, store a value in the array at the passed in offset.
public  voidsetField(LocalField field)
     Pop the top stack value and store it in the local field.
public  voidstartElseCode()
     Complete the true code path of a conditional.
public  booleanstatementNumHitLimit(int noStatementsAdded)
     Tell if statement number in this method builder hits limit.
public  voidswap()
     Swap the top two values on the stack.
public  voidupCast(String className)
     Upcast the top stack value.



Method Detail
addThrownException
public void addThrownException(String exceptionClass)(Code)
Declare the method throws an exception. Must be called before any code is added to the method.



callMethod
public int callMethod(short type, String declaringClass, String methodName, String returnType, int numArgs)(Code)
Call a method. The instance (receiver or reference) for non-static methods must be pushed by the caller. The instance (for non-static) and the arguments are popped of the stack, and the return value (if any) is pushed onto the stack.
The type needs to be one of:
  • VMOpcode.INVOKESTATIC - call a static method
  • VMOpcode.INVOKEVIRTUAL - call method declared in the class or super-class.
  • VMOpcode.INVOKEINTERFACE - call a method declared in an interface
 static methods
 Stack ...,value* => [numArgs number of values will be popped]
 ...,return_value [void methods will not push a value]
 non-static methods
 Stack ...,ref,value* => [numArgs number of values will be popped]
 ...,return_value [void methods will not push a value]
 

The type of the arguments to the methods must exactly match the declared types of the parameters to the methods. If a argument is of the incorrect type the caller must up cast it or down cast it.
Parameters:
  type - type of method invocation
Parameters:
  declaringClass - Class or interface the method is declared in. If it is a non-staticmethod call then if declaringClass is null, the declared type is taken to be thetype of the reference that will be popped.
Parameters:
  methodName - name of the method
Parameters:
  returnType - class name or primitive type (including "void") of the return type of the method, can not be null.
Parameters:
  numArgs - number of arguments to the method (can be 0).



callMethod
public int callMethod(Object methodDescriptor)(Code)
Call a method previously described by describeMethod().
 static methods
 Stack ...,value* => [numArgs number of values will be popped]
 ...,return_value [void methods will not push a value]
 non-static methods
 Stack ...,ref,value* => [numArgs number of values will be popped]
 ...,return_value [void methods will not push a value]
 



callSuper
public void callSuper()(Code)
Call super(). Caller must only add this to a constructor.
 Stack ... =>
 ... 
 



cast
public void cast(String className)(Code)
Cast the top stack value. Correctly down-casts a reference or casts a primitive type (e.g. int to short).
 Stack ...,value =>
 ...,cast_value
 

Parameters:
  className - type (primitive, interface or class) to cast to.



complete
public void complete()(Code)
Indicate the method is complete. Once this call has been made the caller must discard the reference to this object.



completeConditional
public void completeConditional()(Code)
Complete a conditional which completes the false code path.



conditionalIf
public void conditionalIf()(Code)
Initiate a conditional sequence. The top value on the stack must be a boolean and will be popped. If it is true then the code following this call until the startElseCode() will be executed at runtime, otherwise the code following startElseCode() until the completeConditional() is called. See conditionalIfNull() for example and restrictions.
 Stack ...,boolean_value =>
 ...
 
.



conditionalIfNull
public void conditionalIfNull()(Code)
Initiate a conditional sequence. The top value on the stack (a reference) is popped and compared to 'null'. If the value is null then the code following this call until the startElseCode() will be executed at runtime, otherwise the code following startElseCode() until the completeConditional() is called.
E.g.
 mb.callMethod(...); // pushes an object onto the stack
 mb.conditionalIfNull();
 mb.push(3);
 mb.startElseCode();
 mb.push(5);
 mb.completeConditional();
 // at this point 3 or 5 will be on the stack
 
Each path through the ?: statement must leave the stack at the same depth as the other.
If the if or else code pops values from the stack that were before the conditional value, then they must use the same number of values from the stack.
 Stack ...,ref =>
 ...
 
.



describeMethod
public Object describeMethod(short opcode, String declaringClass, String methodName, String returnType)(Code)
Return an object that efficiently (to the implementation) describes a zero-argument method and can be used with the single argument callMethod(). Descriptions for the parameters to this method are the same as the five argument callMethod(). This allows the caller to cache frequently used methods. The returned object is only valid for use by this MethodBuilder.
This call does not affect the Stack.



dup
public void dup()(Code)
Duplicate the top value on the stack.
 Stack ...,value =>
 ...,value,value
 



endStatement
public void endStatement()(Code)
End a statement. Pops the top-word of the stack, if any. Must only be called if zero or one item exists on the stack.
 Stack value =>
 :empty:
 or
 Stack :empty: =>
 :empty:
 
.



getArrayElement
public void getArrayElement(int element)(Code)
Pop an array refrence off the stack and push an element from that array.
 Stack ...,array_ref =>
 ...,value
 

Parameters:
  element - Offset into the array (zero based)



getField
public void getField(LocalField field)(Code)
Push the contents of the local field onto the stack. This call pushes the this instance required to access the field itself.
 Stack ...  =>
 ...,field_value
 



getField
public void getField(String declaringClass, String fieldName, String fieldType)(Code)
Push the contents of the described field onto the stack. This call requires the instance (reference) to be pushed by the caller.
 Stack ...,field_ref  =>
 ...,field_value
 



getName
public String getName()(Code)
return the name of the method.



getParameter
public void getParameter(int id)(Code)
Push a parameter value.
 Stack ...  =>
 ...,param_value
 

Parameters:
  id - position of the parameter (zero based).



getStaticField
public void getStaticField(String declaringClass, String fieldName, String fieldType)(Code)
Push the contents of the described static field onto the stack.
 Stack ...  =>
 ...,field_value
 



isInstanceOf
public void isInstanceOf(String className)(Code)
Pop the top stack value and push a boolean that is the result of an instanceof check on the popped reference.
 Stack ...,ref =>
 ...,boolean_value
 
.



methodReturn
public void methodReturn()(Code)
Return from a method, optionally with a value. Must only be called if zero or one item exists on the stack. If the stack contains a single value then that is popped and used as the returned value.
 Stack value =>
 :empty:
 or
 Stack :empty: =>
 :empty:
 
.



pop
public void pop()(Code)
Pop the top value off the stack
 Stack ..., value =>
 ...
 
.



push
public void push(byte value)(Code)
Push a byte constant onto the stack
 Stack ...  =>
 ...,byte_value
 



push
public void push(boolean value)(Code)
Push a boolean constant onto the stack
 Stack ...  =>
 ...,boolean_value
 



push
public void push(short value)(Code)
Push a short constant onto the stack
 Stack ...  =>
 ...,short_value
 



push
public void push(int value)(Code)
Push a int constant onto the stack
 Stack ...  =>
 ...,int_value
 



push
public void push(long value)(Code)
Push a long constant onto the stack
 Stack ...  =>
 ...,long_value
 



push
public void push(float value)(Code)
Push a float constant onto the stack
 Stack ...  =>
 ...,float_value
 



push
public void push(double value)(Code)
Push a double constant onto the stack
 Stack ...  =>
 ...,double_value
 



push
public void push(String value)(Code)
Push a String constant onto the stack
 Stack ...  =>
 ...,String_value
 



pushNewArray
public void pushNewArray(String className, int size)(Code)
Create an instance of an array and push it onto the stack.
 Stack ...  =>
 ...,array_ref
 

Parameters:
  className - - type of array.
Parameters:
  size - - number of elements in the array



pushNewComplete
public void pushNewComplete(int numArgs)(Code)
Complete the sequence that was started with pushNewStart(). Pop the arguments to the constructor and push the reference to the newly created object.
 Stack ...,value* => [numArgs number of values will be popped]
 ...,new_ref
 

Parameters:
  numArgs - number of arguments to the constructor (can be 0).



pushNewStart
public void pushNewStart(String className)(Code)
Initiate a sequence that calls a constructor, equivalent to the new operator in Java. After this call, the caller must push any arguments and then complete the construction with a call to pushNewComplete(). Only arguments to the constructor can be pushed onto the stack between the pushNewStart() and pushNewComplete() method calls.
 Stack ... => [unchanged]
 ...
 

Parameters:
  className - class name of object to be created.



pushNull
public void pushNull(String className)(Code)
Push a typed null onto the stack
 Stack ...  =>
 ...,null
 



pushThis
public void pushThis()(Code)
Push this onto the stack.
 Stack ...  =>
 ...,this_ref
 



putField
public void putField(LocalField field)(Code)
Pop the top stack value and store it in the local field. This call pushes the this instance required to access the field itself. Like the Java language 'field = value', this leaves the value on the stack.
 Stack ...,value  =>
 ...,value
 



putField
public void putField(String fieldName, String fieldType)(Code)
Pop the top stack value and store it in the instance field of this class. This call pushes the this instance required to access the field itself. Like the Java language 'field = value', this leaves the value on the stack.
 Stack ...,value  =>
 ...,value
 



putField
public void putField(String declaringClass, String fieldName, String fieldType)(Code)
Pop the top stack value and store it in the field. This call requires the instance to be pushed by the caller. Like the Java language 'field = value', this leaves the value on the stack.
 Stack ...,field_ref,value  =>
 ...,value
 



setArrayElement
public void setArrayElement(int element)(Code)
Pop an array reference off the stack, store a value in the array at the passed in offset.
 Stack ...,array_ref, value =>
 ...
 

Parameters:
  element - Offset into the array (zero based)



setField
public void setField(LocalField field)(Code)
Pop the top stack value and store it in the local field. This call pushes the this instance required to access the field itself. This call does not leave any value on the stack.
 Stack ...,value  =>
 ...
 



startElseCode
public void startElseCode()(Code)
Complete the true code path of a conditional.



statementNumHitLimit
public boolean statementNumHitLimit(int noStatementsAdded)(Code)
Tell if statement number in this method builder hits limit. This method builder keeps a counter of how many statements are added to it. Caller should call this function every time it tries to add a statement to this method builder (counter is increased by 1), then the function returns whether the accumulated statement number hits a limit. The reason of doing this is that Java compiler has a limit of 64K code size for each method. We might hit this limit if an extremely long insert statement is issued, for example (see beetle 4293). Counting statement number is an approximation without too much overhead.



swap
public void swap()(Code)
Swap the top two values on the stack.
 Stack ...,valueA,valueB =>
 ...,valueB,valueA
 



upCast
public void upCast(String className)(Code)
Upcast the top stack value. This is used for correct method resolution by upcasting method parameters. It does not put any casting code into the byte code stream. Can only be used for refrences.
 Stack ...,ref =>
 ...,ref
 



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