cJ: enhancing java with safe type conditions

  • Authors:
  • Shan Shan Huang;David Zook;Yannis Smaragdakis

  • Affiliations:
  • Georgia Institute of Technology;Georgia Institute of Technology;University of Oregon

  • Venue:
  • Proceedings of the 6th international conference on Aspect-oriented software development
  • Year:
  • 2007

Quantified Score

Hi-index 0.00

Visualization

Abstract

cJ is an extension of Java that allows supertypes, fields, and methods of a class or interface to be provided only under some static subtyping condition. For instance, a cJ generic class, C, may provide a member method m only when the type provided for parameter P is a subtype of a specific type Q.From a practical standpoint, cJ adds to generic Java classes and interfaces the ability to express case-specific code. Unlike conditional compilation techniques (e.g., the C/C++ "#ifdef" construct) cJ is statically type safe and maintains the modular type-checking properties of Java generic classes: a cJ generic class can be checked independently of the code that uses it. Just like regular Java, checking a cJ class implies that all uses are safe, under the contract for type parameters specified in the class's signature.As a specific application, cJ addresses the well-known shortcomings of the Java Collections Framework (JCF). JCF data structures often throw run-time errors when an "optional" method is called upon an object that does not support it. Within the constraints of standard Java, the authors of the JCF had to either sacrifice static type safety or suffer a combinatorial explosion of the number of types involved. cJ avoids both problems, maintaining both static safety and conciseness.