unchecked

Type safety: Unchecked cast

In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String"> <entry key="some_key" value="some value" /> <entry key="some_key_2" value="some value" /> </util:map> In java class, the implementation looks like: priv...

What is SuppressWarnings ("unchecked") in Java?

Sometime when looking through code, I see many methods specify an annotation: @SuppressWarnings("unchecked") What does this mean? ...

How to implement generic type-safe deep cloning in a Java class hierarchy?

I have a base class, say Base which specifies the abstract method deepCopy, and a myriad of subclasses, say A, B, C, ... Z. How can I define deepCopy so that its signature is public X deepCopy() for each class X? Right, now, I have: abstract class Base { public abstract Base deepCopy(); } Unfortunately, that means that if if I have...

How to catch check/uncheck event of <input type="checkbox" /> with jQuery?

The title should be clear ...

How to catch a java unchecked/runtime exception (specifically SecurityException)

Hi all, I have java class with a method which gets an image from a website: private Image image; private int height; private int width; private String imageUri; public Image getImage() { if (image == null) { log.info("Fetching image: " + imageUri); try { URL iURL = new URL(imageUri); ImageIcon ii = new ImageIcon(iURL); i...

Java Collections.sort - help me remove the unchecked warning

List<Question> questions = new ArrayList<Question>(); questions.addAll(getAllQuestions()); //returns a set of Questions Collections.sort(questions, new BeanComparator("questionId")); //org.apache.commons.beanutils.BeanComparator Under Java 1.5, the above works fine except that the 'new BeanComparator("questionId")' generates an uncheck...

SPD workflow to reset check box

I have a sharepoint list that uses a cascading lookup to display items from another list in the first list. I need to reset the checkbox on the item in the lookup display box in the every week beginning with a date in the "Start Date" field. Is it possible to construct a workflow in SPD to reset the checkbox every 7 days from the "Start...

WPF RadioButton selected in UI, but seen by code as IsChecked == false

I have some radio buttons in a group box. I select the buttons randomly, and all works perfectly from a visual standpoint and also the event handler is called each time a new button is selected. Now I have a dependency property with a callback when the value changes. When in this callback procedure I read the IsChecked value of any butt...

How can i remove an unckecked cast warning in java ?

i have this piece of code: import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.NotBoundException; import java.rmi.Remote; import java.rmi.RemoteException; public class ClientLookup<T extends Remote> { private T sharedObject; public void lookup(String adress) throws MalformedURLException, RemoteException, N...

How to do this without unchecked?

Hello, 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 colors shouldn't be. { _EditControl.BackColor = System.Drawing.Color.FromArgb((...

C# - What could cause overflow checking here?

I am accustomed to C# not performing overflow checks, as the language spec states (§7.5.12): For non-constant expressions (expressions that are evaluated at run-time) that are not enclosed by any checked or unchecked operators or statements, the default overflow checking context is unchecked unless external factors (such as compiler ...

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 unchecked arithmetic, but I didn't find anything like that. I did find that expression trees h...

When is @uncheckedVariance needed in Scala, and why is it used in GenericTraversableTemplate?

@uncheckedVariance can be used to bridge the gap between Scala's declaration site variance annotations and Java's invariant generics. scala> import java.util.Comparator import java.util.Comparator scala> trait Foo[T] extends Comparator[T] defined trait Foo scala> trait Foo[-T] extends Comparator[T] <console>:5: error: contrav...

[Java] Type safety: Unchecked cast from Object

Hi, I try to cast an object to my Action class, but it results in a warning: Type safety: Unchecked cast from Object to Action<ClientInterface> Action<ClientInterface> action = null; try { Object o = c.newInstance(); if (o instanceof Action<?>) { action = (Action<ClientInterface>) o; } else { // TODO 2 Auto-generated catch bloc...

How do I make a checkbox in jQuery lock a existing sliding window from moving and then unlock it by unchecking the box?

I`m very new to jQuery but am starting to get the hang of it. My Question is: How do I make a checkbox in jQuery lock a existing sliding window function from moving and then unlock it by unchecking the box? So basically enable/disable a existing function in my project called - #navigate Any help would be greatly appreciated! ...

I can't find the cause of an "unchecked or unsafe operations" warning in Java.

Hello, as per the title I am struggling to find the cause of an "unchecked or unsafe operations" warning in some code. If I have the following code, it compiles without any warnings: public void test() { Set<String> mySet = new HashSet<String>(); Set<String> myNewSet = mySet; //do stuff } Now, if I change where mySet c...

Using generics to create max function that returns the larger one

In Java, how would I use generics to create a max function that takes as parameters two Comparable objects of the same type and returns the larger one? I tried: public static <T extends Comparable> T max(T obj1, T obj2) { return ( ((obj1).compareTo(obj2) >= 0) ? obj1 : obj2); } (It returns obj1 if they are both equal.) The metho...

unchecked warning on Class<Collection>

Suppose I have the following method, which can be used to create a collection of a given type specified. private static Collection<?> void create(Class<? extends Collection<?>> cls) { return cls.newInstance(); } This is all good if the cls argument is passed in during runtime: List<String> list = new LinkedList<String>(); create(...

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<String> handToolList = new ArrayList<String>( Arrays.asList(handToolArray)); if (handToolList.contains("pliers")){ System.out.prin...

What is the difference between checked and unchecked?

What is the difference between checked(a + b) and unchecked(a + b) ? ...