CWE-1235 · Słabość
Incorrect Use of Autoboxing and Unboxing for Performance Critical Operations
- Abstrakcja
- Bazowa
- Status
- Niekompletny
- Dodano
- 14 października 2019
- Ostatnia zmiana
- 11 grudnia 2025
Opis
The code uses boxed primitives, which may introduce inefficiencies into performance-critical operations.
Skutki
Availability
DoS: Resource Consumption (CPU); DoS: Resource Consumption (Memory); DoS: Resource Consumption (Other); Reduce Performance
Incorrect autoboxing/unboxing would result in reduced performance, which sometimes can lead to resource consumption issues, impacting availability when used with generic collections.
Zapobieganie
Implementation
Use of boxed primitives should be limited to certain situations such as when calling methods with typed parameters. They should not be used for scientific computing or other performance critical operations. They are only suited to support "impedance mismatch" between reference types and primitives. Examine the use of boxed primitives prior to use. Use SparseArrays or ArrayMap instead of HashMap to avoid performance overhead.
Słabość nadrzędna
Kiedy powstaje
- Implementation — The programmer may use boxed primitives when not strictly necessary.
Dotyczy
Java, C#, Not OS-Specific, Not Architecture-Specific, Not Technology-Specific
Źródła
- Oracle Java Documentation
- SEI CERT Oracle Coding Standard for Java : Rule 02. Expressions (EXP) — The Software Engineering Institute
Wpis z katalogu CWE 4.20.