Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How to raise a warning if the close() function of a user-defined class isn't called?

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to raise a warning if the close() function of a user-defined class isn't called?

    I've been searching how to raise a warning in Java if a specific object from a class that has a close() function in it doesn't at some point call that close() function (as for example for the BufferedReader class).
    In searching through this, I found the Closeable and AutoCloseable interfaces and how they work.

    But I still face the issue that when the object in question is created through a function, it is not supposed that it hasn't been closed.

    Is it possible to get a Closeable object from a function with it still being considered unclosed ?

    Thanks !

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    23,844
    Thanks
    53
    Thanked 2,576 Times in 2,527 Posts

    Default Re: How to raise a warning if the close() function of a user-defined class isn't called?

    This discusses similar problem: https://stackoverflow.com/questions/...ream-is-closed
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Function is not defined
    By ssole in forum Other Programming Languages
    Replies: 1
    Last Post: August 5th, 2019, 11:22 AM
  2. Help with formatting and creating a user defined class.
    By mike61096 in forum Object Oriented Programming
    Replies: 1
    Last Post: October 1st, 2014, 01:37 PM
  3. User Defined Criteria
    By SimonTemplar in forum Java Theory & Questions
    Replies: 0
    Last Post: February 20th, 2013, 07:02 PM
  4. User-Defined Methods
    By ZippyShannon in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 28th, 2011, 10:23 PM
  5. User Defined Methods
    By mgutierrez19 in forum Object Oriented Programming
    Replies: 11
    Last Post: October 20th, 2009, 06:57 PM

Tags for this Thread