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 62145

Summary: Hints for "surround with try-catch" aren't displayed when located outside of a method
Product: java Reporter: Max Sauer <msauer>
Component: HintsAssignee: Tomas Hurka <thurka>
Status: NEW ---    
Severity: blocker    
Priority: P3    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: screenshot

Description Max Sauer 2005-08-11 09:24:04 UTC
The Hint System "try-catch" feature doesn't work at all when used in a class
outside of a method, ie:

public class Main {
    String FileName = "new.txt";
    File fr = new File(FileName);
   |FileOutputStream fo = new FileOutputStream(fr);
    ...

Error annotation is displayed properly, but no hint is aviable (See attached
screenshot). Inside of a method, try-catch hint works fine.

This may be related to issue 61967 (Caused by the fix?)
Comment 1 Max Sauer 2005-08-11 09:26:09 UTC
Created attachment 23715 [details]
screenshot
Comment 2 Max Sauer 2005-08-11 09:38:29 UTC
Changing it to enhancement. Could be solved via initializer, like this:

class smtg {
    String FileName = "new.txt";
    File fr = new File(FileName);
    FileOutputStream fo;    
    {
        try {
            fo = new FileOutputStream(fr);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }
    }  
}

I can also use "Surround with Try-Catch" inside an initializer, but no hint is
aviable there.