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
9
votes
3 answers

Fastest way to do an unchecked integer addition in VB.Net?

I have a project where I want to have checked arithmetic by default, except for one performance sensitive spot. Unfortunately, VB.Net doesn't have an 'unchecked' block. Ideally the framework would have some sort of integer type with explicitly…
Craig Gidney
  • 17,763
  • 5
  • 68
  • 136
9
votes
6 answers

The local variable might not have been initialized - Detect unchecked exception throw within a method

I have some code with this structure: public void method() { Object o; try { o = new Object(); } catch (Exception e) { //Processing, several lines throw new Error(); //Our own unchecked exception } …
Luis Sep
  • 2,384
  • 5
  • 27
  • 33
8
votes
4 answers

Does using unchecked context hurt performance or portability in C#?

I want to implement a fast hash function that will use int datatype and rely on integer overflow. MSDN says that in order to guarantee that overflows don't trigger exceptions I have to use unchecked blocks for that code. Suppose I surround only that…
sharptooth
  • 167,383
  • 100
  • 513
  • 979
7
votes
1 answer

How to Improve Performance of C# Object Mapping Code

How can I further improve the performance of the code below while still maintaining the public interface: public interface IMapper { void Map(TSource source, TDestination destination); } public static TDestination…
Muhammad Rehan Saeed
  • 35,627
  • 39
  • 202
  • 311
7
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
  • 1,192
  • 14
  • 24
7
votes
5 answers

not able to unchecked the already checked radio button in dynamic radio group

If I set a radio button to be selected on the first time, it works fine. But if I unselect it by calling .setChecked(false); then, later even if I try to make it selected by calling setChecked(true) will not unselect the previous one. private…
sameer balouria
  • 470
  • 6
  • 20
7
votes
2 answers

How to suppress overflow-checking in PowerShell?

PowerShell seems to perform bounds-checking after arithmetic operations and conversions. For instance, the following operations fail: [byte]$a = 255 $a++ $a = [byte]256 Is there any way to enforce overflows or the typecast without resorting to a…
7
votes
5 answers

Convert -1 to uint C#

Converting -1 to uint will not work "((uint)(-1))" solution? num10 = ((uint)(-1)) >> (0x20 - num9); Error: Constant value '-1' cannot be converted to a 'uint' (use 'unchecked' syntax to override)
user2089096
  • 121
  • 1
  • 1
  • 2
7
votes
1 answer

Overloading the + operator so it is sensitive to being called in a checked or unchecked context

UPDATE: I've found the answer, which I will post in a couple of days if nobody else does. I am creating a numeric struct, so I am overloading the arithmetical operators. Here is an example for a struct that represents a 4-bit unsigned…
phoog
  • 42,068
  • 6
  • 79
  • 117
7
votes
1 answer

Good practices for Java exceptions handling

I have some questions regarding handling exceptions in Java. I read a bit about it and got some contradicting guidelines. Best Practices for Exception Handling Let's go through the mentioned article: It states that one should generally avoid using…
Michał Wróbel
  • 558
  • 1
  • 4
  • 13
6
votes
1 answer

System.OverflowException in unchecked block of C#

If I pass Int32.MinValue and -1 into the Divide() method, I get a System.OverflowException despite the block happening in an unchecked block. private static int Divide(int n, int d) { return unchecked (n / d); } This is…
will_w
  • 73
  • 6
6
votes
6 answers

Java unchecked/checked exception clarification

I've been reading about unchecked versus checked questions, none of the online resources have been truly clear about the difference and when to use both. From what I understand, both of them get thrown at runtime, both of them represent program…
donnyton
  • 5,874
  • 9
  • 42
  • 60
6
votes
2 answers

Dagger 2 unchecked warnings

In a project where I'm currently working on I've experienced some unchecked warnings related to Dagger 2. To exclude project related factors I've tried compiling the Dagger 2 examples provided on GitHub and they are also causing these unchecked…
Ben Groot
  • 5,040
  • 3
  • 40
  • 47
6
votes
1 answer

How do i get rid of these (unchecked call) warnings?

warning: [unchecked] unchecked call to setCellValueFactory(Callback,ObservableValue>) as a member of the raw type TableColumn column1.setCellValueFactory(new PropertyValueFactory("name")); where S,T are…
Markus Paul
  • 135
  • 1
  • 2
  • 7
6
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,808
  • 9
  • 59
  • 109
1 2
3
16 17