Patent ID: 8250559

Claim:
A method for supporting per-task classpaths with class sharing in a multi-tasking virtual machine, comprising: executing a plurality of tasks in a multi-tasking virtual machine (VM); determining that a VM-defined class loader for a first task of the plurality of tasks and a VM-defined class loader for a second task of the plurality of tasks specify the same class definition for a given class name, wherein the VM-defined class loaders are of the same type, wherein, in said determining, a first identical class loader key defined from a classpath used by the VM-defined class loaders of the first and second tasks for locating the class definition is determined to have been associated with each of the first and second tasks; in response to said determining that the VM-defined class loader for the first task and the VM-defined class loader for the second task specify the same class definition for the given class name, sharing, between the first and second tasks, a runtime representation of at least a portion of the class as defined by the class definition specified by the VM-defined class loaders of the first and second tasks and corresponding to the given class name, wherein the shared runtime representation is generated within the multi-tasking virtual machine according to the class definition specified by the VM-defined class loaders of the first and second tasks, and wherein the shared runtime representation is specified by the first identical class loader key associated with the first and second tasks; wherein respective VM-defined class loaders for at least two of the plurality of tasks other than the first and second tasks each specifies a second class definition for the given class name that is not the same class definition specified by the VM-defined class loaders of the first and second tasks, wherein the at least two other tasks share a runtime representation of at least a portion of a class as defined by the second class definition, and wherein the runtime representation shared by the at least two other tasks is specified by a second identical class loader key associated with the at least two other tasks; and wherein the runtime representation shared by the first and second tasks and the runtime representation shared by the at least two other tasks coexist within the multi-tasking virtual machine for a period of time.