IP Library Granted Patent US 7,941,793
Granted Patent B2
US 7,941,793 · App. 11/465,091 · Granted May 10, 2011

Class initialization method semantics

View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 7,941,793
App. No.
11/465,091
Granted
May 10, 2011
Kind
B2
Abstract

A system and method for mitigating problems associated with automatic execution of initialization code is provided. The system includes an initialization method activator that can call a class initialization method at a pre-determined execution point. The system also includes a deadlock analyzer that can determine whether calling the initialization method will create a deadlock, and, if a deadlock is detected that can resolve such a deadlock. The system also includes a semantic analyzing component that can analyze a semantic type associated with the initialization method and a domain uniqueness analyzer that can analyze the uniqueness of the domain with which the class will interact, to facilitate determining where to place code that will check whether a class is initialized, and if the class is not initialized that will invoke the class initializing method.

Claims (38)

1. A computer system comprising a processor operatively coupled to a memory and one or more storage media having stored thereon computer-executable instructions that, when executed by the processor, perform a method for mitigating problems associated with automatic execution of initialization code, the method comprising:

determining whether a class has an initializing method comprising class initialization code;

determining the execution point at which the initializing method should be called by at least analyzing domain uniqueness information associated with one or more application domains with which the class initialization code will interact, wherein the domain uniqueness information comprises an identifier that identifies whether the initializing method is associated with a “normal” environment, or a “domain neutral” environment, wherein the normal environment is an environment in which the class initialization code needs to initialize one set of static fields and in which multiple application domains share a single state associated with the class, and wherein the domain neutral environment is an environment in which the class initialization code needs to initialize more than one set of static fields and in which each of the multiple application domains have separate corresponding states associated with the class;

associating initialization check code with one or more static fields according to a domain associated with at least the class, the check code being operable to determine whether the class is initialized;

determining, prior to calling the initialization method, whether calling the initializing method will generate a deadlock, and if calling the initializing method will generate a deadlock, resolving the deadlock; and

calling the class initializing method.

2. The computer system of claim 1 , further comprising attempting to acquire an initialization lock associated with the class to be initialized, and if the initialization lock cannot be acquired, identifying a holding thread that is holding the initialization lock.

3. The computer system of claim 2 , wherein the method further comprises determining at least one of a caller's just in time compilation time, a callee's just in time compilation time, an initial field access time, an initial method access time, an initial static field access time and a first access of pre-compiled code where no just in time compilation occurs.

4. The computer system of claim 1 , wherein determining prior to calling the initialization method whether calling the initializing method will generate a deadlock further comprises analyzing a wait for graph.

5. The computer system of claim 4 , further comprising adding and/or removing one or more nodes and/or arcs from the wait for graph.

6. The computer system of claim 4 , further comprising analyzing a semantic type associated with the class initialization method.

7. A method, implemented at a computer system comprising a memory operatively coupled to at least one processor, for mitigating problems associated with automatic execution of class initialization code, the method comprising:

determining whether a class has an initializing method comprising class initialization code;

determining the execution point at which the initializing method should be called by at least analyzing domain uniqueness information associated with one or more application domains with which the class initialization code will interact, wherein the domain uniqueness information comprises an identifier that identifies whether the initializing method is associated with a “normal” environment, or a “domain neutral” environment, wherein the normal environment is an environment in which the class initialization code needs to initialize one set of static fields and in which multiple application domains share a single state associated with the class, and wherein the domain neutral environment is an environment in which the class initialization code needs to initialize more than one set of static fields and in which each of the multiple application domains have separate corresponding states associated with the class;

associating initialization check code with one or more static fields according to a domain associated with at least the class , the check code being operable to determine whether the class is initialized;

determining, prior to calling the initialization method, whether calling the initializing method will generate a deadlock, and if calling the initializing method will generate a deadlock, resolving the deadlock; and

calling the class initializing method.

8. The method of claim 7 , further comprises:

analyzing semantic information associated with the initializing method.

9. The method of claim 8 , wherein the semantic information comprises an identifier that identifies whether the initializing method desires “exact” or “before field initialization” behavior.

10. The method of claim 7 , wherein determining whether calling the initializing method will generate a deadlock comprises:

attempting to acquire an initialization lock associated with the class to be initialized, and if the initialization lock cannot be acquired, identifying a holding thread that is holding the initialization lock;

locating a node associated with the holding thread, where the node is located in a wait for graph; and

analyzing the wait for graph to determine whether a deadlock exists.

11. The method of claim 10 , wherein resolving the deadlock comprises:

acquiring a lock associated with the wait for graph;

if a detecting thread that identifies the deadlock previously added one or more arcs and/or nodes to the wait for graph, removing the one or more arcs and/or nodes from the wait for graph; releasing the lock associated with the wait for graph; and

the detecting thread interacting with the class as though the class was initialized.

12. The method of claim 10 , wherein analyzing the wait for graph to determine whether a deadlock exists comprises:

traversing the wait graph starting at the node associated with the holding thread and determining whether a cycle is detected in the wait graph, and if the cycle is detected in the wait graph determining that a deadlock exists, or otherwise, if the cycle is not detected, determining that a deadlock does not exist.

13. The method of claim 7 , wherein the method also includes using the check code to determine an optimal time to perform the initialization check code.

14. The method of claim 7 , wherein the method includes performing the initialization check code once for each of a plurality of different application domains.

15. One or more storage media, storing computer executable instructions which, when executed by a computing system having a processor, implement a method that includes the computing system:

determining whether a class has an initializing method comprising class initialization code;

determining the execution point at which the initializing method should be called by at least analyzing domain uniqueness information associated with one or more application domains with which the class initialization code will interact, wherein the domain uniqueness information comprises an identifier that identifies whether the initializing method is associated with a “normal” environment, or a “domain neutral” environment, wherein the normal environment is an environment in which the class initialization code needs to initialize one set of static fields and in which multiple application domains share a single state associated with the class, and wherein the domain neutral environment is an environment in which the class initialization code needs to initialize more than one set of static fields and in which each of the multiple application domains have separate corresponding states associated with the class;

associating initialization check code with one or more static fields according to a domain associated with at least the class , the check code being operable to determine whether the class is initialized;

determining, prior to calling the initialization method, whether calling the initializing method will generate a deadlock, and if calling the initializing method will generate a deadlock, resolving the deadlock; and

calling the class initializing method.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 9, 2014
From: MICROSOFT CORPORATION
To: MICROSOFT TECHNOLOGY LICENSING, LLC
Reel/Frame 034542/0001 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 17, 2006
From: KAKIVAYA, GOPALA KRISHNA R.; BRUMME, CHRISTOPHER W.; MILLER, JAMES S.; MORRISON, VANCE P.; MORTENSON, DAVID S.; TROWBRIDGE, SEAN E.
To: MICROSOFT CORPORATION
Reel/Frame 018128/0045 →