Introduction

JS Standard Library is the key part of JScripter Libraries. It is more than just a Java library. With this library used, your Java application has become a JS applet: It has to fully comply with the JS Standard API & Re-compilation Specification. It will probably either be run with the support of JS Simulation Library on a web browser as a Java applet, or finally be re-compiled into pure JavaScript code by a JS re-compiler with the help of JS Emulation Library.

For the purposes of both simulation and re-compilation, JS has to, in addition to the access control from Java language, limit the usage of classes and class members by defining compatibility of software members. To JS, a Java software encloses its package collections; A package collection encloses its packages; A package encloses its classes, interfaces, and sub-packages; An interface or class encloses its inner classes and interfaces, its static and instance members including fields, methods and constructors; A field or a constructor encloses its declaration and definition; And a method encloses its declaration, and its definition (method body) if it is concrete.

JS specifies the compatibility of a software member into three levels: normal, opaque and internal. JS Standard Library contains a few opaque interfaces, several internal classes, a couple of base opaque classes, many extended opaque classes, and a lot more normal classes, all distinctively described in the documentation. Accessing software members violating their compatibility shall cause re-compilation failure.

An opaque member can be accessed freely wherever a normal one could be, but it is opaque to JS re-compilers that are required to treat it as just a name. Members of an opaque member are automatically opaque unless specified otherwise.

JS re-compilers will report errors on any operations causing to access the class data of opaque members.

Internal members are "internal" means they are only expected to be accessed "internally" in opaque members and other internal members. With this rule followed, an internal member is always isolated from and therefore invisible to JS re-compilers. Members of an internal member and subclasses of an internal class must be internal. Accessing the internal members outside of opaque members and internal members is prohibited.

JS re-compilers will report errors on any operations causing to resolve internal members.

Unless specified, the compatibility and usage of a member are inherited from the super class for a subclass, from the overridden method for an overriding method, or from the enclosing member for a member that is neither a subclass nor an overriding method. Obviously, a private member has no special usage and inherits compatibility from its enclosing member.

Without specified, a member is automatically normal, or compatible to both simulation environment and re-compilation process. The subclasses of a normal class must also be normal, but its superclass and members do not have to.

User defined packages are all normal and a user defined subclass automatically inherits compatibility from its superclass. That is, user defined classes are all normal except for the extended opaque classes.

Specially, Java primitive types are all "opaque". The class java.lang.String and Java basic classes that wrap the primitive types are also "primitive" in re-compilation and therefore are opaque too. The class java.lang.Object and the class java.lang.Class have obviously to be opaque to re-compilers but no class inherits the compatibility from java.lang.Object. The static main methods are always internal, where developers can initialize simulation, start applets and/or initiate re-compilation. The static main methods must be isolated completely from the re-compilation process, though the re-compilers themselves might have been started from there.

JS Standard Library is written in pure Java and requires JDK 1.5 or above.

Download

JS Standard Library is developed solely by J.J.Liu (Jianjun Liu) and released in open source under GNU General Public License Version 3.

You can choose desired downloads or download the latest all-in-one distribution (still beta) of JS Standard Library including source code and documentation by clicking on the following "Download" button after you have accepted the license agreement below:

I accept the above license agreement

JS Libraries

Documentation

Source Code

Related Projects

The following sites are related to this project.

JavaJavaScript provides JS applications that are good demonstration for JScripter Libraries.

JRecompiler is a free Java re-compiler for JScripter.