Compile Error?

AI discussion, ideas, and SDK help.
Post Reply
User avatar
SunTzu
Lux Cartographer
Posts: 1586
Joined: Sat Jan 14, 2006 1:48 am
Location: Maryland

Compile Error?

Post by SunTzu » Mon Jul 09, 2007 4:18 pm

When compiling my bot the following error shows up:
NetBeans IDE 5.5 wrote:Note: C:\Program Files\Lux\LuxSDK\src\com\sillysoft\lux\agent\Defender.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.
The build is still successful and the bot works in Lux, but I'm wondering if I should worry about this...

User avatar
Bertrand
Reaper Creator
Posts: 568
Joined: Mon Nov 28, 2005 4:35 pm
Location: Montreal

Post by Bertrand » Mon Jul 09, 2007 4:57 pm

Nah, don't worry about that. I get the same errors.

User avatar
dustin
Lux Creator
Lux Creator
Posts: 10998
Joined: Thu May 15, 2003 2:01 am
Location: Cascadia
Contact:

Post by dustin » Mon Jul 09, 2007 4:58 pm

It's a warning, not an error. I wouldn't worry about it.

User avatar
GregM
Luxer
Posts: 252
Joined: Wed Jun 01, 2005 4:33 pm

Post by GregM » Mon Jul 09, 2007 7:14 pm

I get that kind of stuff from using classes like Vector and List without specifying a type.

Do you know about generics in Java? If not, read below:

If you know C++, generics are Java's version of C++ templates.

It used to be that to use a Vector, you had to write nasty code like

Code: Select all

Vector neighbors = new Vector();
neighbors.add(c);
int code = ((Country)neighbors.get(i)).getCode();
As of Java 1.5 you can write that like this:

Code: Select all

Vector<Country> neighbors = new Vector<Country>();
neighbors.add(c);
int code = neighbors.get(i).getCode();
Basically the compiler will take care of the casting for you, as you specified that neighbors was of type "Vector<Country>" instead of just plain "Vector." If you use the latter, though, you will get that compiler warning because who knows what kind of object you have stored in the Vector and if it can be casted to a Country?

I suspect there's a way you can turn off the warning if it bothers you.

User avatar
dustin
Lux Creator
Lux Creator
Posts: 10998
Joined: Thu May 15, 2003 2:01 am
Location: Cascadia
Contact:

Post by dustin » Mon Jul 09, 2007 10:17 pm

My advice is to ignore generics. You don't need them for anything.

Post Reply

Who is online

Users browsing this forum: No registered users and 51 guests