Skip to content

Backport try-with-resources for Java 6 and below #38

Closed
@luontola

Description

@luontola

Though the try-with-resources statement doesn't introduce any new bytecode instructions, it uses the Throwable.addSuppressed method which was added in Java 7. Possible options for a backport:

  1. Swallow the suppressed exception
  2. Throw the suppressed exception, swallowing the original exception
  3. Print the stack trace of suppressed exceptions
  4. Log the suppressed exceptions

Option 2 is clearly undesirable. I think option 3 would possibly cause lots of unwanted stack traces in the console. Option 4 is what Guava's Closer does.

I think the viable options are 1 and 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions