Unexpected Null pointer exception on my legacy code

46 views
Skip to first unread message

Joshua Aroke

unread,
Jul 24, 2019, 9:32:00 PM7/24/19
to CodenameOne Discussions
Hi guys. 

I have an app i haven't updated since January 2018 and now I need to update some stuff on it but i started getting strange null pointer exception. I know a lot has change and may be hard for me to follow up change logs but was hoping to get an help real fast as the update is as sensitive to me. 

Please take a look at the stacktrace. 

/Users/olyjosh/Desktop/OneThousandBizIdea/src/userclasses/StateMachine.java:1268: warning: non-varargs call of varargs method with inexact argument type for last parameter;
            cmp.setModel(new com.codename1.ui.list.DefaultListModel(xxx));
  cast to Object for a varargs call
  cast to Object[] for a non-varargs call and to suppress this warning
Note: /Users/olyjosh/Desktop/OneThousandBizIdea/src/userclasses/StateMachine.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/olyjosh/Desktop/OneThousandBizIdea/src/userclasses/StateMachine.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 warnings
Compiling 1 source file to /Users/olyjosh/Desktop/OneThousandBizIdea/build/classes
warning: [options] bootstrap class path not set in conjunction with -source 1.5
warning: [options] source value 1.5 is obsolete and will be removed in a future release
warning: [options] target value 1.5 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
/Users/olyjosh/Desktop/OneThousandBizIdea/src/userclasses/StateMachine.java:1268: warning: non-varargs call of varargs method with inexact argument type for last parameter;
            cmp.setModel(new com.codename1.ui.list.DefaultListModel(xxx));
  cast to Object for a varargs call
  cast to Object[] for a non-varargs call and to suppress this warning
Note: /Users/olyjosh/Desktop/OneThousandBizIdea/src/userclasses/StateMachine.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/olyjosh/Desktop/OneThousandBizIdea/src/userclasses/StateMachine.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 warnings
compile:
run:
Retina Scale: 1.0
java.lang.NullPointerException
at com.codename1.ui.Display.getProperty(Display.java:3178)
at com.codename1.ui.util.UIBuilder.<init>(UIBuilder.java:233)
at generated.StateMachineBase.<init>(StateMachineBase.java:30)
at generated.StateMachineBase.<init>(StateMachineBase.java:118)
at userclasses.StateMachine.<init>(StateMachine.java:47)
at com.sunkanmivaughan.bizdir.BizDirFund.start(BizDirFund.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.codename1.impl.javase.Executor$3$1.run(Executor.java:256)
at com.codename1.ui.Display.processSerialCalls(Display.java:1298)
at com.codename1.ui.Display.mainEDTLoop(Display.java:1093)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Java Result: 1


If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Mac OS
Simulator

Shai Almog

unread,
Jul 24, 2019, 10:36:35 PM7/24/19
to CodenameOne Discussions
Hi,
are the project libraries up to date?
Try following the instructions here to make sure you aren't using out of date jars: https://www.codenameone.com/blog/tip-fix-issue-missing-builds.html

Joshua Aroke

unread,
Jul 28, 2019, 3:09:51 AM7/28/19
to CodenameOne Discussions
This doesn't work please 

Shai Almog

unread,
Jul 28, 2019, 10:17:13 PM7/28/19
to CodenameOne Discussions
Are the lines in the stack trace the same?
What's the size of JavaSE.jar in your project?
It should be 21,012,387.

Joshua Aroke

unread,
Jul 29, 2019, 11:37:56 AM7/29/19
to CodenameOne Discussions
Thanks you for your response Shai, Jar is of the same size as the one you indicated. Also it's the same trace

Shai Almog

unread,
Jul 30, 2019, 12:06:52 AM7/30/19
to CodenameOne Discussions
That doesn't make much sense, that line in Display is:
        return impl.getProperty(key, defaultValue);

Which means impl is null. That's the implementation of Codename One which is initialized before init(Object) is invoked. Since you invoke this from start() it should be well after init(Object) was initialized.

Joshua Aroke

unread,
Jul 30, 2019, 7:22:59 AM7/30/19
to codenameone...@googlegroups.com
I really don't understand this my self, is there a way I can send you this to look into. Meanwhile I will send screenshot of what my project is 

 

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/hy0euzCH0J0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/86f1ea29-0dc9-4888-9313-0fb20c4f9c7d%40googlegroups.com.


--
Joshua Aroke.

Information contained in this email and any attachments are confidential and intended solely for the use of the addressee only or otherwise directed in such applicable cases. Any dissemination, distribution, copying or use of this communication without prior permission from the addressee is strictly prohibited. If you are not the intended recipient of this communication, please delete permanently without copying, disclosing or otherwise using its contents and notify the sender immediately. Please note that any views or opinions presented in this email are solely those of the author. Joshua accepts no liability for any damage caused by any virus transmitted by this email. 
All My communications with you is rendered in accordance with the applicable conditions. Thank you for too kind. 

Shai Almog

unread,
Jul 30, 2019, 10:21:07 PM7/30/19
to CodenameOne Discussions
You can try to create an isolated test case to reproduce it and file an issue in the issue tracker. Just create a blank project and start adding things in from your existing project to reproduce it.
I'm guessing this won't happen because the issue is in the project itself.
So try the reverse, copy your project and then remove everything except for the code causing the issue then compare that to the blank project to see how they differ.

Joshua Aroke

unread,
Aug 2, 2019, 6:48:06 AM8/2/19
to codenameone...@googlegroups.com
So I tried to recreate the project but there was an issue. Same crashes but with different stacktrace. 

I tried to create the project using the same package name and the same name of Main class so as to make copying into it easier. But this is always crashing. 

If I use a different package name but with the same theme(Mapper theme and selecting Hello word Old GUI builder as the template). Then the hello world runs fine. But with my package name this error is happening.

See stacktrace below

Retina Scale: 1.0
java.lang.NullPointerException
at com.codename1.ui.Display.isSimulator(Display.java:4519)
at com.codename1.io.Log.bindCrashProtection(Log.java:604)
at com.thepackagename.bizdir.BizDirFund.init(BizDirFund.java:25)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.codename1.impl.javase.Executor$3$1.run(Executor.java:250)

at com.codename1.ui.Display.processSerialCalls(Display.java:1298)
at com.codename1.ui.Display.mainEDTLoop(Display.java:1093)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Java Result: 1
BUILD SUCCESSFUL (total time: 9 seconds)


Please take a look


--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/hy0euzCH0J0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.

Shai Almog

unread,
Aug 3, 2019, 12:44:18 AM8/3/19
to CodenameOne Discussions
This is the same crash effectively. The implementation is null.
I don't understand the change you did from the project creation onward. You say that creating the old GUI builder project works. What's your package name that causes the crash?
Reply all
Reply to author
Forward
0 new messages