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 254654 - ClassCastException: com.sun.tools.javac.code.Type$ForAll cannot be cast to com.sun.tools.javac.code.Type$MethodType
Summary: ClassCastException: com.sun.tools.javac.code.Type$ForAll cannot be cast to co...
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-24 13:41 UTC by lolo_101
Modified: 2015-09-08 11:51 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter: 213250


Attachments
stacktrace (6.45 KB, text/plain)
2015-08-24 13:41 UTC, lolo_101
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lolo_101 2015-08-24 13:41:49 UTC
Build: NetBeans IDE 8.1 Beta (Build 201508041349)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Java(TM) SE Runtime Environment, 1.8.0_51-b16
OS: Windows 7

User Comments:
GUEST: Opening projects

Lolo_101: Edited a java file in the editor.

Lolo_101: Opened the Navigator pane.

GUEST: viewing class in editor

GUEST: implementing Spring JpaRepository

Lolo_101: Pressed Alt-Enter on an anonymous class, hopefully to pop-up the "implement all methods" menu, but this exception showed up instead.

code looks like :

public interface Page<T> {...}

public Page<U> load(...) {
    return new Page<>() { // Here i clicked on Page to auto-implement all methods.
    }
}




Stacktrace: 
java.lang.ClassCastException: com.sun.tools.javac.code.Type$ForAll cannot be cast to com.sun.tools.javac.code.Type$MethodType
   at org.netbeans.api.java.source.ElementUtilities.findUnimplementedMethods(ElementUtilities.java:812)
   at org.netbeans.api.java.source.ElementUtilities.findUnimplementedMethods(ElementUtilities.java:792)
   at org.netbeans.api.java.source.ElementUtilities.findUnimplementedMethods(ElementUtilities.java:574)
   at org.netbeans.modules.java.hints.errors.ImplementAllAbstractMethods.createMessage(ImplementAllAbstractMethods.java:138)
   at org.netbeans.modules.java.hints.infrastructure.ErrorHintsProvider.computeErrors(ErrorHintsProvider.java:197)
   at org.netbeans.modules.java.hints.infrastructure.ErrorPositionRefresherHelper.getErrorDescriptionsAt(ErrorPositionRefresherHelper.java:84)
Comment 1 lolo_101 2015-08-24 13:41:51 UTC
Created attachment 155581 [details]
stacktrace
Comment 2 Svata Dedic 2015-08-27 11:33:02 UTC
Lolo_101: could you provide a more complete example ? I've tried a simple source file using your code:

public class Foo<U> {
    public interface Page<T> {
        public T whatever(T x);
    }

    public Page<U> load(int a) {
       return new Page<>() { // Here i clicked on Page to auto-implement all methods.
        }
    }
}


but the IDE does not even offer the 'implement all methods', since the compiler is unable to infer the type argument for the anonymous class
Comment 3 lolo_101 2015-09-02 21:43:33 UTC
(In reply to Svata Dedic from comment #2)
> Lolo_101: could you provide a more complete example ? I've tried a simple
> source file using your code:
> 
> public class Foo<U> {
>     public interface Page<T> {
>         public T whatever(T x);
>     }
> 
>     public Page<U> load(int a) {
>        return new Page<>() { // Here i clicked on Page to auto-implement all
> methods.
>         }
>     }
> }
> 
> 
> but the IDE does not even offer the 'implement all methods', since the
> compiler is unable to infer the type argument for the anonymous class

I just pressed Alt-Enter with the cursor on "Page" on the specified line. I dont know what hints were suggested. I just hoped for 'implement all' to be present to save me some key strokes.
Comment 4 Svata Dedic 2015-09-08 11:51:22 UTC
Cannot reproduce, as noted in comment #2. If the error happens again, please save the exact source for further investigation;