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 3 of 3

Thread: What exactly are supresswarnings?

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default What exactly are supresswarnings?

    I only know the Java basics but now I came across this thing called a supresswarning, I've seen it before but I never knew what it meant.
    Can someone explain it? I tried to google the answer but I had some trouble understanding it.

    Thanks
    Last edited by kaskoepoes112; June 15th, 2014 at 04:29 AM. Reason: for some reason I put a random "because" in the 2nd line

  2. #2
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    345
    My Mood
    Angelic
    Thanks
    27
    Thanked 51 Times in 45 Posts

    Default Re: What exactly are supresswarnings?

    It may differ from language to language but in C at least a suppressed warning is
    a warning that is sort of "in hiding". When the program compiles and translates the
    source code into machine code - it checks over the source before finishing the
    translation. If it finds a syntax error - you get a compilation error. If it checks through
    your code and finds something that "could" be wrong - it gives you a warning.

    Sometimes the warnings it issues are suppressed because an event that could happen in the code
    has not yet happened. The warning sits in the interpreter and while the code is being executed
    it may or may not appear visible to the programmer. One common example of this type of warning
    is a runtime exception which is an error in itself, but will only appear once something has been
    over-written in memory that should not have been.

    Best way I can explain it without being too technical.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  3. The Following User Says Thank You to Ada Lovelace For This Useful Post:

    kaskoepoes112 (June 15th, 2014)

  4. #3
    Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    450
    Thanks
    0
    Thanked 87 Times in 72 Posts

    Default Re: What exactly are supresswarnings?

    Your java compiler will generate warnings in certain situations, for example when you use a generic class but you dont specify a generic class type parameter.
    Oftentimes you should read these warnings and try to solve the problem they are referring to. They are, in general, very useful.
    But sometimes they might be "wrong", because the compiler is not very smart. Maybe there is no other way around because you work with an old API. Maybe the alternative would be much more complicated and error prone.
    This does not happen often, but its possible.

    This is the reason why you are able to explicitely tell the compiler to ignore a certain problem and supress the warning for that particular instance. It has no other effect. It will only make the compiler shut up.

  5. The Following User Says Thank You to Cornix For This Useful Post:

    kaskoepoes112 (June 15th, 2014)