Captive Imagination
August 01, 2010, 12:01:36 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Check out the teaser site for the first official game by Captive Imagination: http://www.galaxiesbeyond.com
 
   Home   Help Search Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: workaround for NPE with SharedObjects with camel case method names  (Read 310 times)
0 Members and 1 Guest are viewing this topic.
Nicolas
Newbie
*
Offline Offline

Posts: 2


View Profile
« on: January 02, 2010, 11:11:46 AM »

It leads to a NullPointerException if shared objects use method names with camel case like 'getPlayerName' instead of 'getPlayername'. This seems to be due to a problem in the magic beans implementation. The updated method always receives the field name in lower case.

As I don't know how to fix this problem, here a work around (it seems to work):
Code:
Index: SharedObjectManager.java
===================================================================
--- SharedObjectManager.java (revision 1287)
+++ SharedObjectManager.java (working copy)
@@ -113,6 +113,7 @@
  (fld.substring(3,4).toLowerCase() + fld.substring(4)) :
  fld.substring(3,4).toLowerCase();
  Class retType = m.getReturnType();
+ fldName = fldName.toLowerCase();
  try {
  map.put(fldName, Converter.getConverter(retType));
  } catch (ConversionException ex) {

Logged
Tumaini
JGN Developer
Jr. Member
*****
Offline Offline

Posts: 51


View Profile
« Reply #1 on: January 08, 2010, 05:04:30 AM »

Again, thank you! Smiley
As I'm not updated on this subject, I'll leave it to someone else to look into right now and apply, or I'll have to get back to it when I get the time.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.163 seconds with 20 queries.