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.

243 questions
17
votes
3 answers

How to avoid unchecked cast warnings with Java Generics

Somehow my old question was closed, so I open a new one: I am using Java Generics to implement a generic bidirectional Hash Map out of an SQL Query. It should be able to map any combination of String, Integer pairs back and forth. It should be used…
Sauer
  • 1,429
  • 4
  • 17
  • 32
17
votes
7 answers

Uncheck radio button on click using jquery

Radio buttons are unchecked only at page refresh 12 $("#btn").click(function(){ $(':radio').each(function () { …
DON
  • 835
  • 1
  • 8
  • 21
17
votes
3 answers

Compilation warning: Unchecked call to XXX as member of the raw type

I am getting the compiler warning: warning: [unchecked] unchecked call to setView(V) as a member of the raw type AbstractPresenter this.presenter.setView(this); where V is a type-variable: V extends AbstractView declared in class…
jcollin.be
  • 300
  • 1
  • 2
  • 6
16
votes
5 answers

What is the difference between checked and unchecked?

What is the difference between checked(a + b) and unchecked(a + b) ?
Difference Engine
  • 12,025
  • 5
  • 21
  • 11
15
votes
1 answer

Why does `Some(123).isInstanceOf[Option[List[String]]]` *not* give an unchecked warning?

When using .isInstanceOf[GenericType[SomeOtherType]], where GenericType and SomeOtherType are arbitrary types (of suitable kind), the Scala compiler gives an unchecked warning due to type erasure: scala>…
Mechanical snail
  • 29,755
  • 14
  • 88
  • 113
14
votes
1 answer

In what situations would I specify operation as unchecked?

For example: int value = Int32.MaxValue; unchecked { value += 1; } In what ways would this be useful? can you think of any?
MasterMastic
  • 20,711
  • 12
  • 68
  • 90
13
votes
5 answers

How to explicitly set checkbox unchecked

I have a xhtml page with transitional doctype having a checkbox that I want to be unchecked after loading. No JavaScript! In Firefox 3.5 (for instance, there may be other browsers) user can check input, than reload page and get input checked. How…
Oleg Kubrakov
  • 175
  • 1
  • 1
  • 10
12
votes
3 answers

Why should I explicitly surround with "unchecked"?

Is there anyone able to explain me this strange behavior? int i = 0x1234; byte b1 = (byte)i; byte b2 = (byte)0x1234; //error: const value '4660' can't convert to byte (use unchecked) byte b3 = unchecked((byte)0x1234); …
Mario Vernari
  • 6,649
  • 1
  • 32
  • 44
12
votes
3 answers

Suppressing Java unchecked warnings in JSP files

I have a legacy webapp which uses jstl and Struts 1 tags. When I pre-compile the JSP files with Java 5/6, the jstl and Struts 1 tags throw warnings about "unchecked or unsafe operations". For example, if I use the following tag: <%@ page…
Bob
  • 217
  • 4
  • 10
11
votes
4 answers

Java generics SuppressWarnings("unchecked") mystery

Why does code alternative(1) compile without warnings, and code alternative(2) produce an "unchecked cast" warning? Common for both: class Foo { Foo( T [] arg ) { } } Alternative (1): class Bar extends Foo { protected static…
Johannes Ernst
  • 3,072
  • 3
  • 42
  • 56
10
votes
3 answers

Why not simply disable unchecked warnings?

When developers interact with non-generic APIs, they usually run into "unchecked" warnings. Consider the following example: import java.util.AbstractList; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class IterableNodeList
Jens Bannmann
  • 4,845
  • 5
  • 49
  • 76
9
votes
4 answers

CheckBox gets unchecked on scroll in a custom listview

I know that this question has been asked over and over again but still I've not been a able to find a suggestion that really helps me. The checkbox is unchecked whenever the list is scrolled down. Yes I'm using a boolean array to store the values…
Dinesh
  • 181
  • 1
  • 3
  • 17
9
votes
2 answers

Weird result from unchecked(), possible compiler bug?

The following snippet evaluates to zero: int result = unchecked((int)double.MaxValue); Whereas, if you do this: double x = double.MaxValue int result = (int)x; The result is (would you even guess this?) int.MinValue. That fact alone is weird…
harold
  • 61,398
  • 6
  • 86
  • 164
9
votes
2 answers

Avoiding unchecked warnings when using Mockito

I'd like to mock a call on ScheduledExecutorService to return mock of ScheduledFuture class when method schedule is invoked. The following code compiles and works correctly: ScheduledExecutorService executor =…
Michal Kordas
  • 10,475
  • 7
  • 58
  • 103
9
votes
1 answer

jquery button to uncheck checkboxes

This task seemed to be very easy, though my code doesn't work. I have table with some rows, each row has a checkbox, underneath I put button "Remove all" to uncheck checkboxes. This is my code: $('#remove-button').click(function(){ …
kuba0506
  • 455
  • 2
  • 8
  • 20
1
2
3
16 17