Guarded Type Promotion: Eliminating Redundant Casts in Java

Research output: Contribution to book/anthology/report/proceedingArticle in proceedingsResearchpeer-review

Standard

Guarded Type Promotion : Eliminating Redundant Casts in Java. / Winther, Johnni.

Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs . Association for Computing Machinery, 2011.

Research output: Contribution to book/anthology/report/proceedingArticle in proceedingsResearchpeer-review

Harvard

Winther, J 2011, Guarded Type Promotion: Eliminating Redundant Casts in Java. in Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs . Association for Computing Machinery, Formal Techniques for Java-Like Programs, Lancaster, United Kingdom, 26/07/2011. https://doi.org/10.1145/2076674.2076680

APA

Winther, J. (2011). Guarded Type Promotion: Eliminating Redundant Casts in Java. In Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs Association for Computing Machinery. https://doi.org/10.1145/2076674.2076680

CBE

Winther J. 2011. Guarded Type Promotion: Eliminating Redundant Casts in Java. In Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs . Association for Computing Machinery. https://doi.org/10.1145/2076674.2076680

MLA

Winther, Johnni "Guarded Type Promotion: Eliminating Redundant Casts in Java". Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs . Chapter 6, Association for Computing Machinery. 2011. https://doi.org/10.1145/2076674.2076680

Vancouver

Winther J. Guarded Type Promotion: Eliminating Redundant Casts in Java. In Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs . Association for Computing Machinery. 2011 https://doi.org/10.1145/2076674.2076680

Author

Winther, Johnni. / Guarded Type Promotion : Eliminating Redundant Casts in Java. Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs . Association for Computing Machinery, 2011.

Bibtex

@inproceedings{92765cc0bdd643449e2a96165b719d63,
title = "Guarded Type Promotion: Eliminating Redundant Casts in Java",
abstract = "In Java, explicit casts are ubiquitous since they bridge the gap between compile-time and runtime type safety. Since casts potentially throw a ClassCastException, many programmers use a defensive programming style of guarded casts. In this programming style casts are protected by a preceding conditional using the instanceof operator and thus the cast type is redundantly mentioned twice. We propose a new typing rule for Java called Guarded Type Promotion aimed at eliminating the need for the explicit casts when guarded. This new typing rule is backward compatible and has been fully implemented in a Java 6 compiler. Through our extensive testing of real-life code we show that guarded casts account for approximately one fourth of all casts and that Guarded Type Promotion can eliminate the need for 95 percent of these guarded casts. ",
keywords = "Java, type cast, type checking",
author = "Johnni Winther",
year = "2011",
doi = "10.1145/2076674.2076680",
language = "English",
isbn = "978-1-4503-0893-9",
booktitle = "Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs",
publisher = "Association for Computing Machinery",
note = "Formal Techniques for Java-Like Programs, FTfJP ; Conference date: 26-07-2011 Through 26-07-2011",

}

RIS

TY - GEN

T1 - Guarded Type Promotion

T2 - Formal Techniques for Java-Like Programs

AU - Winther, Johnni

N1 - Conference code: 13

PY - 2011

Y1 - 2011

N2 - In Java, explicit casts are ubiquitous since they bridge the gap between compile-time and runtime type safety. Since casts potentially throw a ClassCastException, many programmers use a defensive programming style of guarded casts. In this programming style casts are protected by a preceding conditional using the instanceof operator and thus the cast type is redundantly mentioned twice. We propose a new typing rule for Java called Guarded Type Promotion aimed at eliminating the need for the explicit casts when guarded. This new typing rule is backward compatible and has been fully implemented in a Java 6 compiler. Through our extensive testing of real-life code we show that guarded casts account for approximately one fourth of all casts and that Guarded Type Promotion can eliminate the need for 95 percent of these guarded casts.

AB - In Java, explicit casts are ubiquitous since they bridge the gap between compile-time and runtime type safety. Since casts potentially throw a ClassCastException, many programmers use a defensive programming style of guarded casts. In this programming style casts are protected by a preceding conditional using the instanceof operator and thus the cast type is redundantly mentioned twice. We propose a new typing rule for Java called Guarded Type Promotion aimed at eliminating the need for the explicit casts when guarded. This new typing rule is backward compatible and has been fully implemented in a Java 6 compiler. Through our extensive testing of real-life code we show that guarded casts account for approximately one fourth of all casts and that Guarded Type Promotion can eliminate the need for 95 percent of these guarded casts.

KW - Java

KW - type cast

KW - type checking

U2 - 10.1145/2076674.2076680

DO - 10.1145/2076674.2076680

M3 - Article in proceedings

SN - 978-1-4503-0893-9

BT - Proceedings of the 13th Workshop on Formal Techniues for Java-Like Programs

PB - Association for Computing Machinery

Y2 - 26 July 2011 through 26 July 2011

ER -