# US 2025/0094147 A1 · Removing redundant code

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

- Number: US 2025/0094147 A1
- Document ID: US20250094147A1
- Status: Published application
- Kind: A1
- Application number: 18/369,347
- Filed: 2023-09-18
- Published: 2025-03-20
- Earliest claimed: 2023-09-18
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Michihiro Horie; Kazunori Ogata
- Web page: https://patentgrep.com/patent/US20250094147A1

## CPC

- G06F 8/4435: {Detection or removal of dead or redundant code}
- G06F 8/315: {Object-oriented languages}
- G06F 8/433: {Dependency analysis; Data or control flow analysis}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Embodiments determine that a compiler option is not provided to enable an assertion for a reachable class in a target application, determine that there is no application program interface (API) being used to enable the assertion found in a reachable method in the reachable class, determine that there is no assertion being executed before an initialization of the reachable class, and remove assertion related code from the reachable class.

## Claims

### Claim 1

A computer-implemented method, comprising:
determining, by the processor set, that a compiler option is not provided to enable an assertion for a reachable class in a target application;
determining, by the processor set, that there is no application program interface (API) being used to enable the assertion found in a reachable method in the reachable class in response to a determination that the compiler option is not provided to enable the assertion for the reachable class;
determining, by the processor set, that there is no assertion being executed before an initialization of the reachable class in response to a determination that there is no API being used to enable the assertion found in the reachable method in the reachable class; and
removing, by the processor set, assertion related code from the reachable class in response to a determination that there is no assertion being executed before the initialization of the reachable class.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, further comprising:
determining that the reachable class is initialized at a different time than a compilation time in response to a determination that there is the reachable class in the target application.

### Claim 3 (depends on 1)

The computer-implemented method of claim 1, wherein the determining that there is no assertion being executed before the initialization of the reachable class comprises:
determining whether the reachable method in the reachable class uses an assertion; and
ending compilation in response to a determination that the reachable method in the reachable class does not use the assertion.

### Claim 4 (depends on 1)

The computer-implemented method of claim 1, wherein the determining that there is no assertion being executed before the initialization of the reachable class further comprises:
finding at least one super class in a reachable class hierarchy from the reachable class; and
finding a super class of the at least one super class that has a static initializer.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1, wherein the determining that there is no assertion being executed before the initialization of the reachable class further comprises:
traversing a static initializer to check the reachable method; and
determining whether the reachable method is found in the static initializer.

### Claim 6 (depends on 5)

The computer-implemented method of claim 5, wherein the determining that there is no assertion being executed before the initialization of the reachable class further comprises:
ending compilation in response to determining that the reachable method is found in the static initializer; and
returning a no in response to determining that the reachable method is not found in the static initializer.

### Claim 7 (depends on 1)

The computer-implemented method of claim 1, wherein the reachable method comprises a method which is explicitly invoked in a main method.

### Claim 8 (depends on 1)

The computer-implemented method of claim 1, wherein the reachable class occurs when a class is executed by a virtual machine (VM).

### Claim 9 (depends on 7)

The computer-implemented method of claim 7, wherein the reachable class and the source code comprises an object-oriented language.

### Claim 10 (depends on 1)

The computer-implemented method of claim 1, further comprising outputting a native image with the assertion related code removed from the reachable class.

### Claim 11 (depends on 10)

The computer-implemented method of claim 10, further comprising running the native image with the assertion related code removed from the reachable class.

### Claim 12

A computer program product comprising one or more computer readable storage media having program instructions collectively stored on the one or more computer readable storage media, the program instructions executable to:
determine that a compiler option is not provided to enable an assertion for a reachable class in a target application;
determine that there is no application program interface (API) being used to enable the assertion found in a reachable method in the reachable class in response to a determination that the compiler option is not provided to enable the assertion for the reachable class;
determine that there is no assertion being executed before an initialization of the reachable class in response to a determination that there is no API being used to enable the assertion found in the reachable method in the reachable class; and
remove assertion related code from the reachable class in response to a determination that there is no assertion being executed before the initialization of the reachable class.

### Claim 13 (depends on 12)

The computer program product of claim 12, further comprising:
determining that the reachable class is initialized at a different time than a compilation time in response to a determination that there is the reachable class in the target application.

### Claim 14 (depends on 12)

The computer program product of claim 12, wherein the determining that there is no assertion being executed before the initialization of the reachable class comprises:
determining whether the reachable method in the reachable class uses an assertion; and
ending compilation in response to a determination that the reachable method in the reachable class does not use the assertion.

### Claim 15 (depends on 12)

The computer program product of claim 12, wherein the determining that there is no assertion being executed before the initialization of the reachable class further comprises:
finding at least one super class in a reachable class hierarchy from the reachable class; and
finding a super class of the at least one super class that has a static initializer.

### Claim 16 (depends on 12)

The computer program product of claim 12, wherein the determining that there is no assertion being executed before the initialization of the reachable class further comprises:
traversing a static initializer to check the reachable method; and
determining whether the reachable method is found in the static initializer.

### Claim 17 (depends on 16)

The computer program product of claim 16, wherein the determining that there is no assertion being executed before the initialization of the reachable class further comprises:
ending compilation in response to determining that the reachable method is found in the static initializer; and
returning a no in response to determining that the reachable method is not found in the static initializer.

### Claim 18 (depends on 12)

The computer program product of claim 12, wherein the reachable class occurs when a class is executed by a virtual machine (VM), and the reachable class comprises an object-oriented language.

### Claim 19 (depends on 12)

The computer program product of claim 12, further comprising running a native image with the assertion related code removed from the reachable class.

### Claim 20

A system comprising:
a processor set, one or more computer readable storage media, and program instructions collectively stored on the one or more computer readable storage media, the program instructions executable to:
determine that a compiler option is not provided to enable an assertion for a reachable class in a target application;
determine that there is no application program interface (API) being used to enable the assertion found in a reachable method in the reachable class in response to a determination that the compiler option is not provided to enable the assertion for the reachable class;
determine that there is no assertion being executed before an initialization of the reachable class in response to a determination that there is no API being used to enable the assertion found in the reachable method in the reachable class; and
remove assertion related code from the reachable class in response to a determination that there is no assertion being executed before the initialization of the reachable class.
