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 257967 - ClassCastException: com.sun.tools.javac.code.Type$UnionClassType cannot be cast to com.sun.tools.javac.code.Type$IntersectionClassType
Summary: ClassCastException: com.sun.tools.javac.code.Type$UnionClassType cannot be ca...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-12 20:32 UTC by klawson88
Modified: 2016-02-12 20:32 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 205481


Attachments
stacktrace (4.32 KB, text/plain)
2016-02-12 20:32 UTC, klawson88
Details

Note You need to log in before you can comment on or make changes to this bug.
Description klawson88 2016-02-12 20:32:06 UTC
Build: NetBeans IDE 8.0 (Build 201403101706)
VM: Java HotSpot(TM) Client VM, 25.31-b07, Java(TM) SE Runtime Environment, 1.8.0_31-b13
OS: Windows 7

User Comments:
GUEST: A simple Clean and Build of a maven project.

klawson88: Using the "instanceof" operator on an exception caught in a multicatch block made to catch two exceptions which have a "cousin first removed" relationship causes this error, which prevents the IDE from providing assistive features such as autocomplete, and error highlighting.

Problematic code snippet (WriteTimeoutException is a child of QueryTimeoutException, which, along with UnavailableException and TruncateException (not seen here), is a child of QueryExcecutionException (also not seen here)): 

package wiki.nouns.actions;

import com.datastax.driver.core.exceptions.UnavailableException;
import com.datastax.driver.core.exceptions.WriteTimeoutException;
/**
 *
 * @author
 */
public class TestAction 
{
    
    public void test(Exception e)
    {
        try
        {
            
        }
        catch(WriteTimeoutException | UnavailableException rr)
        {
            
            if(rr instanceof WriteTimeoutException)
            {
                
            }

juansmolano: It took me a while to figure this out.  Only happens on NEtBeans 7.4 (Mac and Linux)

on a managedBean althought netbeans recomend to use multi catch with pipes (Ex1 | Ex2 | ...)  all help from netbeans (tips, autocomplete, etc) just stops when using this type of multi catch.

my concrete implementation was:

try{
 ....
}catch(EmptyActiveServiceListException | ServiceProviderParameterNotFoundException | 
                NotSupportedServiceException | IncorrectPinCodeException | InsufficientBalanceException |
                BusinessUnitAssociatedServiceNotFoundException | EnumTypeNotAllowedException ex){
      messageTools.displayMessage(FacesMessage.SEVERITY_ERROR, ((UserVisibleException) ex).getExMsgKey(), null);
}


And everything comes to normal when replaced by:

try{
....
}  catch (Exception ex) {
            messageTools.displayMessage(FacesMessage.SEVERITY_ERROR, ((UserVisibleException) ex).getExMsgKey(), null);
 }

GUEST: Occurs after restart and after cleaning the cache.

juansmolano: Installed NEtBeans 7.4 Full Bundle on Mac OS X without importing setting from NetBeans 7.3 and then Open an Enterprise App compose of 10+ EJBs and 1 WAR

GUEST: Error always happen for this class. Also If I cleared cache.




Stacktrace: 
java.lang.ClassCastException: com.sun.tools.javac.code.Type$UnionClassType cannot be cast to com.sun.tools.javac.code.Type$IntersectionClassType
   at com.sun.tools.javac.code.Types$10.visitClassType(Types.java:1544)
   at com.sun.tools.javac.code.Types$10.visitClassType(Types.java:1503)
   at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:763)
   at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4430)
   at com.sun.tools.javac.code.Types.isCastable(Types.java:1494)
   at com.sun.tools.javac.comp.Check.checkCastable(Check.java:572)
Comment 1 klawson88 2016-02-12 20:32:09 UTC
Created attachment 158480 [details]
stacktrace