【24h】

The case for run-time types in generic Java

机译:通用Java中的运行时类型

获取原文
获取原文并翻译 | 示例

摘要

Since the advent of the Java Programming Language in 1995, many thoughtful proposals have been made for adding generic types to the Java programming language. Generic types are a glaring omission from the existing language, forcing programmers to use permissive, non-parametric type signatures for fields and methods of "naturally generic" classes (such as java.util.Vector) and repeatedly cast the results of operations on these classes to the more specific types. The JSR14 extension of Java proposed by Sun Microsystems (based on GJ) addresses this problem by adding generic types to the language, but prohibits operations that depend on run-time generic type information. This prohibition relegates generic types to "second-class" status where they are invisible at run-time, which is inconsistent with the status of types including parametric arrray types in the existing language. We have implemented a generalization of JSR14 called NextGen that supports the same syntactic extensions of Java of JSR14 yeteliminates the prohibition on operations that depend on run-time generic type information. In NextGen. generic types are "first-class": they can be used in excactly the same contexts as conventional types. The implementation of NextGen compiler is derived from the same prototype GJ compiler as the JSR14 compiler and shares most of its desirable properties including a high degree of compatibility with legacy code. In this paper, we show through of a series of programming examples that first-class generic types play an important role in writing clean generic code.
机译:自1995年Java编程语言问世以来,已经提出了许多周到的建议,以将通用类型添加到Java编程语言中。通用类型是对现有语言的明显忽略,它迫使程序员对“自然通用”类(例如java.util.Vector)的字段和方法使用许可的非参数类型签名,并在这些类型上重复执行操作结果类以更具体的类型。 Sun Microsystems(基于GJ)提出的Java的JSR14扩展通过在语言中添加通用类型来解决此问题,但禁止依赖于运行时通用类型信息的操作。该禁止将通用类型降级为“第二类”状态,在运行时它们是不可见的,这与现有语言中包括参数化错误类型的类型状态不一致。我们实现了称为NextGen的JSR14的泛化,该泛化支持JSR14的Java的相同语法扩展,但消除了对依赖于运行时泛型类型信息的操作的禁止。在NextGen中。泛型类型是“一流”的:它们可以在与常规类型完全相同的上下文中使用。 NextGen编译器的实现派生自与JSR14编译器相同的原型GJ编译器,并共享其大多数期望的属性,包括与遗留代码的高度兼容性。在本文中,我们通过一系列编程示例说明一流的泛型类型在编写干净的泛型代码中起着重要的作用。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号