This invention relates generally to the field of searching for information in a computer system and in particular to caching of information related to finding classes.
A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever. The following notice applies to the software and data as described below and in the drawing hereto: Copyright® 1999, Microsoft Corporation, All Rights Reserved.
A class is the fundamental element of Java systems. They provide functions that support application programs and other programs that are written by developers. The classes, which may number in the thousands, reside in class files, which essentially are groupings of classes in containers. The containers may take a number of forms, typically including file system directories, archive files such as ZIP and JAR files, and in the case of Microsoft Corporation's Java VM implementation, they may also appear in a database of installed classes referred to as a Java Package Manager, which manages many attributes about the classes such as version, security and others. Any combination of these containers of classes, referred to as class path elements, can be put together in an order dependent list, known as the class path.
A class path is defined by use of an environment variable called ClassPath. ClassPath is used to define the order and places to search for classes when in an execution environment and in development environments. A class locator service, known as WS, or the Java Package Service, exposes an API which describes the class path as a single class source, with methods such as FindClass and EnumClasses regardless of the current configuration of the class path. These methods final all classes with a given name in all or a specified package, and enumerate all classes of given name respectively. However, they currently search through all the classes identified by the class path. When a JPS instance is created, it is initialized with a list of class path elements. For each element, a root object is created which represents the contents of the element. This object exposes an interface called IRoot, which has simple class location/enumeration methods, such as DoesClassExist, GetClass, and EnumClasses, each of which do what their names imply. Depending on the type of the element, a different implementation of a root object is created. For directory elements, a direct root object is created, whose IRoot method implementations result in direct searches of the root's underlying file system directory. For other elements, a root implementation that performs caching is created.
Since there are literally thousands of classes available for use when developing applications, it can be difficult to keep track of them. Further, many different containers are available from different companies or other organizations to support programming in Java. Each of the different containers may have classes with similar names and similar functions. In a development environment, it is necessary for a class location system to provide a list of all the existing classes to help the developer select a desired class for use. When a developer is writing or modifying an application, the list can be useful to help the developer determine which class to select.
There are three significant differences in the way that a class locator service is utilized in the development environment as opposed to the execution environment. First, the Java compiler must verify that classes do not appear in certain locations, and therefore must make requests for classes that probably do not exist. Second, the development environment must provide lists of all available classes in given packages, where a package is an organized sub-container of classes. These classes are referred to by their package name plus their class name. And, finally, the development environment needs to inspect a small portion of each class found to provide and display more detailed information about the class, such as its fields, methods and attributes.
Each of these three differences place a different efficiency requirement on the class locator. First, unsuccessful searches are speed critical. Second, fast enumeration of all classes is required. Third, the interesting information about a class must be easily and quickly obtainable from each class located. There is a need for a class location mechanism that can find classes in a fast and efficient manner. There is a further need for such a mechanism that operates with existing development environments.
Location of classes is facilitated by caching information about the classes in a class path comprising different collections of classes or places to search for classes. This cached information provides a much quicker way of searching for a class which is needed for instantiation and execution. The cache is constructed during non-speed critical times so that it is available for fast location of classes when needed. The cache is reconstructed when changes to the original information in the class path are detected.
In one aspect of the invention, only selected elements in a class path are cached. These elements are selected as those which have associated mechanisms to provide notification of changes. In this manner, the integrity of the cache can be maintained with little overhead involved in independent tracking of the class path elements. By keeping separate caches, reconstruction of a cache due to a detected change is limited to that cache only. Further the selection criteria can be modified such that only class path elements that are least likely to be changed are cached, and for which changes are easy to detect. This allows selectivity of elements to cache based on the overhead associated with caching the element.
In a further aspect of the invention, a class path manager is used to create caches for selected class path elements on instantiation of the path manager. It first parses the path into names of elements, and then decides whether the element is viable for caching. In one embodiment, only ZIP files are cached due to the ease of detection of change. The class path manager creates a wrapper for each element in the class path as identified by a classpath environment variable. The wrapper is used to provide a level of indirection when calls are made to determine the location of a class. If the element is not one which is viable to cache, standard system services are invoked to perform a search of the path of that element. If the element is one for which caching is viable, a caching wrapper is created which invokes methods to search the cache for that element. The indirection provided by the wrappers allows multiple different types of caches to be provided for elements without increasing the complexity of the class path manager, nor changing the normal calls from applications that need to find the class.
One example of a call that utilizes a cache is a code completion call. When a user is using an editor for writing a program and reaches a common delimiter, such as a period or space, it generates a code completion call, which the class path manager receives, and invokes each wrapper corresponding to elements in the class path. Given the information prior to the delimiter, classes matching or meeting that portion of the information are provided by using standard system services to search uncached elements, or by cache dependent search services for elements having a cache. Such elements currently comprise ZIP files, which can represent a significant number of the classes to be searched, and hence result in significant performance improvements.
In the following detailed description of exemplary embodiments of the invention, reference is made to the accompanying drawings which form a part hereof, and in which is shown by way of illustration specific exemplary embodiments in which the invention can be practiced. These embodiments are described in sufficient detail to enable those skilled in the art to practice the invention, and it is to be understood that other embodiments can be utilized and that logical, mechanical, electrical and other changes can be made without departing from the spirit or scope of the present invention. The following detailed description is, therefore, not to be taken in a limiting sense, and the scope of the present invention is defined only by the appended claims.
The detailed description is divided into multiple sections. A first section describes the operation of a computer system which implements the current invention of caching class information. This is followed by a description of a cache used to store information about elements in a class path, the use of separate caches for selected elements of the class path, and a method of indirection to permit the use by a development system of standard methods to find and enumerate classes. The operation of a class path manager in association with element wrappers to provide such indirection is then described followed by examples of the use of the class path manager to create and manage caches for selected class path elements. This is followed by a conclusion which describes some potential benefits and describes further alternative embodiments.
Program modules can be stored on the hard disk, magnetic disk 29, optical disk 31, ROM 24 and RAM 25. Program modules can include operating system 35, one or more application programs 36, other program modules 37, and program data 38. A user can enter commands and information into personal computer 20 through input devices such as a keyboard 40 and a pointing device 42. Other input devices (not shown) can include a microphone, joystick, game pad, satellite dish, scanner, or the like. These and other input devices are often connected to the processing unit 21 through a serial-port interface 46 coupled to system bus 23; but they can be connected through other interfaces not shown in
Personal computer 20 can operate in a networked environment using logical connections to one or more remote computers such as remote computer 49. Remote computer 49 can be another personal computer, a server, a router, a network PC, a peer device, or other common network node. It typically includes many or all of the components described above in connection with personal computer 20; however, only a storage device 50 is illustrated in
When placed in a LAN networking environment, PC 20 connects to local network 51 through a network interface or adapter 53. When used in a WAN networking environment such as the Internet, PC 20 typically includes modem 54 or other means for establishing communications over network 52. Modem 54 can be internal or external to PC 20, and connects to system bus 23 via serial-port interface 46. In a networked environment, program modules, such as those comprising Microsoft® Word which are depicted as residing within 20 or portions thereof can be stored in remote storage device 50. Of course, the network connections shown are illustrative, and other means of establishing a communications link between the computers can be substituted.
Software can be designed using many different methods, including object oriented programming methods. C++ and Java are two examples of common object oriented computer programming languages that provide functionality associated with object oriented programming. Object oriented programming methods provide a means to encapsulate data members (variables) and member functions (methods) that operate on that data into a single entity called a class. Object oriented programming methods also provide a means to create new classes based on existing classes.
An object is an instance of a class. The data members of an object are attributes that are stored inside the computer memory, and the methods are executable computer code that act upon this data, along with potentially providing other services. The notion of an object is exploited in the present invention in that certain aspects of the invention are implemented as objects in one embodiment.
An interface is a group of related functions that are organized into a named unit. Each interface can be uniquely identified by some identifier. Interfaces have no instantiation, that is, an interface is a definition only without the executable code needed to implement the methods which are specified by the interface. An object can support an interface by providing executable code for the methods specified by the interface. The executable code supplied by the object must comply with the definitions specified by the interface. The object can also provide additional methods. Those skilled in the art will recognize that interfaces are not limited to use in or by an object oriented programming environment.
A class path is defined by use of an environment variable called ClassPath. ClassPath is used to define the order and places to search for classes when in an execution environment and in development environments. A class locator service, known as JPS, or the Java Package Service, exposes an API which describes the class path as a single class source, with methods such as FindClass and EnumClasses regardless of the current configuration of the class path. These methods final all classes with a given name in all or a specified package, and enumerate all classes of given name respectively. However, they currently search through all the classes identified by the class path. When a JPS instance is created, it is initialized with a list of class path elements. For each element, a root object is created which represents the contents of the element. This object exposes an interface called Root, which has simple class location/enumeration methods, such as DoesClassExist, GetClass, and EnumClasses, each of which do what their names imply. Depending on the type of the element, a different implementation of a root object is created. For directory elements, a direct root object is created, whose IRoot method implementations result in direct searches of the root's underlying file system directory. For other elements, a root implementation that performs caching is created.
In
An example of a ClassPath definition is provided in
In one embodiment, a hash table can be used to represent the information that is cached. A unique ID (identifier) for each Name can be used, which is shorter than the actual name itself. Further entries can refer to the ID as opposed to the name, making the table more efficient. The cache can be in the form of a flat file, a relational database, or other format as desired. The type of cache used can be optimized if desired depending on the type of element.
A class path manager 320 is used to create wrappers 330, 332, and 334. Each wrapper is used to provide a level of indirection from the application program interfaces (APIs) used by the class locator service provided by Java. In other words, calls to such APIs, such as from a code completion class function 336 (a function which provides potential completions of statements that are being entered), are received by the class path manager 320 and provided to the wrappers for application to the class path elements. In one embodiment of the invention, each class path element can have an independent cache containing the same information as the cache in
Each wrapper 330, 332 and 334 receives the API calls from the class path manager without the need for changing the class path manager handling of such calls. In other words, the class path manager does not need to be changed from the prior manner in which it directly operated with the class path elements to cause them to be searched. The wrapper handles translation of the APIs into the proper form for searching the element, or the cache for that element if one exists. The wrappers provide a level of indirection to either location services provided by the system if no cache is used for the element corresponding to the wrapper, or they provide indirection to different services to be used to search a cache, such as wrapper 330 providing indirection to services associated with element 318. This permits multiple different caches to be used for different elements, which can be more efficient for different types of elements.
If at 432, the element is not a viable candidate for cache, a non-cache wrapper, such as wrappers 332 and 334 in
In conjunction with the creation of a wrapper for cacheable elements, a process is followed as indicated generally at 510 in the flowchart of
Once the cache file is either deemed valid or recreated, the IRoot method implementations examine the cache file to satisfy search/enumeration requests for classes, rather than looking to the class path element itself. In the rare cases, when non-cached information about a class is requested, the root object then reverts back to the class path element to satisfy the request.
The JPS instances use a list of root objects in the order in which they were created to satisfy external class location requests. For example, a JPS instance can be initialized with a class path that looks something like “Z;D;J”, where Z is a ZIP file, D is a directory, and J is the Java Package Manager. In this case, the JPS instance will have a list of three root objects, the first and third of which will be caching root objects, and the second will be a non-caching root object. When a request to find a class is made on the JPS instance, it asks each of these root objects for the class, in order, until the class is found or the list is exhausted.
To monitor whether or not the elements having associated caches have changed during normal use of a development system, in one embodiment a background thread is run. File change notifications are issued by a file system to wake up the thread, which in turn can automatically check either an identified cache for changes, or check them all depending on the granularity of the change notice. The change notifications can also be directed to individual wrappers for initiating update of associated caches, either as received, or at the time that the cache is next needed to find all classes or enumerate them.
In
In
Location of classes is facilitated by caching information about classes in a class path. This cached information provides a much quicker way of searching for a class which is needed for instantiation and execution. The cache is reconstructed when changes to the original information in the class path are detected.
In one aspect of the invention, only selected elements in a class path are cached. These elements are selected as those which have associated mechanisms to provide notification of changes. In this manner, the integrity of the cache can be maintained with little overhead involved in independent tracking of the class path elements. By keeping separate caches, reconstruction of a cache due to a detected change is limited to that cache only. Further the selection criteria can be modified such that only class path elements that are least likely to be changed are cached, and for which changes are easy to detect. This allows selectivity of elements to cache based on the overhead associated with caching the element.
In a further aspect of the invention, a class path manager is used to create caches for selected class path elements on instantiation of the path manager. It first parses the path into names of elements, and then decides whether the element is viable for caching. In one embodiment, only zip files are cached. The class path manager creates a wrapper for each element in the class path as identified by a classpath environment variable. The wrapper is used to provide a level of indirection when calls are made to determine the location of a class. If the element is not one which is viable to cache, standard system services are invoked to perform a search of the path of that element. If the element is one for which caching is viable, a caching wrapper is created which invokes methods to search the cache for that element. The indirection provided by the wrappers allows multiple different types of caches to be provided for elements without increasing the complexity of the class path manager, nor changing the normal calls from applications that need to find the class.
While the invention has been described with respect to Java, it should be noted that it is applicable to other environments which need to identify and/or enumerate files from a large quantity of files. Further, the information cached can be changed in other embodiments. It should merely be sufficient to identify the locations of classes meeting the criteria given the context of invocation of the search. While ZIP files were identified as viable candidates for caching, other types of directories or file structures can also be cached as determined by a weighing of the tradeoffs between increased performance and overhead associated with keeping the cache up to date.
This application is intended to cover any adaptations or variations of the present invention. It is manifestly intended that this invention be limited only by the claims and equivalents thereof.
Number | Name | Date | Kind |
---|---|---|---|
4317168 | Messina et al. | Feb 1982 | A |
4332010 | Messina et al. | May 1982 | A |
4394731 | Flusche et al. | Jul 1983 | A |
4400770 | Chan et al. | Aug 1983 | A |
4484267 | Fletcher | Nov 1984 | A |
4905141 | Brenza | Feb 1990 | A |
5151989 | Johnson et al. | Sep 1992 | A |
5187786 | Densmore et al. | Feb 1993 | A |
5537574 | Elko et al. | Jul 1996 | A |
5581760 | Atkinson et al. | Dec 1996 | A |
5619710 | Travis et al. | Apr 1997 | A |
5822580 | Leung | Oct 1998 | A |
5893118 | Sonderegger | Apr 1999 | A |
5920725 | Ma et al. | Jul 1999 | A |
5923878 | Marsland | Jul 1999 | A |
5937411 | Becker | Aug 1999 | A |
5966702 | Fresko et al. | Oct 1999 | A |
5987608 | Roskind | Nov 1999 | A |
6016392 | Jordan | Jan 2000 | A |
6061743 | Thatcher et al. | May 2000 | A |
6078924 | Ainsbury et al. | Jun 2000 | A |
6085030 | Whitehead et al. | Jul 2000 | A |
6085198 | Skinner et al. | Jul 2000 | A |
6086030 | Hepworth | Jul 2000 | A |
6169992 | Beall et al. | Jan 2001 | B1 |
6199082 | Ferrel et al. | Mar 2001 | B1 |
6212564 | Harter et al. | Apr 2001 | B1 |
6216152 | Wong et al. | Apr 2001 | B1 |
6230184 | White et al. | May 2001 | B1 |
6233601 | Walsh | May 2001 | B1 |
6237135 | Timbol | May 2001 | B1 |
6243856 | Meyer et al. | Jun 2001 | B1 |
6243865 | Wei et al. | Jun 2001 | B1 |
6247020 | Minard | Jun 2001 | B1 |
6263377 | Monday et al. | Jul 2001 | B1 |
6263496 | Meyer et al. | Jul 2001 | B1 |
6269373 | Apte et al. | Jul 2001 | B1 |
6272650 | Meyer et al. | Aug 2001 | B1 |
6314558 | Angel et al. | Nov 2001 | B1 |
6321261 | Glass | Nov 2001 | B1 |
6324688 | Brown et al. | Nov 2001 | B1 |
6330709 | Johnson et al. | Dec 2001 | B1 |
6378126 | Tang | Apr 2002 | B2 |
6385769 | Lewallen | May 2002 | B1 |
6401241 | Taylor | Jun 2002 | B1 |
6430556 | Goldberg et al. | Aug 2002 | B1 |
6430570 | Judge et al. | Aug 2002 | B1 |
6430730 | Ghatate et al. | Aug 2002 | B1 |
6442620 | Thatte et al. | Aug 2002 | B1 |
6470494 | Chan et al. | Oct 2002 | B1 |
6519594 | Li | Feb 2003 | B1 |
6530080 | Fresko et al. | Mar 2003 | B2 |
6609146 | Slotznick | Aug 2003 | B1 |
6633888 | Kobayashi | Oct 2003 | B1 |
6654765 | Wong et al. | Nov 2003 | B2 |
6654954 | Hicks | Nov 2003 | B1 |
6715145 | Bowman-Amuah | Mar 2004 | B1 |
6738975 | Yee et al. | May 2004 | B1 |
6748396 | Klicnik et al. | Jun 2004 | B2 |
20010047510 | Angel et al. | Nov 2001 | A1 |
20020007357 | Wong et al. | Jan 2002 | A1 |
20020042833 | Hendler et al. | Apr 2002 | A1 |
20020049865 | Charnell et al. | Apr 2002 | A1 |
20020184226 | Klicnik et al. | Dec 2002 | A1 |
20040111730 | Apte | Jun 2004 | A1 |
20040133882 | Angel et al. | Jul 2004 | A1 |
20040144882 | Small et al. | Jul 2004 | A1 |
20040261069 | Verbeke et al. | Dec 2004 | A1 |
20060070051 | Kuck et al. | Mar 2006 | A1 |
20060122962 | Ushiku | Jun 2006 | A1 |