# US 7,610,579 B2 · Critical finalizers

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 7,610,579 B2
- Document ID: US7610579B2
- Status: Granted
- Kind: B2
- Application number: 11/008,831
- Filed: 2004-12-10
- Published: 2006-07-13
- Granted: 2009-10-27
- Earliest claimed: 2004-12-10
- Assignees: Microsoft Corporation
- Inventors: Sean E. Trowbridge; Brian M. Grunkemeyer; Christopher W. Brumme; Mahesh Prakriya; Patrick H. Dussud; Ian H. Carmichael
- Web page: https://patentgrep.com/patent/US7610579B2

## CPC

- G06F 11/3698: Environments for analysis, debugging or testing of software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A finalizer may include a notification that no tolerance for failure or corruption is expected. Any potential failure point, which may be induced by a runtime execution environment routine or subroutine that is associated with the finalizer may then be prepared apart from the finalizer.

## Claims

### Claim 1

A method, comprising:
identifying a class having prioritized finalization code, wherein the identifying includes receiving an indication that at least a sub-set of the finalization code expects to have no tolerance for failure;
preparing the finalization code for an instance of the identified class, wherein the preparing includes:
identifying a potential failure point associated with at least a portion of the finalization code; and
hoisting the identified failure point to a designated execution location either preceding or following at least the portion of the finalization code; and
executing the finalization code for the instance of the identified class.

### Claim 2 (depends on 1)

A method according to claim 1, wherein the identifying further includes receiving an indication that at least a sub-set of the finalization code expects to have no tolerance for a runtime execution environment induced resource failure.

### Claim 3 (depends on 2)

A method according to claim 2, wherein the runtime execution environment induced resource failure includes at least one of a thread abort condition, an out-of-memory condition, a stack overflow condition, a control deadlock resolution condition, an execution termination condition, and an execution interruption condition.

### Claim 4 (depends on 1)

A method according to claim 1, wherein the preparing further includes:
identifying at least a portion of a runtime execution environment routine that has a potential to induce a failure during processing in correspondence with at least a portion of the finalization code; and
rescheduling at least the identified portion of the runtime execution environment routine for execution separate from at least the portion of the finalization code.

### Claim 5 (depends on 4)

A method according to claim 4, wherein the rescheduling includes hoisting at least the identified portion of the runtime execution environment routine to a designated execution location preceding at least the portion of the finalization code.

### Claim 6 (depends on 4)

A method according to claim 4, wherein the rescheduling includes hoisting at least the identified portion of the runtime execution environment routine to a designated execution location following at least the portion of the finalization code.

### Claim 7

A method, comprising:
loading one or more classes, wherein the one or more classes include finalization attributes, wherein a finalization attribute of at least one of the one or more classes comprises a prioritized finalization attribute comprising a critical finalizer;
preparing the critical finalizer, wherein the preparing includes:
identifying a potential failure point associated with at least a portion of the critical finalizer; and
hoisting the identified failure point to a designated execution location either preceding or following at least the portion of the critical finalizer;
sorting the loaded classes based on respective finalization attributes, wherein the sorting includes sorting loaded classes having a prioritized finalization attribute from loaded classes having a non-prioritized finalization attribute; and
finalizing objects of the loaded classes in an order based on the sorting, wherein the finalizing includes performing a garbage collection sweep on objects of the loaded classes, running a finalizer for objects with the non-prioritized finalization attribute before objects having a prioritized finalization attribute.

### Claim 8 (depends on 7)

A method according to claim 7, wherein a finalizer is prepared before initialization of the sorted classes having a prioritized finalization attribute, and wherein further the finalizing includes performing a garbage collection sweep on objects of the loaded classes having non-prioritized finalization attributes before objects of the loaded classes having prioritized finalization attributes.

### Claim 9

A method, comprising:
sorting classes having a non-prioritized finalization attribute and classes having a prioritized finalization attribute;
preparing a finalizer for a sorted class having a prioritized finalization attribute, wherein preparing the finalizer includes:
identifying a potential failure point associated with at least a portion of the finalizer; and
hoisting the identified failure point to a designated execution location either preceding or following at least the portion of the finalizer;
finalizing a first constructed object for a sorted class having the non-prioritized finalization attribute; and
finalizing a second constructed object for a sorted class having the prioritized finalization attribute, wherein the finalizing of the first constructed object occurs before the finalizing of the second constructed object.

### Claim 10 (depends on 9)

A method according to claim 9, wherein the sorting includes sorting classes into separate queues in accordance with prioritization finalization attributes for the respective classes.

### Claim 11 (depends on 9)

A method according to claim 9, wherein the sorting includes sorting the classes within a single queue in accordance with prioritization finalization attributes for the respective classes.

### Claim 12

A computer-readable storage medium having one or more executable instructions that, when read, cause one or more processors to:
prepare a first finalizer for a class having a first attribute, wherein the first attribute is a critical finalizable attribute, wherein preparing the first finalizer includes:
identifying a potential failure point associated with at least a portion of the first finalizer; and
hoisting the identified failure point to a designated execution location either preceding or following at least the portion of the first finalizer;
execute a second finalizer for an object of a class having a second attribute, wherein the second attribute is a non-critical finalizable attribute; and
execute the first finalizer for an object of the class having the first attribute, wherein the first attribute indicates that the first finalizer for the class having the first attribute is to be executed after execution of the second finalizer for an object of a class having the second attribute.

### Claim 13 (depends on 12)

A computer-readable storage medium according to claim 12, wherein the one or more instructions to prepare the finalizer for the class having the first attribute further cause the one or more processors to:
identify a potential failure point associated with at least a portion of the finalizer; and
reschedule at least the identified potential failure point for execution separate from at least the portion of the finalizer for the class having the first attribute.

### Claim 14 (depends on 12)

A computer-readable storage medium according to claim 12, wherein the one or more instructions to prepare the finalizer for the class having the first attribute further cause the one or more processors to:
identify at least a portion of a runtime execution environment routine that has a potential to induce an exceptional condition during execution of at least a portion of the finalizer; and
hoist at least the portion of the identified runtime execution environment routine to be executed apart from at least the portion of the finalizer having the first attribute.

### Claim 15 (depends on 12)

A computer-readable storage medium according to claim 12, wherein the first attribute indicates that the finalizer for the class having the first attribute is to be executed in exceptional conditions.

### Claim 16 (depends on 12)

A computer-readable storage medium according to claim 12, further comprising one or more executable instructions that, after execution of the one or more instructions to prepare the finalizer for the class having the first attribute, cause the one or more processors to construct an object for the class having the first attribute.

### Claim 17

A system, comprising:
means for identifying a class having prioritized finalization code and a prioritized finalization attribute;
means for preparing the prioritized finalization code for an object constructed from the identified class, wherein the means for preparing includes:
means for identifying a potential failure point associated with at least a portion of the prioritized finalization code; and
means for hoisting the identified failure point to a designated execution location either preceding or following at least the portion of the prioritized finalization code; and
means for executing the prioritized finalization code for the constructed object,
wherein the means for identifying determines that at least a portion of the prioritized finalization code expects to be executed after execution of finalization code for an object of a class having a non-prioritized finalization attribute.

### Claim 18 (depends on 17)

A system according to claim 17, wherein the means for identifying determines that at least a portion of the finalization code expects to be executed in the event of an exception.

### Claim 19 (depends on 17)

A system according to claim 17, wherein the object is constructed after the means for preparing the finalization code prepares the finalization code.
