
-----------------------------------
gsquare567
Sat Dec 02, 2006 10:59 pm

Weird xlint error with my linkedlist adding method
-----------------------------------
check this:

GalacticWar.java:975: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);

where getSprites() returns a LinkedList of type AnimatedSprite, and bullets
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\Asteroids\classes>javac
-Xlint GalacticWar.java
GalacticWar.java:157: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                getSprites().add(ship);
                                ^
GalacticWar.java:555: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                getSprites().add(ship);
                                ^
GalacticWar.java:599: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                getSprites().add(asteroid);
                                ^
GalacticWar.java:691: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                getSprites().add(asteroid);
                                ^
GalacticWar.java:708: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                getSprites().add(expl);
                                ^
GalacticWar.java:725: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                getSprites().add(expl);
                                ^
GalacticWar.java:792: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(powerup);
                                                ^
GalacticWar.java:799: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(powerup);
                                                ^
GalacticWar.java:806: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(powerup);
                                                ^
GalacticWar.java:813: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(powerup);
                                                ^
GalacticWar.java:820: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(powerup);
                                                ^
GalacticWar.java:827: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(powerup);
                                                ^
GalacticWar.java:920: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:926: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:930: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[1]);
                                                ^
GalacticWar.java:936: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:939: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[2]);
                                                ^
GalacticWar.java:943: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[2]);
                                                ^
GalacticWar.java:949: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:953: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[1]);
                                                ^
GalacticWar.java:957: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[2]);
                                                ^
GalacticWar.java:961: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[3]);
                                                ^
GalacticWar.java:967: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:971: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:975: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:979: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:983: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:987: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
                                getSprites().add(bullets[0]);
                                                ^
GalacticWar.java:8: warning: [serial] serializable class GalacticWar has no defi
nition of serialVersionUID
public class GalacticWar extends Game
       ^
29 warnings


-----------------------------------
wtd
Sat Dec 02, 2006 11:51 pm


-----------------------------------
Of you're using Java 1.5 and collections, you'll need to be familiar with generics.

-----------------------------------
gsquare567
Sat Dec 02, 2006 11:57 pm


-----------------------------------
thanks for the help... now can anyone tell me why these are coming up?

-----------------------------------
OneOffDriveByPoster
Sun Dec 03, 2006 12:29 am


-----------------------------------
thanks for the help... now can anyone tell me why these are coming up?
Check your method signature for getSprites().  wtd is right, get used to generics if you are using Java 1.5.

-----------------------------------
wtd
Sun Dec 03, 2006 9:34 am


-----------------------------------
We know of what we speak.

import java.util.ArrayList;

public class Foo {
   public static void main(String[] args) {
      ArrayList arr = new ArrayList();
	  int i = 5;
	  
	  arr.add(i);
   }
}

$ javac -Xlint:unchecked Foo.java
Foo.java:8: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
          arr.add(i);
                 ^
1 warning

import java.util.ArrayList;

public class Foo {
   public static void main(String[] args) {
      ArrayList arr = new ArrayList();
	  int i = 5;
	  
	  arr.add(i);
   }
}

$ javac -Xlint:unchecked Foo.java
$

-----------------------------------
gsquare567
Sun Dec 03, 2006 2:34 pm


-----------------------------------
thanks, but it still doesn't work... heres how i declare the LinkedList:

private LinkedList sprites;
sprites = new LinkedList();

and heres how i call it:

public LinkedList getSprites()
	{
		return sprites;
	}

i still get the same message, and can you also look at the very last error, something about serialVersionUID?

-----------------------------------
OneOffDriveByPoster
Sun Dec 03, 2006 4:30 pm


-----------------------------------
Check the method signature; what is different from your declaration of sprites?  Your code below:
private LinkedList sprites;
public LinkedList getSprites() { /* ... */ }

Re:  serialVersionUID:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html

-----------------------------------
gsquare567
Sun Dec 03, 2006 6:32 pm


-----------------------------------
OH NO WAY MAN U R GOD! public LinkedList getSprites()... your a genious!

-----------------------------------
gsquare567
Sun Dec 03, 2006 6:56 pm


-----------------------------------
umm hmm... got rid of the "recompile with -Xlint", but now wen i run the internet file, the applet wont work. says "Loading Java Applet Failed"... i did everything required to run an applet, so why isnt it working?

-----------------------------------
gsquare567
Mon Dec 04, 2006 1:19 pm


-----------------------------------
any1?

-----------------------------------
wtd
Mon Dec 04, 2006 1:22 pm


-----------------------------------
Which browser are you using?

-----------------------------------
gsquare567
Mon Dec 04, 2006 6:37 pm


-----------------------------------
firefox, but it worked b4 for 2 other games. i even copied the htm file for the other two and just renamed it + the "code = " parameter

-----------------------------------
gsquare567
Mon Dec 04, 2006 10:07 pm


-----------------------------------
heres another problem, might be connected... i cant make a jar file. heres the error message:

C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\Asteroids\src\Version 3>
jar cvfm GalacticWar3.jar manifest.txt *.*
java.io.IOException: invalid header field
        at java.util.jar.Attributes.read(Attributes.java:389)
        at java.util.jar.Manifest.read(Manifest.java:167)
        at java.util.jar.Manifest.(Manifest.java:52)
        at sun.tools.jar.Main.run(Main.java:123)
        at sun.tools.jar.Main.main(Main.java:903)

ps, i include a manifest called manifest.txt plus all the classes needed. the manifest is 3 lines, Main-Class: GalacticWar + 2 blank lines :D

-----------------------------------
Aziz
Tue Dec 05, 2006 9:10 am


-----------------------------------
using generics would cause that problem, try and step back a few steps in your code (ie. undo a bit, then add in the  bit). Also, make sure your browser has an up-to-date JRE plug-in installed. The latest is 6 (or 1.6) but that's a prerelease, so 5 (update 9) should be fine

-----------------------------------
gsquare567
Tue Dec 05, 2006 3:49 pm


-----------------------------------
i based my entire game on the LinkedList which is where i store the sprites or objects on the screen... so i'll try downloading the latest plugin and update, i'll get back to you to tell you if it still doesnt work.

-----------------------------------
gsquare567
Tue Dec 05, 2006 4:03 pm


-----------------------------------
nope, didnt work. still says "Applet GalacticWar notinited". i dled the jdk 5 update 10...

-----------------------------------
gsquare567
Wed Dec 06, 2006 7:16 pm


-----------------------------------
BUMP...
and, added a lil info if it helps you solve this complex error :D.

ok. i re-dled the whole jse and got update 10. heres the shiz lol:

HTML CODE



Galactic War - enhanced by Gsquare567








FIRST LINES OF MAIN JAVA CODE

public class GalacticWar extends Game


abstract class Game extends Applet implements Runnable, KeyListener


MANIFEST FILE CODE

Main-Class: GalacticWar



PS thanks a lot for helping me man. if you actually solve this problem... well... iunno i'll thank you. :?

-----------------------------------
gsquare567
Thu Dec 07, 2006 8:06 pm


-----------------------------------
whats with this wtd hasnt responded on the hour! is he sick or sumtin?

-----------------------------------
gsquare567
Sun Dec 10, 2006 2:32 pm


-----------------------------------
anyone???

-----------------------------------
gsquare567
Wed Dec 13, 2006 9:57 pm


-----------------------------------
ok, this is REALLY buggin me, so im just taking random guesses, hoping someone can help. so it says applet notinited, i thought, well maybe its the init method. well, here it is, i checked EVERYTHING i could, but there is something missing/incorrect. help! please!
public void init()
	{
		backBuffer = new BufferedImage(screenWidth, screenHeight, BufferedImage.TYPE_INT_RGB);
		g2d = backBuffer.createGraphics();

		sprites = new LinkedList();

		addKeyListener(this);

		gameStartup();// implemented by subclass
	}
and here is the method implemented by the subclass.
void gameStartup()
	{
		// load sounds and music
		music.load("music.midi");
		shoot.load("shoot.au");
		explosion.load("explode.au");

		// load the health/shield bars
		barFrame = new ImageEntity(this);
		barFrame.load("barframe.png");
		barImage[0] = new ImageEntity(this);
		barImage[0].load("bar_health.png");
		barImage[1] = new ImageEntity(this);
		barImage[1].load("bar_shield.png");

		// load powerups
		powerupShield = new ImageEntity(this);
		powerupShield.load("powerup_shield2.png");
		powerupHealth = new ImageEntity(this);
		powerupHealth.load("powerup_cola.png");
		powerup250 = new ImageEntity(this);
		powerup250.load("powerup_250.png");
		powerup500 = new ImageEntity(this);
		powerup500.load("powerup_500.png");
		powerup1000 = new ImageEntity(this);
		powerup1000.load("powerup_1000.png");
		powerupGun = new ImageEntity(this);
		powerupGun.load("powerup_gun.png");

		// load the background
		background = new ImageEntity(this);
		background.load("bluespace.png");

		// create the ship
		shipImage[0] = new ImageEntity(this);
		shipImage[0].load("spaceship.png");
		shipImage[1] = new ImageEntity(this);
		shipImage[1].load("ship_thrust.png");
		shipImage[2] = new ImageEntity(this);
		shipImage[2].load("ship_shield.png");

		AnimatedSprite ship = new AnimatedSprite(this, getGraphics());
		ship.setSpriteType(SPRITE_SHIP);
		ship.setImage(shipImage[0].getImage());
		ship.setFrameWidth(ship.getImageWidth());
		ship.setFrameHeight(ship.getImageHeight());
		ship.setPosition(new Point2D(SCREENWIDTH/2, SCREENWIDTH/2));
		ship.setAlive(true);
		ship.setState(STATE_EXPLODING);

		collisionTimer = System.currentTimeMillis();
		addToSprites(ship);

		// load the bullet
		bulletImage = new ImageEntity(this);
		bulletImage.load("plasmashot.png");

		// load the explosion
		explosions[0] = new ImageEntity(this);
		explosions[0].load("explosion.png");
		explosions[1] = new ImageEntity(this);
		explosions[1].load("explosion2.png");

		// load the asteroids
		for(int i = 0; i < 5; i++)
		{
			bigAsteroids[i] = new ImageEntity(this);
			bigAsteroids[i].load("asteroid" + (i+1) + ".png");
		}
		for(int i = 0; i < 2; i++)
		{
			medAsteroids[i] = new ImageEntity(this);
			medAsteroids[i].load("medium" + (i+1) + ".png");
		}
		for(int i = 0; i < 3; i++)
		{
			smlAsteroids[i] = new ImageEntity(this);
			smlAsteroids[i].load("small" + (i+1) + ".png");
		}
		for(int i = 0; i < 4; i++)
		{
			tnyAsteroids[i] = new ImageEntity(this);
			tnyAsteroids[i].load("tiny" + (i+1) + ".png");
		}

		// start in pause mode
		pauseGame();
	}

i checked that all files were written correctly, although i wasnt sure if a MIDI file's extension was mid or midi so i tried both, and neither worked, so i assume it doesnt matter. also, the au extension is for an AU file, and png is for PNG... so i know those are correct.
what could be the problem? just throw things PLEASE!

-----------------------------------
Neville
Wed Dec 13, 2006 11:40 pm


-----------------------------------
I would start by debugging as much as you can. Do you use an IDE with built in debugging? This way you could step through and see where it is failing. If not, try writing an output file with little messages to see how far along your init() goes before it fails. That way you can narrow down the problem. It's most likely an exception being thrown somewhere.
