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 - Hints for "surround with try-catch" aren't displayed when located outside of a method
Summary: Hints for "surround with try-catch" aren't displayed when located outside of ...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Tomas Hurka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-11 09:24 UTC by Max Sauer
Modified: 2005-09-05 09:34 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
screenshot (5.34 KB, image/png)
2005-08-11 09:26 UTC, Max Sauer
Details

Note You need to log in before you can comment on or make changes to this bug.
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.