Automatic discovery of a JavaScript API
AssigneeInternational Business Machines Corporation
InventorsYoav Ben-Yair, Gil Fuchs, Itai Gordon, Oren Paikowsky
Life of this patent
Estimating the term…
Loading patent…
AssigneeInternational Business Machines Corporation
InventorsYoav Ben-Yair, Gil Fuchs, Itai Gordon, Oren Paikowsky
Estimating the term…
An approach to creating a canonical representation of a JavaScript API. Objects associated with the JavaScript API are instantiated, creating entry points for analysis. A list of discovered objects is created based on parsing a document object model associated with the JavaScript API. The objects are instrumented and statically analyzed, creating an infrastructure associated with the JavaScript API. The infrastructure is updated based on analyzing the objects while the interface is being used and the objects are executing. A canonical representation, based on the updated infrastructure, is generated for further operations.
A computer system for creating a canonical representation of a JavaScript Application Programming Interface (API), the
Dependencies are inferred from the claim text.
Drawings are temporarily unavailable. Open the PDF at USPTO
From the US filing history. Foreign family members aren’t listed.
Abstract machines for program code execution, e.g. Java virtual machine [JVM], interpreters or emulators: embedded in an application, e.g.…
Creation or generation of source code: software reuse
Creation or generation of source code: compiler construction; Parser generation
Syntactic analysis: parsing
About 8 years 8 months of term left · ends 30 Jun 2035 (estimated)
The present invention relates generally to utilizing JavaScript Application Programming Interfaces (APIs) and more specifically, to optimizing the utilization of JavaScript APIs based on associated runtime platforms.
In recent years, the popularity of implementing systems with JavaScript has dramatically risen, with predictions that approximately 90% of all websites use JavaScript. Accordingly, many of these websites and their associated web applications expose JavaScript APIs for consumption by client applications on a variety of runtime platforms. With the ever present benchmark measurements of user experience and performance, consuming JavaScript APIs based on a native runtime environment of an associated platform becomes the desired path of implementation for client applications.
According to an embodiment of the present invention, a computer system for creating a canonical representation of a JavaScript API, the computer system comprising: one or more computer processors; one or more computer readable storage media; program instructions stored on the one or more computer readable storage media for execution by at least one of the one or more computer processors, the program instructions comprising: program instructions to instantiate a first one or more objects, associated with the JavaScript API, for use as one or more entry points to the JavaScript API; program instructions to generate a list of the first one or more objects based on recursively parsing a Document Object Model (DOM) associated with the JavaScript API and filtering the first one or more objects to include objects associated with the JavaScript API and to exclude objects specified in a preconfigured exclusion list; program instructions to instrument the first one or more objects for creating an infrastructure associated with the JavaScript API based on attaching a respective callback function to one or more class members for invocation each time each of the one or more class members are assigned a value, for determining a data type of each value, replacing one or more class functions with a respective first function that invokes a respective first callback function for analyzing input parameter types, based on a data type matrix, associated with a replaced function, invokes the replaced function and invokes a second callback function for determining a return type, based on a data type matrix, associated with the replaced function and replacing one or more constructors with a respective second function that invokes a respective third callback function for determining input parameter types associated with a replaced constructor and invokes the replaced constructor; program instructions to statically analyzing the first one or more objects for creating the infrastructure associated with the JavaScript API wherein statically analyzing comprises an analysis based on at least one of class hierarchy, one or more class members, one or more class functions and one or more class constructors; program instructions to create an updated infrastructure, based on substantially simultaneous execution and analysis of the first one or more objects and a second one or more objects created based on the execution of the first one or more objects wherein the updated infrastructure is a tree-like data structure and wherein one or more elements of the update infrastructure change positions based on at least one of determining a return type and one or more input parameter types; and program instructions to output an extensible markup language (XML) canonical representation of the JavaScript API based on the updated infrastructure.
FIG. 1 is a functional block diagram illustrating a JavaScript API producer and JavaScript API consumer processing environment, in accordance with an embodiment of the present invention;
FIG. 2 is a flowchart depicting operational steps of a JavaScript API discovery program, on a computing device within the data processing environment of FIG. 1, in accordance with an embodiment of the present invention;
FIG. 3 is a table depicting JavaScript API data type mappings, in accordance with an embodiment of the present invention; and
The embodiments depicted and described herein recognize the challenges of consuming a JavaScript API in a runtime platform different than the runtime platform of the JavaScript API producer. For example, consuming a Microsoft Windows Server JavaScript API from within an Apple, Incorporated iOS mobile application can result in embedding a copy of the JavaScript API object model and portions of the object model logic in the mobile application platform. Embedding a copy of the JavaScript API object model and its associated logic in the mobile application runtime platform can result in application failures because any subsequent updates to the object model or the JavaScript API should be copied to the platform embedding the object model and/or the JavaScript API to prevent interface synchronization problems.
Embodiments will now be described in detail with reference to the figures. It should be noted for the embodiments described herein that although JavaScript is the referenced programming language, the embodiments are not limited to the JavaScript programming language, i.e., the embodiments can be applied to other programming languages.
FIG. 1 is a functional block diagram illustrating, generally, an embodiment of a JavaScript API producer-consumer environment 100. The environment 100 comprises a JavaScript API producer 108 operating on a server computer 102, a JavaScript API consumer 110 operating on a client computer 104 and a network 106 supporting communications between the JavaScript API producer 108 and the JavaScript API consumer 110.