范型JAVA

原创 2001年12月30日 15:36:00

GJ is an extension of the Java programming language that supports generic types.

  • Support for generics. Many data types are generic over some other data type, and this is especially common for reusable libraries such as collection classes. GJ supports the use of such types, for instance allowing one to write the GJ type Vector<String> as opposed to the Java type Vector. With GJ, fewer casts are required, and the compiler catches more errors.

  • Superset of the Java programming language. Every Java source program is still legal and retains the same meaning in GJ. The GJ compiler can be used as a Java compiler.

  • Compiles into the Java Virtual Machine. GJ compiles into JVM code, so GJ programs run on any Java platform, including Java compliant browsers. Class files produced by the GJ compiler can be freely mixed with those produced by other Java compilers.

  • Compatible with existing libraries. One can call any Java library function from GJ, and any GJ library function from Java. Further, where it is sensible, one can assign GJ types to existing Java libraries. For instance, the GJ type Vector<String> is implemented by the Java library type Vector.

  • Efficient translation. GJ is translated by erasure: no information about type parameters is maintained at run-time. This means GJ code is pretty much identical to Java code for the same purpose, and equally efficient.

  • Freely available and fully documented. The GJ compiler is itself written in GJ, so it runs on any platform that supports Java. The GJ compiler is available for download, and there is extensive documentation.

  • Related work. There are several related attempts to add generic types to Java, including our previous work on Pizza. GJ differs from these in that it places a premium on compatibility with old Java programs, which is important to developers that want to evolve smoothly from Java to GJ.

GJ was designed by Gilad Bracha of JavaSoft, Martin Odersky of the University of South Australia, David Stoutamire of JavaSoft, and Philip Wadler of Bell Labs, Lucent Technologies. Although JavaSoft employees contributed to its design, GJ is not a product of JavaSoft or Sun Microsystems and neither JavaSoft nor Sun Microsystems makes any claims regarding it.


Sun proposes to add generic types to Java

Sun has put forward a proposal to Add Generic Types To The Java Programming Language as part of the Java Community Process. GJ is one of the leading proposals being considered. The process is spearheaded by Gilad Bracha, one of the GJ designers.

Sun maintains a Bug Parade where users can vote to give feedback on which shortcomings in Java they would like to see fixed. A request to add generics to Java is bug number 4064105, and is in The Top Twenty-five Requests for Enhancements.

(You need to register with Sun's Java developer connection to follow the above links.)

Java范型浅析

        从jdk1.5开始,Java中开始支持范型了。范型是一个很有用的编程工具,给我们带来了极大的灵活性。在看了《java核心编程》之后,我小有收获,写出来与大家分享。        所谓范...
  • andycpp
  • andycpp
  • 2007年08月17日 20:18
  • 12392

java 设置多个泛型类型

1 class NotePad{ 2 private K key; 3 private V value; 4 public K getKey() { 5 re...
  • hjw541988478
  • hjw541988478
  • 2013年07月12日 11:24
  • 1374

JAVA范型

起因: JDK1.4以前类型不明确: 1.装入集合的类型都被装作Object对待,从而失去自己的实际类型。 2.从集合中取出时往往需要转型,效率低,容易产生错误。 解决办法: 1.在定义集合的时候同时...
  • Airv
  • Airv
  • 2007年05月15日 10:23
  • 509

java范型

Class a = new ArrayList().getClass(); Class b = new ArrayList().getClass(); System.out.println(a == ...
  • zsz459520690
  • zsz459520690
  • 2016年07月17日 17:16
  • 168

简单的关于java的伪泛型的一个小例子

Java的泛型,不同于c#的泛型,    c#中的泛型无论在程序的源码中,编译后的IL中,还是在运行前的CLR中都切实存在的, List与List就是两个不同的类型,它们在运行期生成, 有自己的虚方法...
  • u013135520
  • u013135520
  • 2017年01月02日 23:13
  • 453

跟我撩fastjson-第三章:Java泛型的序列化和反序列化

我们在第二章中讲解的集合例子,集合中数据类型都是简单的String类型。现在我们来一个稍微复杂点的,List中存放的是User对象实例,那么应该如何序列化和反序列化呢?我们直接上代码。 /** ...
  • XGL8552
  • XGL8552
  • 2017年10月15日 16:20
  • 119

Java范型

一:范型方法 public T get(Class c) throws InstantiationException, IllegalAccessException{ T t = c.newI...
  • aojiancc2
  • aojiancc2
  • 2013年12月12日 16:39
  • 459

Java中的范型类型强制转化注意2

Type mismatch Error : Cannont convert from ArrayList to List It seems you're trying t...
  • u010746364
  • u010746364
  • 2016年04月26日 07:54
  • 188

泛型之类型推导

概述 编译器判断泛型方法的实际类型参数的过程叫做类型推断,类型推断的实现方法是一种非常复杂的过程. 根据调用泛型方法时实际传递的参数类型或返回值类型来推断,具体规则如下: 如果某类型变量只在方法...
  • litefish
  • litefish
  • 2015年05月11日 10:47
  • 453

[java]范型

范型
  • nydxgby
  • nydxgby
  • 2014年11月06日 13:05
  • 92
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:范型JAVA
举报原因:
原因补充:

(最多只允许输入30个字)