Questions tagged [unchecked]

An option "unchecked" used to turn off a javac compiler warnings about failing to use generics because it does not have enough type information to perform all type checks necessary to ensure type safety.

The term "unchecked" means that the javac compiler does not have enough type information to perform all type checks necessary to ensure type safety. The "unchecked" warning is disabled, by default, though the compiler gives a hint. To see all "unchecked" warnings, recompile with -Xlint:unchecked.

In JDK 1.5 an annotation was introduced called SuppressWarnings. It could be used to insert the annotation prior to a class or method telling which sort of warning you want suppressed.

A @SuppressWarning option unchecked used to turn off a javac compiler warnings about failing to use generics.

234 questions
5
votes
3 answers

Does the placement of @SuppressWarnings("unchecked") matter?

I had used @SuppressWarnings("unchecked") like: class SomeClass { public static void main(String [] args) { Vector v = new Vector(); @SuppressWarnings("unchecked") v.addElement(new Integer(1_000_000)); // ... On…
Seshadri R
  • 990
  • 9
  • 21
5
votes
3 answers
5
votes
3 answers

How to do this without unchecked?

a few months ago I wrote this code because it was the only way I could think to do it(while learning C#), well. How would you do it? Is unchecked the proper way of doing this? unchecked //FromArgb takes a 32 bit value, though says it's signed. Which…
Earlz
  • 57,517
  • 89
  • 275
  • 484
5
votes
2 answers

Java generic Observer Pattern implementation unchecked call as raw type

I am currently trying to utilize a generic implementation of the Observer Pattern in Java I found that seems to work quite well except for the fact that it generates unchecked call warnings that I'd like to fix if possible. The implementation looks…
qwertymodo
  • 415
  • 5
  • 15
5
votes
3 answers

How to un-check radio button without radio group?

I have used the following code snippet to set one radio button to unchecked if the other is selected,but when I run the application and select both radio buttons the code doesn't work as both stay selected. I'm using a relative layout so I can't use…
Brian J
  • 5,416
  • 19
  • 94
  • 189
5
votes
3 answers

getElementByName returns Type Error?

My code: var isSomethingChecked = (document.getElementByName("koalaCheck").checked || document.getElementByName("kangarooCheck").checked); Why does this code throw an exception called "Type Error"?
jth41
  • 3,542
  • 8
  • 50
  • 105
4
votes
1 answer

No unchecked warnings in NetBeans 7.1 Java EE

I use Java EE 6 with Java 7 and Glassfish 3.1.1. When I choose "clean and build" option in menu it works but it doesn't show warnings about unchecked operations. How to enable it? And additional question: Is there any way to enable all warnings to…
guest
  • 1,280
  • 4
  • 18
  • 31
4
votes
3 answers

Recursive generics

Is there a way to make this method properly generic and do away with the warnings? /** *

Sort a collection by a certain "value" in its entries. This value is retrieved using * the given valueFunction which takes an entry as…

Bart van Heukelom
  • 40,403
  • 57
  • 174
  • 291
4
votes
3 answers

Java unchecked operation cast to generic

I am wondering why the following issues a warning about an unsafe / unchecked operation: Map sessionMap = (Map) se.getSession().getServletContext().getAttribute("myattribute"); Is the cast wrong? I can't…
gpol
  • 916
  • 2
  • 17
  • 29
4
votes
3 answers

unchecked block doesn't work with BigInteger?

Just noticed that the unchecked context doesn't work when working with a BigInteger, for instance: unchecked { // no exception, long1 assigned to -1 as expected var long1 = (long)ulong.Parse(ulong.MaxValue.ToString()); } unchecked { var…
theburningmonk
  • 14,865
  • 12
  • 57
  • 103
4
votes
3 answers

java generics, unchecked warnings

here is part of tutorial in oracle page : Consider the following example: List l = new ArrayList(); List ls = l; // unchecked warning l.add(0, new Integer(42)); // another unchecked warning String s = ls.get(0); // ClassCastException…
tomaas
  • 129
  • 1
  • 6
4
votes
4 answers

Java: unchecked call to compareTo(T)

1 class test { 2 public static int compare0(Comparable x, Comparable y) { 3 return x.compareTo(y); 4 } 5 public static int compare1(Object x, Object y) { 6 return ((Comparable) x).compareTo((Comparable) y); …
kjo
  • 27,601
  • 42
  • 124
  • 225
4
votes
0 answers

Eclipse Helios - @SuppressWarnings "rawtypes" doesn't work while "unchecked" does

I have a problem with the @SuppressWarnings annotation when handling raw-types warnings in Eclipse Helios. According to this post and the docs, the annotation parameter rawtypes should be used instead of the old unchecked in Eclipse Helios. However,…
janhink
  • 4,744
  • 2
  • 27
  • 37
4
votes
3 answers

Create a list of item on a single line, then query list to see if item exists, without receiving unchecked conversion warning in Java

I want a list of things, and then I want to test the list to see if an item exists: Here is my example snippet: String[] handToolArray = {"pliers", "screwdriver", "tape measure"}; List handToolList = new ArrayList(…
mb-texas
  • 338
  • 5
  • 8
4
votes
4 answers

Java checked and unchecked exceptions

If I create an exception class that extends Exception, will my class be checked or unchecked? I note that the subclass of Exception called RuntimeException is an unchecked exception whereas all other subclasses of 'Exception' are checked…
danger mouse
  • 1,397
  • 1
  • 14
  • 28