# US 2017/0293547 A1 · Redundant Instance Variable Initialization Elision

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

- Number: US 2017/0293547 A1
- Document ID: US20170293547A1
- Status: Published application
- Kind: A1
- Application number: 15/094,783
- Filed: 2016-04-08
- Published: 2017-10-12
- Earliest claimed: 2016-04-08
- Assignees: Oracle International Corporation
- Applicants: Oracle International Corporation
- Inventors: Chris J. Hegarty; Maurizio Cimadamore
- Web page: https://patentgrep.com/patent/US20170293547A1

## CPC

- G06F 11/3604: Analysis of software for verifying properties of programs (testing of software G06F11/3668)
- G06F 8/37: {Compiler construction; Parser generation}
- G06F 8/41: Compilation
- G06F 8/43: {Checking; Contextual analysis}
- G06F 8/443: {Optimisation}
- G06F 8/4435: {Detection or removal of dead or redundant code}
- G06F 8/4441: {Reducing the execution time required by the program code}
- G06F 8/74: Reverse engineering; Extracting design information from source code
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A compiler, IDE or other code analyzer may determine whether an instance variable declaration assignment is redundant. The code analyzer may also take action based on that determination. A code analyzer may be able to determine with certainty that a particular instance variable initialization or assignment is definitely redundant. The code analyzer may cause a compiler to automatically elide the redundant assignment from compiled source code. The code analyzer may be able to determine with certainty that a particular assignment is definitely not redundant. Additionally, a code analyzer may not be able to determine with certainty whether an instance variable assignment is definitely redundant or definitely not redundant. Additionally, the code analyzer may report a warning or other informative message indicating the redundancy property of the assignment, thus alerting the programming to a (possibly) redundant assignment.

## Claims

### Claim 1

A non-transitory, computer-readable storage medium storing program instructions that when executed on a computing device cause the computing device to perform:
implementing a code analyzer configured to:
access source code;
identify, within the source code, an instance variable declaration comprising an assignment that assigns a value to an instance variable;
determine whether the assigned value is a default value for the instance variable;
apply, based at least in part on determining that the assigned value is a default value for the instance variable, a set of rules to determine whether the instance variable declaration assignment is definitely redundant with respect to the default value; and
indicate, based at least in part on determining that the instance variable declaration assignment is definitely redundant, that the instance variable declaration assignment is definitely redundant.

### Claim 2 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1, wherein the code analyzer is further configured to:
determine that the assigned value is not the default value for the instance variable; and
in response to determining that the assigned value is not the default value, determine that the instance variable declaration assignment is definitely not redundant with respect to the default value such that no indication is made regarding the instance variable declaration assignment being definitely redundant.

### Claim 3 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1, wherein to apply the set of rules, the code analyzer is configured to:
determine whether the instance variable is assigned a value prior to the instance variable declaration assignment according to an execution order of the source code.

### Claim 4 (depends on 3)

The non-transitory, computer-readable storage medium of claim 3, wherein the code analyzer is further configured to:
determine, based at least in part on determining that the instance variable is assigned a value prior to the instance variable declaration assignment, that the instance variable declaration is definitely not redundant with respect to the default value.

### Claim 5 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1, wherein to determine whether the instance variable declaration assignment is definitely redundant, the code analyzer is further configured to:
determine whether the source code includes one or more earlier blocks of code, executable prior to the instance variable declaration assignment according to an execution order of the source code, that assign a value to the instance variable; and
determine, based at least in part on determining that the source code does not include one or more earlier blocks of code that assign a value to the instance variable, that the instance variable declaration assignment is definitely redundant with respect to the default value.

### Claim 6 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1, wherein to determine whether the instance variable declaration assignment is definitely redundant, the code analyzer is further configured to:
determine whether the source code includes one or more earlier blocks of code, executable prior to the instance variable declaration assignment according to an execution order of the source code, that possibly assign a value to the instance variable; and
apply, based at least in part on determining that the source code includes one or more earlier blocks of code that possibly assigns a value to the instance variable, the set of rules to each of the one or more earlier blocks of code to determine whether the one or more earlier blocks of code assign a value to the instance variable.

### Claim 7 (depends on 6)

The non-transitory, computer-readable storage medium of claim 6, wherein the code analyzer is further configured to:
determine, based at least in part on applying the set of rules to each of the one or more earlier blocks of code, that none of the one or more earlier blocks of code assign a value to the instance variable; and
determine, based at least in part on determining that none of the one or more earlier blocks of code assign a value to the instance variable, that the instance variable declaration is definitely redundant with respect to the default value.

### Claim 8 (depends on 6)

The non-transitory, computer-readable storage medium of claim 6, wherein the code analyzer is further configured to:
determine, based at least in part on applying the set of rules to each of the one or more earlier blocks of code, that at least one of the one or more earlier blocks of code assigns a value to the instance variable; and
determine, based at least in part on determining that the at least of the one or more earlier blocks of code assigns a value to the instance variable, that the instance variable declaration is definitely not redundant with respect to the default value.

### Claim 9 (depends on 6)

The non-transitory, computer-readable storage medium of claim 6, wherein to determine whether the source code includes one or more earlier blocks of code that possibly assign a value to the instance variable, the code analyzer is further configured to:
determine whether the source code includes any earlier blocks of code, executable prior to the instance variable declaration assignment according to an execution order for the source code, that comprise any of:
a method invocation;
a class construction involving the instance variable;
a class construction involving an object that includes the instance variable;
an expression involving the object that includes the instance variable; or
an instruction involving the object that includes the instance variable.

### Claim 10 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1, wherein the code analyzer is further configured to:
determine that the source code includes one or more earlier blocks of code, executable prior to the instance variable declaration assignment according to an execution order of the source code, that possibly assign a value to the instance variable;
apply the set of rules to each of the one or more earlier blocks of code;
determine, based at least in part on applying the set of rules to each of the one or more earlier blocks of code, that it cannot be determined, for at least one of the one or more earlier blocks of code, whether the at least one earlier block of code assigns a value to the instance variable declaration assignment; and
indicate that it cannot be determined whether the instance variable declaration assignment is definitely redundant with respect to the default value.

### Claim 11 (depends on 1)

The non-transitory, computer-readable storage medium of claim 1, wherein the code analyzer is further configured to:
include a compiler hint in the source code indicating that the instance variable declaration assignment should not be included in a compiled version of the source code.

### Claim 12

A computing device, comprising:
a processor; and
a memory comprising program instructions, that when executed on the processor cause the processor to implement a code analyzer configured to:
access source code;
identify, within the source code, an instance variable declaration comprising an assignment that assigns a value to an instance variable;
determine whether the assigned value is a default value for the instance variable;
apply, based at least in part on determining that the assigned value is a default value for the instance variable, a set of rules to determine whether the instance variable declaration assignment is definitely redundant with respect to the default value; and
indicate, based at least in part on determining that the instance variable declaration assignment is definitely redundant, that the instance variable declaration assignment is definitely redundant.

### Claim 13 (depends on 12)

The computing device of claim 12, wherein to determine whether the instance variable declaration assignment is definitely redundant, the code analyzer is further configured to:
determine that the instance variable is assigned a value prior to the instance variable declaration according to an execution order of the source code; and
in response to determining that the instance variable is assigned a value prior to the instance variable declaration, determine that the instance variable is definitely not redundant with respect to the default value such that no indication is made regarding the instance variable declaration assignment being definitely redundant.

### Claim 14 (depends on 12)

The computing device of claim 12, wherein to determine whether the instance variable declaration assignment is definitely redundant, the code analyzer is further configured to:
determine whether the source code includes one or more earlier blocks of code, executable prior to the instance variable declaration assignment according to an execution order of the source code, that assign a value to the instance variable; and
determine, based at least in part on determining that the source code does not include one or more earlier blocks of code that assign a value to the instance variable, that the instance variable declaration assignment is definitely redundant with respect to the default value.

### Claim 15 (depends on 12)

The computing device of claim 12, wherein to determine whether the instance variable declaration assignment is definitely redundant, the code analyzer is further configured to:
determine whether the source code includes one or more earlier blocks of code, executable prior to the instance variable declaration assignment according to an execution order of the source code, that possibly assign a value to the instance variable; and
apply, based at least in part on determining that the source code includes one or more earlier blocks of code that possibly assign a value to the instance variable, the set of rules to each of the one or more earlier blocks of code to determine whether the one or more earlier blocks of code assign a value to the instance variable.

### Claim 16 (depends on 15)

The computing device of claim 15, wherein the code analyzer is further configured to:
determine, based at least in part on applying the set of rules to each of the one or more earlier blocks of code, that none of the one or more earlier blocks of code assign a value to the instance variable; and
determine, based at least in part on determining that none of the one or more earlier blocks of code assign a value to the instance variable, that the instance variable declaration is definitely redundant with respect to the default value.

### Claim 17 (depends on 15)

The computing device of claim 15, wherein the code analyzer is further configured to:
determine, based at least in part on applying the set of rules to each of the one or more earlier blocks of code, that at least one of the one or more earlier blocks of code assigns a value to the instance variable; and
determine, based at least in part on determining that the at least of the one or more earlier blocks of code assigns a value to the instance variable, that the instance variable declaration is definitely not redundant with respect to the default value.

### Claim 18 (depends on 12)

The computing device of claim 12, wherein to determine whether the source code includes one or more earlier blocks of code that possibly assign a value to the instance variable, the code analyzer is further configured to:
determine whether the source code includes any earlier blocks of code, executable prior to the instance variable declaration assignment according to an execution order for the source code, that comprise any of:
a private or final instance method invocation on an object pointer to an object that includes the instance variable;
a stable method invocation that receives an object pointer to an object that includes the instance variable;
an inner class construction involving the instance variable;
a lambda expression that captures an object pointer to an object that includes the instance variable; or
a new class construction that receives an object pointer to an object that includes the instance variable.

### Claim 19 (depends on 12)

The computing device of claim 12, wherein the program instructions further cause the computing device to:
implement a compiler configured to:
compile the source code to generate a compiled version of the source code; and
omit, in response to the indication that the instance variable declaration assignment should not be included in a compiled version of the source code, the instance variable declaration assignment from the compiled version of the source code.

### Claim 20

A computer implemented method, comprising:
accessing, by a code analyzer, source code;
identifying within the source code, by the code analyzer, an instance variable declaration comprising an assignment that assigns a value to an instance variable;
determining, by the code analyzer, whether the assigned value is a default value for the instance variable;
applying, by the code analyzer based at least in part on determining that the assigned value is a default value for the instance variable, a set of rules to determine whether the instance variable declaration assignment is definitely redundant with respect to the default value; and
indicating, by the code analyzer based at least in part on determining that the instance variable declaration assignment is definitely redundant, that the instance variable declaration is definitely redundant.
