buildtools/nasgen/README

Thu, 30 May 2013 10:58:35 -0700

author
katleman
date
Thu, 30 May 2013 10:58:35 -0700
changeset 261
1c7481ac7fe0
parent 0
b1a7da25b547
permissions
-rw-r--r--

Added tag jdk8-b92 for changeset dee23cce5235

     1 Nasgen is a tool for processing Java classes that implement native
     2 JavaScript objects. It does so by looking for the
     3 com.oracle.nashorn.objects.annotations.ScriptClass annotation and other
     4 annotations in that package.
     6 For each  class "C", nasgen instruments the original class and generates
     7 two additional classes: a "C$Prototype" class for the JavaScript
     8 prototype object, and a "C$Constructor" class for the JavaScript
     9 constructor function.
    11 Each class instrumented or generated by nasgen contains a private static
    12 "$nasgenmap$" field of type com.oracle.nashorn.runtime.PropertyMap and
    13 static initializer block to initialize the field to the object's
    14 JavaScript properties.
    16 Members annotated with @Function, @Property, @Getter, and @Setter are
    17 mapped to the $Constructor, $Prototype, or main class, depending on the
    18 value of the annotation's 'where' field. By default, @Property, @Getter,
    19 and @Setter belong to the main class while @Function methods without
    20 explicit 'where' field belong to the $Prototype class. The @Constructor
    21 annotation marks a method to be invoked as JavaScript constructor.
    23 Nasgen enforces all @Function/@Getter/@Setter/@Constructor annotated
    24 methods to be declared as static. Static final @Property fields remain
    25 in the main class while other @Property fields are moved to respective
    26 classes depending on the annotation's 'where' value. For functions
    27 mapped to the $Prototype or $Constructor class, nasgen also generates
    28 getters and setters prefixed by G$ and S$, respectively.
    30 Nasgen-generated classes are hidden from normal ClassLoaders by giving
    31 them a ".clazz" file name extension instead of the standard ".class"
    32 extension. This allows script classes to be loaded independently by each
    33 Nashorn context through the com.oracle.nashorn.runtime.StructureLoader
    34 class loader.

mercurial