A system and method for dumping all or some exceptions in an object-oriented environment. The invention includes a Java virtual machine comprising: a system for enabling a verbose exceptions mode; and a system for dumping exceptions that occur during the running of the executable code when the verbose exceptions mode is enabled.

Patent
   7036045
Priority
Mar 21 2002
Filed
Mar 21 2002
Issued
Apr 25 2006
Expiry
Sep 23 2023
Extension
551 days
Assg.orig
Entity
Large
5
3
EXPIRED
1. An interpreter for generating and running an application, the interpreter comprising: a system for enabling a verbose exceptions mode; and a system for dumping exceptions that occur during the running of the application when the verbose exceptions mode is enabled; and initiating execution of the application; wherein the initialization option includes a command line switch.
12. A method for dumping exceptions during the running of an application in an interpreted language environment, comprising: inputting an initialization option; enabling a verbose exceptions mode; initiating execution of the application; wherein the initialization option includes a command line switch; generating an exception when an error occurs; and outputting an exception stack trace associated with each exception.
8. A program product stored on a recordable medium for generating and running an application, the interpreter comprising: program code configured to enabling a verbose exceptions mode; and program code configured to dump exceptions that occur during the running of the application when the verbose exceptions mode is enabled; and initiating execution of the application; wherein the initialization option includes a command line switch.
15. A compiler system for generating an executable program configured to dump exceptions, wherein the compiler system comprises a runtime library having a verbose exceptions module, wherein the verbose exceptions module includes: a system for reading in an initialization option that enables a verbose exceptions mode; wherein the initialization option includes a command line switch; a system for causing exceptions to be dumped when the verbose exceptions mode is enabled.
2. The interpreter of claim 1, wherein the interpreter comprises a Java virtual machine.
3. The interpreter of claim 1, wherein the system for dumping exceptions dumps each exception to a log and includes a stack trace associated with each exception.
4. The interpreter of claim 1, wherein the system for dumping exceptions dumps all of the exceptions that occur during the running of the application.
5. The interpreter of claim 1, wherein the system for dumping exceptions dumps a subset of exceptions.
6. The interpreter of claim 5, wherein the subset of exceptions is selected from the group consisting of: a predetermined class type and a predetermined derivative of a class type.
7. The interpreter of claim 5, further comprising a system for receiving an initialization option that causes the verbose exceptions mode to be enabled and dictates what subset of exceptions will be dumped.
9. The program product of claim 8, further comprising program code configured to receive an initialization option that causes the verbose exceptions mode to be enabled and dictates a subset of exceptions to be dumped.
10. The program product of claim 8, further comprising a Java virtual machine.
11. The program product of claim 8, wherein the program code configured to dump exceptions dumps each exception to a log and includes a stack trace associated with each exception.
13. The method of claim 12, wherein the step of enabling a verbose exceptions mode includes the step of defining an exception subset.
14. The method of claim 13, comprising the further step of checking the verbose exceptions mode after the exception is generated to determine if verbose exceptions mode is enabled for the exception.
16. The compiler system of claim 15, wherein the initialization option dictates a subset of exceptions to be dumped.
17. The compiler system of claim 15, further comprising a C++ compiler.
18. The compiler system of claim 15, wherein the dumped exceptions include a stack trace associated with each exception.

1. Technical Field

The present invention relates generally to isolating errors in a software runtime environment, and more particularly, to a system and method for dumping exceptions during execution of a computer program in an interpreted language environment.

2. Related Art

Identifying runtime problems in a software program can be a very time consuming and expensive process given the often inherent complexity of software. Difficulties arise because problems are often hard to identify and are not always evident when a program is executing. Such problems result not only in a costly process of isolating errors, but also result in low performance when such errors are unexpected or go undetected.

In many environments, runtime errors result in an “exception,” which can be dealt with during runtime to allow the program to continue executing. In a Java environment, for instance, when a runtime error occurs, the program can “throw an exception,” and a handler can be provided to “catch” the exception and deal with it. If a handler is not provided, the program will terminate and output some type of error message.

Problems often occur, however, because many applications write code that catch exceptions that perform some type of default behavior. In Java, for example, exceptions are sometimes caught generically, such as with the statement:

catch (Exception e) {/* do nothing */}.

In this case, nothing is done except to consume the exception. While this may work fine for cases where the exceptions are intended, it may be insufficient to handle other, perhaps unintended, exceptions such as a ClassNotFoundException. In cases where the exception is due to some user error (e.g., configuration problem, missing classpath item, etc.), the program will behave badly, and there may be no visible sign of what the problem is.

In addition, many times applications use exceptions to pass back errors or event notifications (e.g., correct responses). The use of exceptions in this manner can be a performance overhead, particularly in a system where there is a large stack depth. In such cases, the creation and throwing of each exception requires the stack, at the point of the throw, to be captured and saved in the exception. Unfortunately, without analyzing when, where, and how such exceptions are used, it may be difficult to identify or quantify any loss of performance.

Accordingly, a need exists for a system and method that can analyze exceptions generated during runtime to determine problems, isolate errors, and improve performance.

The present invention addresses the above-mentioned problems, as well as others, by providing a system, method and program product, such as a Java virtual machine (JVM), that can be enabled to dump all exceptions in a verbose mode. In a first aspect, the invention provides an interpreter for generating and running an application, the interpreter comprising: a system for enabling a verbose exceptions mode; and a system for dumping exceptions that occur during the running of the application when the verbose exceptions mode is enabled.

In a second aspect, the invention provides a program product stored on a recordable medium for generating and running an application, the program product comprising: program code configured to enable a verbose exceptions mode; and program code for dumping exceptions that occur during the running of the application when the verbose exceptions mode is enabled.

In a third aspect, the invention provides a method for dumping exceptions during the running of an application in an interpreted language environment, comprising: inputting an initialization option; enabling a verbose exceptions mode; running the application; generating an exception when an error occurs; and outputting an exception stack trace.

In a fourth aspect, the invention provides a compiler system for generating an executable program configured to dump exceptions, wherein the compiler system comprises a runtime library having a verbose exceptions module, wherein the verbose exceptions module includes: a system for reading in an initialization option that enables a verbose exceptions mode; and a system for causing exceptions to be dumped when the verbose exceptions mode is enabled.

These and other features of this invention will be more readily understood from the following detailed description of the various aspects of the invention taken in conjunction with the accompanying drawings in which:

FIG. 1 depicts a computer system having a Java virtual machine in accordance with the present invention.

FIG. 2 depicts an exemplary exception dump in accordance with the present invention.

FIG. 3 depicts a compiler system in accordance with the present invention.

FIG. 4 depicts a method flow diagram according to the present invention.

The drawings are merely schematic representations, not intended to portray specific parameters of the invention. The drawings are intended to depict only typical embodiments of the invention, and therefore should not be considered as limiting the scope of the invention. In the drawings, like numbering represents like elements.

Referring now to the drawings, FIG. 1 depicts a computer system 10 having a Java virtual machine 18 that can generate a log file 34 containing a dump of exceptions 36 that occur while an application is running. By providing such a log file 34, problems in the application related to exceptions can be more easily diagnosed.

Computer system 10 generally comprises memory 16, input/output (I/O) 14, a processor 12, external devices/resources (not shown) and bus 26. Memory 16 may comprise any known type of data storage and/or transmission media, including magnetic media, optical media, random access memory (RAM), read-only memory (ROM), a data cache, a data object, etc. Moreover, memory 16 may reside at a single physical location, comprising one or more types of data storage, or be distributed across a plurality of physical systems in various forms. Processor 12 may likewise comprise a single processing unit, or be distributed across one or more processing units in one or more locations, e.g., on a client and server.

I/O 14 may comprise any system for exchanging information with an external source. External sources may comprise any known type of external device, including memory, a CRT, LED screen, hand-held device, keyboard, mouse, voice recognition system, speech output system, printer, monitor, facsimile, pager, etc. Bus 26 provides a communication link between each of the components in the computer system 10 and likewise may comprise any known type of transmission link, including electrical, optical, wireless, etc. In addition, although not shown, additional components, such as cache memory, communication systems, system software, etc., may be incorporated into computer system 10.

Stored in memory 16 is an enhanced Java virtual machine (JVM) 18 in the form of a software program. In general, JVM 18 reads in an input file “APP” 31 containing byte code 32, interprets the byte code 32, generates executable code or instructions (i.e., an application), and causes the executable instructions to be run by processor 12. It is recognized that JVM's represent just one type of interpreted language environment, and is described herein for exemplary purposes only. Accordingly, it should be understood that any type of interpreter adapted to include the inventive features described herein clearly falls within the scope of this invention. Furthermore, given that JVM's are well known in the art, their basic functionality will not be discussed in detail herein.

As noted above, JVM 18 can be enabled to generate log file 34 (i.e., an exception dump), which contains a list of exceptions 36 that occurred while an application was executing. Along with the list of exceptions 36, associated stack traces and other relevant information may be provided. An exemplary exception dump is shown in FIG. 2. It should be understood that the format depicted in FIG. 2 is for exemplary purposes only, and that any output format could be provided. In addition, exceptions need not be outputted to a log file 34, but rather, could be outputted to any type of I/O device (e.g., a CRT), to a program that analyzes the results, etc.

Returning to FIG. 1, initialization options 28 are utilized to setup JVM's system properties to generate log file 34. Specifically, a “verbose exceptions” option 30, which may comprise, e.g., a command line option or switch, is inputted into JVM 18 and enables a verbose exceptions mode within JVM 18. For example, in order to run the input file “APP” 31 in a verbose exceptions mode, a command line option as follows may be utilized:

>Java-verbose:exceptions APP

It is understood that verbose exceptions option 30 may be implemented in any manner and is not limited to a command line switch. For example, in an integrated development environment, the verbose exceptions option 30 may be implemented via a drop down menu.

In addition to simply turning the verbose exceptions mode on, the verbose exceptions option 30 also allows the user to specify different levels of granularity regarding the types of exceptions to be dumped. To achieve this, the user specifies a subset of exceptions within the verbose exceptions option 30. For example, the user may just want to dump certain classes of exceptions, derivatives of classes, etc. This can be achieved by, for instance, using additional subset options on the command line switch, such as:

>Java-verbose:exceptions APP [{class1, class2, class3, . . . }]

In this case, only the selected class or classes exceptions would be dumped.

When the verbose exceptions option 30 is turned on, the JVM system properties set-up 20 will enable the verbose exceptions mode 21 and define the appropriate exception subset 23 in JVM 18. Then, when the application is run, and an error occurs that creates an exception, a checking system 22 will identify exception object classes that match the defined exception subset. The checking system 22 can be implemented as a software routine that compares the object class of an exception with the object classes defined in the exception subset. If a match is found, then the information associated with the exception (e.g., stack trace) is collected from the JVM 18 and outputted by exception dumping system 24 to log file 34. Exception dumping system 24 may be implemented, for instance, by a software routine that opens log file 34 and writes the exception data to the log file 34.

In addition to interpreted language environments, the process for dumping exceptions can be implemented in non-interpreted environments. For example, as shown in FIG. 3, exception dumping can be implemented with an object-oriented compiler, such as a C++ compiler 44. In a C++ environment, a C++ runtime library 46 containing a verbose exceptions module 42 is provided and is linked with the application code 48 by the C++ compiler 44. The result is an executable application 40 having the verbose exceptions module 42. The verbose exceptions module 42 includes: (1) a system for reading in an initialization option (e.g., and environment variable) that enables a verbose exceptions mode; and (2) a system for causing exceptions to be dumped when the verbose exceptions mode is enabled.

Thus, when the application 40 gets executed, e.g., by computer system 10 of FIG. 1, the verbose exceptions module 42 checks for any environment variables or the like that would enable the exception dumping mode. If enabled, exceptions are dumped during runtime and output to a log file in a manner similar to that described above.

In one exemplary embodiment, the initialization option may be implemented during run time with environment variables, such as:

>CAPP verbose[{class1, class2, class3, . . . }],

where: “CAPP” is an exectable application 40 created with C++ compiler 44; “verbose” causes the verbose exceptions mode to be enabled; and “class1, class2, class3, . . . ” are the class exceptions that will be dumped. Thus, for instance, the command line

>CAPP verbose[class1],

would cause only class1 exceptions to be dumped when CAPP is executed.

Referring now to FIG. 4, a flow diagram depicting an exemplary methodology implementing verbose exceptions in an interpreted language environment is shown. Prior to execution of application logic 50, the verbose exceptions mode is enabled and an exception subset is defined (not shown). Within application logic 50 is a piece of code containing a “try-catch” block 56 to deal with any “Exception e” errors that might occur while “Do some business logic” is executed. If an error occurs 58, an exception is created 60, and the verbose exceptions mode is checked 62. If verbose is enabled for the exception 64, then the exception is output along with its stack trace 66, and the application logic continues 52.

It is understood that the present invention can be realized in hardware, software, or a combination of hardware and software. Moreover, the present invention can be realized in a centralized fashion in a single computerized workstation, or in a distributed fashion where different elements are spread across several interconnected systems (e.g., a network). Any kind of computer—or other apparatus adapted for carrying out the methods described herein—is suited. A typical combination of hardware and software could be a general purpose computer system with a computer program that, when loaded and executed, controls computer system 10 such that it carries out the methods described herein. Alternatively, a specific use computer system, containing specialized hardware for carrying out one or more of the functional tasks of the invention could be utilized. The present invention can also be embedded in a computer program product, which comprises all the features enabling the implementation of the methods described herein, and which—when loaded in a computer system—is able to carry out these methods. Computer program, software program, program, or software, in the present context mean any expression, in any language, code or notation, of a set of instructions intended to cause a system having an information processing capability to perform a particular function either directly or after either or both of the following: (a) conversion to another language, code or notation; and/or (b) reproduction in a different material form.

The foregoing description of the invention has been presented for purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise form disclosed, and obviously, many modifications and variations are possible. Such modifications and variations that may be apparent to a person skilled in the art are intended to be included within the scope of this invention as defined by the accompanying claims.

Broussard, Scott J., Spring, Eduardo N.

Patent Priority Assignee Title
7877640, Mar 30 2007 SAP SE Method and system for providing enhanced exception messages for exceptions thrown by virtual machines
8516498, Oct 31 2003 Microsoft Technology Licensing, LLC Handling a delivery failure as a program exception in a distributed asynchronous architecture
8762953, Jul 12 2007 The MathWorks, Inc. Exception-based error handling in an array-based language
8914776, May 17 2012 Microsoft Technology Licensing, LLC Assisting development tools through inserted code statements
9459991, Dec 31 2009 International Business Machines Corporation Heap dump object identification in a heap dump analysis tool
Patent Priority Assignee Title
6289446, Sep 29 1998 AXIS AB Exception handling utilizing call instruction with context information
6543011, Jul 15 1999 International Business Machines Corporation Method for event recording in java
20020198983,
///
Executed onAssignorAssigneeConveyanceFrameReelDoc
Mar 15 2002BROUSSSARD, SCOTT J International Business Machines CorporationASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS 0127410594 pdf
Mar 15 2002SPRING, EDUARDO N International Business Machines CorporationASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS 0127410594 pdf
Mar 21 2002International Business Machines Corporation(assignment on the face of the patent)
Date Maintenance Fee Events
Sep 29 2009M1551: Payment of Maintenance Fee, 4th Year, Large Entity.
Dec 06 2013REM: Maintenance Fee Reminder Mailed.
Apr 11 2014M1552: Payment of Maintenance Fee, 8th Year, Large Entity.
Apr 11 2014M1555: 7.5 yr surcharge - late pmt w/in 6 mo, Large Entity.
Dec 04 2017REM: Maintenance Fee Reminder Mailed.
May 21 2018EXP: Patent Expired for Failure to Pay Maintenance Fees.


Date Maintenance Schedule
Apr 25 20094 years fee payment window open
Oct 25 20096 months grace period start (w surcharge)
Apr 25 2010patent expiry (for year 4)
Apr 25 20122 years to revive unintentionally abandoned end. (for year 4)
Apr 25 20138 years fee payment window open
Oct 25 20136 months grace period start (w surcharge)
Apr 25 2014patent expiry (for year 8)
Apr 25 20162 years to revive unintentionally abandoned end. (for year 8)
Apr 25 201712 years fee payment window open
Oct 25 20176 months grace period start (w surcharge)
Apr 25 2018patent expiry (for year 12)
Apr 25 20202 years to revive unintentionally abandoned end. (for year 12)