fredsa / playn

Cross platform game library for N≥4 platforms
0 stars 1 forks source link

PlayN version 1.4 doesn't call JavaStorage.init() on JavaPlatform.register() #188

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
JavaPlatform.register();
PlayN.storage().getItem("foo");
// In PlayN 1.3, this worked fine.
// In PlayN 1.4, You will get Null Pointer Exception (NPE).
Exception in thread "main" java.lang.NullPointerException
    at playn.java.JavaStorage.getItem(JavaStorage.java:55)

NPE is caused because properties is not yet initialized (and is null) in 
JavaStorage. It is null because JavaStorage.init() never got called.

Original issue reported on code.google.com by in...@trymph.com on 13 Jul 2012 at 12:26

GoogleCodeExporter commented 9 years ago
It seems like JavaStorage.init() is only called in JavaPlatform.run(Game).
However, this means we can not preconfigure Game with anything from storage.

Original comment by in...@trymph.com on 13 Jul 2012 at 12:28

GoogleCodeExporter commented 9 years ago
Why would you not do your configuration in Game.init?

Original comment by m...@samskivert.com on 13 Jul 2012 at 8:31

GoogleCodeExporter commented 9 years ago
I guess it could be done there. However, I was looking to keep my fields as 
final so was doing the initialization in a constructor.

Feel free to close this bug.

Original comment by inder123 on 13 Jul 2012 at 8:47

GoogleCodeExporter commented 9 years ago
I definitely appreciate the desire to make fields final. I'm a little worried 
about promising that all platforms will be able to service Storage requests 
before the game has been initialized, but I don't suppose that's a huge burden. 
I'll look into why I changed the behavior.

Original comment by m...@samskivert.com on 13 Jul 2012 at 8:50

GoogleCodeExporter commented 9 years ago
It was related to being sure logging was initialized. I went ahead and fixed 
things up so that JavaStorage is once again available immediately after 
JavaPlatform.register(). That'll go out in a 1.4.1 release (as soon as I figure 
out what the Android freakoutery is all about).

Original comment by m...@samskivert.com on 13 Jul 2012 at 8:58

GoogleCodeExporter commented 9 years ago
Perfect! Thanks.

Original comment by inder123 on 13 Jul 2012 at 9:07