org.codehaus.janino

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 » Scripting » jacl » org.codehaus.janino 
org.codehaus.janino
Java Source File NameTypeComment
Access.javaClass Return value for IClass.IMember.getAccess .
AstCompilationUnitGenerator.javaInterface
ByteArrayClassLoader.javaClass This ClassLoader allows for the loading of a set of JavaTM classes provided in class file format.
CachingJavaSourceClassLoader.javaClass A org.codehaus.janino.JavaSourceClassLoader that uses a resource storage provided by the application to cache compiled classes and thus saving unnecessary recompilations.
ClassBodyEvaluator.javaClass Parses a class body and returns it as a java.lang.Class object ready for use with java.lang.reflect.

Example:

 import java.util.*;
 static private int a = 1;
 private int b = 2;
 public void func(int c, int d) {
 return func2(c, d);
 }
 private static void func2(int e, int f) {
 return e * f;
 }
 

The optionalClassLoader serves two purposes:

  • It is used to look for classes referenced by the class body.
  • It is used to load the generated JavaTM class into the JVM; directly if it is a subclass of ByteArrayClassLoader , or by creation of a temporary ByteArrayClassLoader if not.
To set up a ClassBodyEvaluator object, proceed as follows:
  1. Create the ClassBodyEvaluator using ClassBodyEvaluator.ClassBodyEvaluator()
  2. Configure the ClassBodyEvaluator by calling any of the following methods:
  3. Call any of the org.codehaus.janino.Cookable.cook(Scanner) methods to scan, parse, compile and load the class body into the JVM.
Alternatively, a number of "convenience constructors" exist that execute the steps described above instantly.

To compile a class body and immediately instantiate an object, one of the ClassBodyEvaluator.createFastClassBodyEvaluator(Scanner,Class,ClassLoader) methods can be used.

The generated class may optionally extend/implement a given type; the returned instance can safely be type-casted to that optionalBaseType.

Example:

 public interface Foo {
 int bar(int a, int b);
 }
 ...
 Foo f = (Foo) ClassBodyEvaluator.createFastClassBodyEvaluator(
 new Scanner(null, new StringReader("public int bar(int a, int b) { return a + b; }")),
 Foo.class,                  // Base type to extend/implement
 (ClassLoader) null          // Use current thread's context class loader
 );
 System.out.println("1 + 2 = " + f.bar(1, 2));
 
Notice: The optionalBaseType must be accessible from the generated class, i.e.
ClassFileIClass.javaClass A wrapper object that turns a ClassFile object into a IClass .
ClassLoaderIClassLoader.javaClass An IClassLoader that loads IClass es through a reflection ClassLoader .
CodeContext.javaClass The context of the compilation of a function (constructor or method).
CompileException.javaClass An exception that reflects an error during compilation.
Compiler.javaClass A simplified substitute for the javac tool.
Cookable.javaClass "Cooking" means scanning a sequence of JavaTM tokens with a org.codehaus.janino.Scanner .
DebuggingInformation.javaClass
Descriptor.javaClass
ExpressionEvaluator.javaClass An expression evaluator that evaluates expressions in JavaTM bytecode.

The syntax of the expression to compile is that of a JavaTM expression, as defined in the Java Language Specification, 2nd edition, section 15. Notice that a JavaTM expression does not have a concluding semicolon.

Example:

 a + 7 * b
(Notice that this expression refers to two parameters "a" and "b", as explained below.)

The expression may optionally be preceeded with a sequence of import directives like

 import java.text.*;
 new DecimalFormat("####,###.##").format(10200020.345345)
 
(Notice that the import directive is concluded with a semicolon, while the expression is not.)

The expression evaluator is implemented by creating and compiling a temporary compilation unit defining one class with one static method with one return statement.

To set up an ExpressionEvaluator object, proceed as follows:

  1. Create the ExpressionEvaluator using ExpressionEvaluator.ExpressionEvaluator()
  2. Configure the ExpressionEvaluator by calling any of the following methods:
  3. Call any of the org.codehaus.janino.Cookable.cook(Scanner) methods to scan, parse, compile and load the expression into the JVM.
Alternatively, a number of "convenience constructors" exist that execute the steps described above instantly.

After the ExpressionEvaluator object is set up, the expression can be evaluated as often with different parameter values (see ExpressionEvaluator.evaluate(Object[]) ).

FilterWarningHandler.javaClass
IClass.javaClass A simplified equivalent to "java.lang.reflect".
IClassLoader.javaClass Loads an IClass by type name.
Java.javaClass This wrapper class defines classes that represent the elements of the JavaTM programming language.
JavaSourceClassLoader.javaClass A ClassLoader that, unlike usual ClassLoader s, does not load byte code, but reads JavaTM source code and then scans, parses, compiles and loads it into the virtual machine.
JavaSourceIClassLoader.javaClass This org.codehaus.janino.IClassLoader finds, scans and parses compilation units.
Location.javaClass Represents the location of a character in a file, as defined by file name, line number and column number.
MethodDescriptor.javaClass Representation of a "method descriptor" (JVMS 4.3.3).
Mod.javaClass This class defines constants and convenience methods for the handling of modifiers as defined by the JVM.
Opcode.javaInterface Definitions of Java bytecode opcodes.
Parser.javaClass A parser for the JavaTM programming language.
ReflectionIClass.javaClass Wraps a java.lang.Class in an org.codehaus.janino.IClass .
ResourceFinderIClassLoader.javaClass This org.codehaus.janino.IClassLoader loads IClasses through a a org.codehaus.janino.util.resource.ResourceFinder that designates org.codehaus.janino.util.ClassFile s.
Scanner.javaClass Splits up a character stream into tokens and returns them as java.lang.String String objects.
ScriptEvaluator.javaClass A script evaluator that executes a script in JavaTM bytecode.

The syntax of the script to compile is a sequence of import declarations followed by a sequence of statements, as defined in the Java Language Specification, 2nd edition, sections 7.5 and 14.

Example:

 import java.text.*;
 System.out.println("HELLO");
 System.out.println(new DecimalFormat("####,###.##").format(a));
 
(Notice that this expression refers to a parameter "a", as explained below.)

The script may complete abnormally, e.g.

SimpleCompiler.javaClass A simplified version of Compiler that can compile only a single compilation unit.
UnicodeUnescapeException.javaClass Represents a problem that occurred while unescaping a unicode escape sequence through a org.codehaus.janino.UnicodeUnescapeReader .
UnicodeUnescapeReader.javaClass A FilterReader that unescapes the "Unicode Escapes" as described in the Java Language Specification, 2nd edition.

Notice that it is possible to formulate invalid escape sequences, e.g. "\u123g" ("g" is not a valid hex character).

UnitCompiler.javaClass This class actually implements the JavaTM compiler.
UnparseVisitor.javaClass A visitor that unparses (un-compiles) an AST to a Writer .
Visitor.javaClass Basis for the "visitor" pattern as described in "Gamma, Helm, Johnson, Vlissides: Design Patterns".
WarningHandler.javaInterface Interface type for UnitCompiler.setWarningHandler(WarningHandler) .
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.