Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 475895

Summary: Annotation or Workbench-Setting to ignore certain resource warnings
Product: [Eclipse Project] JDT Reporter: Marvin Fröhlich <eclipse>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Marvin Fröhlich CLA 2015-08-26 05:49:00 EDT
This is just an idea and I don't even know, if it's right put here.

We have a very useful set of utility methods to handle input and output streams. One of them looks like this:

StreamUtils.transferBytes( in, out );

It reads the bytes from in and writes them to out. In the above signature variant it will automatically close in and out after all.

If the streams are created in the same method, then a compile warning will arise (if not disabled), that tells me to close the streams.

Couldn't we have an annotation for a method like this, that would make the compiler aware of the method closing the streams?

Alternatively Eclipse could know about certain methods to close resources and hence suppress warnings for it.

Compared to a utility method like this even the nice try-with-resources is bloated.

What do you mean?
Is this the right place to ask?
Comment 1 Eclipse Genie CLA 2020-05-07 13:38:04 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 2 Stephan Herrmann CLA 2020-05-07 17:13:52 EDT
Since bug 381445 the compiler uses a white list for known close methods.

The annotation idea is similar to bug 413854.