bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/33813] New: Enum.valueOf throws java.lang.Error: Unable t


From: stephan at cs dot tu-berlin dot de
Subject: [Bug classpath/33813] New: Enum.valueOf throws java.lang.Error: Unable to access Enum class
Date: 19 Oct 2007 01:07:44 -0000

The following snippet runs on Sun VM but fails when using Gun classpath 
(using JamVM):

public class T {
    static enum E { A, B, C }
    public static void main(String[] args) {
        E e= E.valueOf("A");
        System.out.println(e);
    }
}

Reason: the implementation of Enum.valueOf uses reflection to access
the value of field E.A, but class Enum is not in the same package as
E and thus has no access to this field.
=> Field.get(..) throws IllegalAccessException.

Chaning E to public avoids the problem.


-- 
           Summary: Enum.valueOf throws java.lang.Error: Unable to access
                    Enum class
           Product: classpath
           Version: 0.92
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: classpath
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stephan at cs dot tu-berlin dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33813





reply via email to

[Prev in Thread] Current Thread [Next in Thread]