This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 121458 - Compiler does not recognize interface method when a enum implements it using generic
Summary: Compiler does not recognize interface method when a enum implements it using ...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords:
: 121454 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-11-08 11:42 UTC by pnizer
Modified: 2008-01-31 15:19 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pnizer 2007-11-08 11:42:01 UTC
public interface Interface <T> {
    void method(T obj);
}

public enum NewEnum implements Interface<Integer> {
    ENUM1 {
        public void method(Integer obj) {
        }
    };
}

public class Main {
    public static void main(String[] args) {
        NewEnum newe = NewEnum.ENUM1;
        newe.method(new Integer(1));        // error here
    }
}

When I try to compile this code, the following error occurs:

Compiling 3 source files to C:\Documents and Settings\opd132\My Documents\NetBeansProjects\EnumTest\build\classes
C:\NetBeansProjects\EnumTest\src\enumtest\Main.java:15: cannot find symbol
symbol  : method method(java.lang.Integer)
location: class enumtest.NewEnum
        newe.method(new Integer(1));
1 error
BUILD FAILED (total time: 1 second)
Comment 1 pnizer 2007-11-08 11:44:58 UTC
*** Issue 121454 has been marked as a duplicate of this issue. ***
Comment 2 Jan Lahoda 2007-11-08 15:37:00 UTC
Sorry, but this appears to be a bug in JDK/javac not in the NetBeans IDE (the NB IDE uses ant and command line javac to
do the build). We can improve the in-IDE parser to handle this situation correctly, but we cannot fix the compiler that
is used to perform the build - sorry.

Two action items for us:
-jlahoda: file a bug against javac
-dbalek: try to fix this problem in the in-IDE parser
Comment 3 Marian Mirilovic 2007-11-08 16:16:40 UTC
Honza, 
please once you report an issue against javac, write a note here with the bug number. Thank in advance.
Comment 4 pnizer 2007-11-08 16:55:16 UTC
I've tried to compile this code using javac, and the error occurs too.
Using Eclipse it works fine.
Comment 5 Dusan Balek 2007-11-09 18:46:55 UTC
Problem in the IDE parser fixed. Reassigning to Honza.
Comment 6 pnizer 2007-11-15 22:50:07 UTC
I found an old issue against javac about this bug:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6330385

There is a work arround for this bug that is compile enum class first.
Is there a way to force netbeans compile enum class first?
Comment 7 Jan Becicka 2008-01-31 15:19:48 UTC
IDE parser fixed. Bug already reported against javac.