Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualwarnexus

Posted 13 September 2013 - 03:37 PM

I know why null pointer exception happens in Java. An object is not created which means it is a null object reference.

 

Problem is, I am facing an occasional case of the null pointer exception that is harder to track down because

sometimes the error happens which means I need to re-compile my game and it would work just fine after that.

Other times, the error just won't happen.

 

Luckily I encountered it again and can copy

and paste what the Eclipse IDE is saying:

Exception in thread "main" java.lang.NullPointerException
    at sun.java2d.SunGraphics2D.validateColor(Unknown Source)
    at sun.java2d.SunGraphics2D.<init>(Unknown Source)
    at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)
    at java.awt.image.VolatileImage.getGraphics(Unknown Source)
    at java.awt.Component$BltBufferStrategy.showSubRegion(Unknown Source)
    at java.awt.Component$BltBufferStrategy.show(Unknown Source)
    at com.nicholaskong.zelda.MainMenuCanvas.flipBuffer(MainMenuCanvas.java:217)
    at com.nicholaskong.zelda.MainMenuCanvas.run(MainMenuCanvas.java:199)
    at com.nicholaskong.zelda.Main.main(Main.java:31)

There are two cases when the error happens:

booting up the game to display the main menu and main menu transition to gameplay.

It happens roughly once or twice during the days I run the game to test new features.

 

Is my bufferstrategy object null at some point?

The 3 errors seems to point to the code below.

private void flipBuffer(Graphics2D g) {
        // TODO Auto-generated method stub
        g.dispose();
        // null object of bufferStrategy object perhaps? compiler thinks so.
        strategy.show();
    }

But my strategy has an object reference.

Canvas create two buffers: one is a front buffer and the other is a back buffer.

Strategy object gets the bufferStrategy object.

  createBufferStrategy(2);
  strategy = getBufferStrategy();


#5warnexus

Posted 13 September 2013 - 03:37 PM

I know why null pointer exception happens in Java. An object is not created which means it is a null object reference.

 

Problem is, I am facing an occassional case of the null pointer exception that is harder to track down because

sometimes the error happens which means I need to re-compile my game and it would work just fine after that.

Other times, the error just won't happen.

 

Luckily I encountered it again and can copy

and paste what the Eclipse IDE is saying:

Exception in thread "main" java.lang.NullPointerException
    at sun.java2d.SunGraphics2D.validateColor(Unknown Source)
    at sun.java2d.SunGraphics2D.<init>(Unknown Source)
    at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)
    at java.awt.image.VolatileImage.getGraphics(Unknown Source)
    at java.awt.Component$BltBufferStrategy.showSubRegion(Unknown Source)
    at java.awt.Component$BltBufferStrategy.show(Unknown Source)
    at com.nicholaskong.zelda.MainMenuCanvas.flipBuffer(MainMenuCanvas.java:217)
    at com.nicholaskong.zelda.MainMenuCanvas.run(MainMenuCanvas.java:199)
    at com.nicholaskong.zelda.Main.main(Main.java:31)

There are two cases when the error happens:

booting up the game to display the main menu and main menu transition to gameplay.

It happens roughly once or twice during the days I run the game to test new features.

 

Is my bufferstrategy object null at some point?

The 3 errors seems to point to the code below.

private void flipBuffer(Graphics2D g) {
        // TODO Auto-generated method stub
        g.dispose();
        // null object of bufferStrategy object perhaps? compiler thinks so.
        strategy.show();
    }

But my strategy has an object reference.

Canvas create two buffers: one is a front buffer and the other is a back buffer.

Strategy object gets the bufferStrategy object.

  createBufferStrategy(2);
  strategy = getBufferStrategy();


#4warnexus

Posted 13 September 2013 - 03:36 PM

I know why null pointer exception happens in Java. An object is not created which means it is a null object reference.

 

Problem is, I am facing an occassional case of the null pointer exception that is harder to track down because

sometimes the error happens which means I need to re-compile my game and it would work just fine after that.

Other times, the error just won't happen.

 

Luckily I encountered it again and can copy

and paste what the Eclipse IDE is saying:

Exception in thread "main" java.lang.NullPointerException
    at sun.java2d.SunGraphics2D.validateColor(Unknown Source)
    at sun.java2d.SunGraphics2D.<init>(Unknown Source)
    at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)
    at java.awt.image.VolatileImage.getGraphics(Unknown Source)
    at java.awt.Component$BltBufferStrategy.showSubRegion(Unknown Source)
    at java.awt.Component$BltBufferStrategy.show(Unknown Source)
    at com.nicholaskong.zelda.MainMenuCanvas.flipBuffer(MainMenuCanvas.java:217)
    at com.nicholaskong.zelda.MainMenuCanvas.run(MainMenuCanvas.java:199)
    at com.nicholaskong.zelda.Main.main(Main.java:31)

There are two cases when the error happens:

booting up the game to display the main menu and main menu transition to gameplay.

It happens roughly once or twice during the days I run the game to test new features.

 

Is my bufferstrategy object null at some point?

The 3 errors seems to point to the code below.

 

private void flipBuffer(Graphics2D g) {
        // TODO Auto-generated method stub
        g.dispose();
        // null object of bufferStrategy object perhaps? compiler thinks so.
        strategy.show();
    }

 

But my strategy has an object reference.

Canvas create two buffers: one is a front buffer and the other is a back buffer.

Strategy object gets the bufferStrategy object.

  createBufferStrategy(2);
  strategy = getBufferStrategy();


#3warnexus

Posted 13 September 2013 - 03:35 PM

I know why null pointer exception happens in Java. An object is not created which means it is a null object reference.

 

Problem is, I am facing an occassional case of the null pointer exception that is harder to track down because

sometimes the error happens which means I need to re-compile my game and it would work just fine after that.

Other times, the error just won't happen.

 

Luckily I encountered it again and can copy

and paste what the Eclipse IDE is saying:

Exception in thread "main" java.lang.NullPointerException
    at sun.java2d.SunGraphics2D.validateColor(Unknown Source)
    at sun.java2d.SunGraphics2D.<init>(Unknown Source)
    at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)
    at java.awt.image.VolatileImage.getGraphics(Unknown Source)
    at java.awt.Component$BltBufferStrategy.showSubRegion(Unknown Source)
    at java.awt.Component$BltBufferStrategy.show(Unknown Source)
    at com.nicholaskong.zelda.MainMenuCanvas.flipBuffer(MainMenuCanvas.java:217)
    at com.nicholaskong.zelda.MainMenuCanvas.run(MainMenuCanvas.java:199)
    at com.nicholaskong.zelda.Main.main(Main.java:31)

There are two cases when the error happens:

booting up the game to display the main menu and main menu transition to gameplay.

It happens roughly once or twice during the days I run the game to test new features.

 

Is my bufferstrategy object null at some point?

The 3 errors seems to point to the code below. But my strategy has an object reference.

Canvas create two buffers: one is a front buffer and the other is a back buffer.

Strategy object gets the bufferStrategy object.

  createBufferStrategy(2);
  strategy = getBufferStrategy();
private void flipBuffer(Graphics2D g) {
        // TODO Auto-generated method stub
        g.dispose();
        // null object of bufferStrategy object perhaps? compiler thinks so.
        strategy.show();
    }

#2warnexus

Posted 13 September 2013 - 03:34 PM

I know how null pointer exception happens in Java. An object is not created which means it is a null object reference.

 

Problem is, I am facing an occassional case of the null pointer exception that is harder to track down because

sometimes the error happens which means I need to re-compile my game and it would work just fine after that.

Other times, the error just won't happen.

 

Luckily I encountered it again and can copy

and paste what the Eclipse IDE is saying:

Exception in thread "main" java.lang.NullPointerException
    at sun.java2d.SunGraphics2D.validateColor(Unknown Source)
    at sun.java2d.SunGraphics2D.<init>(Unknown Source)
    at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)
    at java.awt.image.VolatileImage.getGraphics(Unknown Source)
    at java.awt.Component$BltBufferStrategy.showSubRegion(Unknown Source)
    at java.awt.Component$BltBufferStrategy.show(Unknown Source)
    at com.nicholaskong.zelda.MainMenuCanvas.flipBuffer(MainMenuCanvas.java:217)
    at com.nicholaskong.zelda.MainMenuCanvas.run(MainMenuCanvas.java:199)
    at com.nicholaskong.zelda.Main.main(Main.java:31)

There are two cases when the error happens:

booting up the game to display the main menu and main menu transition to gameplay.

It happens roughly once or twice during the days I run the game to test new features.

 

Is my bufferstrategy object null at some point?

The 3 errors seems to point to the code below. But my strategy has an object reference.

Canvas create two buffers: one is a front buffer and the other is a back buffer.

Strategy object gets the bufferStrategy object.

  createBufferStrategy(2);
  strategy = getBufferStrategy();
private void flipBuffer(Graphics2D g) {
        // TODO Auto-generated method stub
        g.dispose();
        // null object of bufferStrategy object perhaps? compiler thinks so.
        strategy.show();
    }

#1warnexus

Posted 13 September 2013 - 03:34 PM

I know how null pointer exception happen in Java. An object is not created which means it is a null object reference.

 

Problem is, I am facing an occassional case of the null pointer exception that is harder to track down because

sometimes the error happens which means I need to re-compile my game and it would work just fine after that.

Other times, the error just won't happen.

 

Luckily I encountered it again and can copy

and paste what the Eclipse IDE is saying:

 

Exception in thread "main" java.lang.NullPointerException
    at sun.java2d.SunGraphics2D.validateColor(Unknown Source)
    at sun.java2d.SunGraphics2D.<init>(Unknown Source)
    at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)
    at java.awt.image.VolatileImage.getGraphics(Unknown Source)
    at java.awt.Component$BltBufferStrategy.showSubRegion(Unknown Source)
    at java.awt.Component$BltBufferStrategy.show(Unknown Source)
    at com.nicholaskong.zelda.MainMenuCanvas.flipBuffer(MainMenuCanvas.java:217)
    at com.nicholaskong.zelda.MainMenuCanvas.run(MainMenuCanvas.java:199)
    at com.nicholaskong.zelda.Main.main(Main.java:31)

 

There are two cases when the error happens:

booting up the game to display the main menu and main menu transition to gameplay.

It happens roughly once or twice during the days I run the game to test new features.

 

Is my bufferstrategy object null at some point?

The 3 errors seems to point to the code below. But my strategy has an object reference.

Canvas create two buffers: one is a front buffer and the other is a back buffer.

Strategy object gets the bufferStrategy object.

 

  createBufferStrategy(2);
  strategy = getBufferStrategy();

 

private void flipBuffer(Graphics2D g) {
        // TODO Auto-generated method stub
        g.dispose();
        // null object of bufferStrategy object perhaps? compiler thinks so.
        strategy.show();
    }

 

 


PARTNERS