Date: Sat, 31 May 2003 12:15:01 -0400 (EDT)
From: C. Scott Ananian
To: Neal M Gafter
Cc: jsr14-prototype-comments@sun.com
Subject: Broken signature emitted for <Some Enum>.valueOf()

In this thread, hhkratz reported problems using the valueOf method for an
enumeration class:
   http://forum.java.sun.com/thread.jsp?forum=316&thread=406073
For a simple enumeration class:
  enum SomeEnum { A };
javap (actually, SinjP) reports:

$ javap SomeEnum
Compiled from "SomeEnum.java"
class SomeEnum extends java.lang.Enum<SomeEnum>
{
    public static final java.util.List<SomeEnum> VALUES;
    public static final SomeEnum A;
    public final java.util.List<SomeEnum> family();
    public static java.util.List<SomeEnum> valueOf(java.lang.String);
    void <init>();
    public int compareTo(java.lang.Enum);
    public int compareTo(java.lang.Object);
    static void <clinit>();
}

Note that the return type of the valueOf method is reported as
List<SomeEnum>, rather than the proper SomeEnum.  But looking at the
bytecode (with FLEX):

Codeview "bytecode" for public static java.util.List SomeEnum.valueOf(java.lang.String):
  #2/SomeEnum.java:1 - getstatic public static final java.util.List SomeEnum.VALUES
  #3/SomeEnum.java:1 - aload_0 lv_0
  #4/SomeEnum.java:1 - invokestatic protected static java.lang.Enum java.lang.Enum.valueOf(java.util.List,java.lang.String)
  #5/SomeEnum.java:1 - areturn

So clearly the returned value is actually an Enum, not a List.

Therefore this is a bug in the generated signature (and descriptor;
not that the non-GJ-aware FLEX reports the type as 'List') for the
valueOf() method.
  --scott

blowfish MI5 AP Columbia mustard Dictionary Chechnya North Korea Ortega 
Richard Tomlinson Cheney Shoal Bay Seattle COBRA JUDY fissionable 
                         ( http://cscott.net/ )

Valid XHTML 1.0!