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 235555 - ClassCastException: com.sun.tools.javac.tree.JCTree$JCForLoop cannot be cast to com.sun.source.tree.BlockTree
Summary: ClassCastException: com.sun.tools.javac.tree.JCTree$JCForLoop cannot be cast ...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-05 13:19 UTC by Jiri Prox
Modified: 2014-02-01 05:45 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 203608


Attachments
stacktrace (6.48 KB, text/plain)
2013-09-05 13:19 UTC, Jiri Prox
Details
stacktrace (7.55 KB, text/plain)
2014-01-21 12:24 UTC, aldobrucale
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Prox 2013-09-05 13:19:56 UTC
Build: NetBeans IDE Dev (Build 20130905-bba83179662f)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.0-b40, Java(TM) SE Runtime Environment, 1.8.0-ea-b98
OS: Windows 7

User Comments:
jiriprox: CCE when calling safe delete on i in for loop

 public static void main(String[] args) {
        for (int i = 0; i < args.length; i++) {
            String string = args[i];
            
        }
    }




Stacktrace: 
java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCForLoop cannot be cast to com.sun.source.tree.BlockTree
   at org.netbeans.modules.refactoring.java.plugins.DeleteTransformer.deleteDeclIfMatch(DeleteTransformer.java:93)
   at org.netbeans.modules.refactoring.java.plugins.DeleteTransformer.visitVariable(DeleteTransformer.java:72)
   at org.netbeans.modules.refactoring.java.plugins.DeleteTransformer.visitVariable(DeleteTransformer.java:56)
   at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:864)
   at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
   at org.netbeans.modules.refactoring.java.spi.RefactoringVisitor.scan(RefactoringVisitor.java:209)
Comment 1 Jiri Prox 2013-09-05 13:19:58 UTC
Created attachment 139701 [details]
stacktrace
Comment 2 aldobrucale 2014-01-21 12:24:51 UTC
Created attachment 144196 [details]
stacktrace

Tried to safely delete a variable in a try-with resources construct:

try (InputStream a = ..., InputStream b = ...) {
    ... do things with "a"...
}

Here i tried to delete b
Comment 3 Ralph Ruijs 2014-01-30 12:46:54 UTC
changeset   : a967e829f542
author      : Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
date        : Thu Jan 30 13:18:03 CET 2014
summary     : #235555 - ClassCastException: com.sun.tools.javac.tree.JCTree$JCForLoop cannot be cast to com.sun.source.tree.BlockTree
Comment 4 Quality Engineering 2014-02-01 05:45:35 UTC
Integrated into 'main-silver', will be available in build *201402010001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/a967e829f542
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: #235555 - ClassCastException: com.sun.tools.javac.tree.JCTree$JCForLoop cannot be cast to com.sun.source.tree.BlockTree