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 226053 - Mishandled JDK 1.7 multi catch - "catch( AException | BException ex ) " /// ClassCastException: com.sun.tools.javac.tree.JCTree$JCCatch cannot be cast to com.sun.source.tree.TryTree
Summary: Mishandled JDK 1.7 multi catch - "catch( AException | BException ex ) " /// C...
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P2 normal with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks: 225959
  Show dependency tree
 
Reported: 2013-02-13 11:23 UTC by mienamoo
Modified: 2013-05-24 05:40 UTC (History)
10 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 198158


Attachments
stacktrace (982 bytes, text/plain)
2013-02-13 11:23 UTC, mienamoo
Details
stacktrace (909 bytes, text/plain)
2013-02-14 05:31 UTC, misterm
Details
stacktrace (982 bytes, text/plain)
2013-02-16 15:34 UTC, pekarna
Details
stacktrace (982 bytes, text/plain)
2013-02-17 15:28 UTC, Chiana
Details
stacktrace (982 bytes, text/plain)
2013-02-18 09:58 UTC, Maksim Khramov
Details
stacktrace (982 bytes, text/plain)
2013-02-21 18:08 UTC, narsereg
Details
stacktrace (909 bytes, text/plain)
2013-03-18 09:45 UTC, Jiri Prox
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mienamoo 2013-02-13 11:23:33 UTC
Build: NetBeans IDE Dev (Build 201302070001)
VM: Java HotSpot(TM) 64-Bit Server VM, 23.6-b04, Java(TM) SE Runtime Environment, 1.7.0_11-b21
OS: Windows 7

User Comments:
mienamoo: I searched in the module for a string that appears in a catch block. This exception occurred when I navigated to the code.

jag: Editing catch clause with '|'

jag: Editing catch

jag: Attempted to "run" project




Stacktrace: 
java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCCatch cannot be cast to com.sun.source.tree.TryTree
   at org.netbeans.modules.java.editor.semantic.MarkOccurrencesHighlighter.processImpl(MarkOccurrencesHighlighter.java:319)
   at org.netbeans.modules.java.editor.semantic.MarkOccurrencesHighlighter.run(MarkOccurrencesHighlighter.java:173)
   at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:561)
   at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:737)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
Comment 1 mienamoo 2013-02-13 11:23:34 UTC
Created attachment 131339 [details]
stacktrace
Comment 2 misterm 2013-02-14 05:31:47 UTC
Created attachment 131374 [details]
stacktrace
Comment 3 pekarna 2013-02-16 15:34:49 UTC
Created attachment 131456 [details]
stacktrace
Comment 4 pekarna 2013-02-16 15:40:43 UTC
In my case, it's 

         catch( IOException | EJBTransactionRolledbackException ex ) {
Comment 5 pekarna 2013-02-16 15:41:51 UTC
Makes editing of some sources impossible, I dare setting P2.

NetBeans IDE Build 201302020001
Comment 6 Chiana 2013-02-17 15:28:50 UTC
Created attachment 131484 [details]
stacktrace

Stepping over some code with the debugger, this is caused by an exception beeing thrown in the debugger when it accesses the data.
Code below.
  TableColumn[] needResolving = new TableColumn[0];
    boolean resolvLater = false;
    try {
      // Create an entity instance
      data = table.classFor.newInstance(); <-- Problem appears here when data is created
    } catch (InstantiationException | IllegalAccessException ex) {
      throw new RuntimeException(ex);
    }                                                            <-- This is thrown here!
    // A table.callPreLoad would have been here if it made any sense
    // Transform the data
    for (int col = 0; col < table.columns.length; col++) {
Comment 7 Chiana 2013-02-17 15:38:20 UTC
I stepped one line more after this had occured and then #658789 (report #198675) occured
Comment 8 Maksim Khramov 2013-02-18 09:58:52 UTC
Created attachment 131522 [details]
stacktrace
Comment 9 Exceptions Reporter 2013-02-18 09:58:58 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=198158
Comment 10 narsereg 2013-02-21 18:08:00 UTC
Created attachment 131688 [details]
stacktrace

I tried to use multicatch. Now this sring highlighted with red (as error) but source was changed to Java 7 after this error appeared.
Comment 11 Jiri Prox 2013-02-22 07:39:36 UTC
reproducible

my steps to reproduce:
1) have a code:
try {
	    FileReader fileReader = new FileReader("");
	    URL r = new URL("asadsadasdasda");
	} catch (MalformedURLException ex) {
	    Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
	} catch (FileNotFoundException ex) {
	    Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
	}

2) apply 'change to multicatch' hint



Product Version: NetBeans IDE Dev (Build 20130220-b02dbd2e0ef0)
Java: 1.7.0_15; Java HotSpot(TM) 64-Bit Server VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_15-b03
System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb)
User directory: C:\Users\jprox\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\jprox\AppData\Local\NetBeans\Cache\dev
Comment 12 Jiri Prox 2013-03-18 09:45:46 UTC
Created attachment 132746 [details]
stacktrace

CCE when calling code completion in following method:

 public void process (FooInnerClass callback) {
	System.out.println("callback");
	String fieldName = "";
	"".matches("");
	Class clazz = callback.getClass();
	try {

	    final Field field = clazz.getField(fieldName); //marked as error


	}
	catch (IntrospectionException | SecurityException ex) {
	    throw new RuntimeException(ex);
	}


    }
Comment 13 Dusan Balek 2013-03-22 16:52:09 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/2afe7ca05491
Comment 14 Quality Engineering 2013-03-24 01:54:22 UTC
Integrated into 'main-golden', will be available in build *201303232300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/2afe7ca05491
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #226053 - Mishandled JDK 1.7 multi catch - fixed.
Comment 15 mienamoo 2013-05-24 05:40:39 UTC
Verified with build 201305212300. Thanks to everybody involved!