Bug 407944 - NullPointerException when invoking VJET->"Js2Java Code Generation" Context Menu Action
Summary: NullPointerException when invoking VJET->"Js2Java Code Generation" Context Me...
Status: UNCONFIRMED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: VJET (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Justin Early CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-13 16:16 EDT by Victor Rubezhny CLA
Modified: 2017-04-11 15:12 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Rubezhny CLA 2013-05-13 16:16:55 EDT
I'm getting an NPE while trying to invoke VJET->"Js2Java Code Generation" Context Menu Action:


!ENTRY org.eclipse.vjet.eclipse.javatojs.ui 4 0 2013-05-14 00:11:58.204
!MESSAGE 
!STACK 0
java.lang.NullPointerException
	at org.eclipse.vjet.eclipse.javatojs.ui.commands.Js2JavaGenerateJob$1.run(Js2JavaGenerateJob.java:83)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2327)
	at org.eclipse.vjet.eclipse.javatojs.ui.commands.Js2JavaGenerateJob.runInWorkspace(Js2JavaGenerateJob.java:125)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Comment 1 Justin Early CLA 2013-05-14 22:01:40 EDT
Can you provide example .js file you selected? What was selected when you selected Js to java? This command works with vjo.js types such as 

vjo.ctype('namespace.Foo')
.protos({
   //> public void doIt(String)
   doIt:function(a){}
})
.endType()
Comment 2 Victor Rubezhny CLA 2013-05-15 05:20:49 EDT
The project itself was selected, not a specific js-file. It is a dependency problem was the reason of org.eclipse.vjet.eclipse.javatojs.core plug-in wasn't activated. 

In this case, org.eclipse.vjet.eclipse.javatojs.ui.commands.Js2JavaGenerateJob.getGenerator() method returns null (and this method is intended to return null if it cannot find a Generator for any reason), but there is no a check for null for a generator (lines after #82 in org.eclipse.vjet.eclipse.javatojs.ui.commands.Js2JavaGenerateJob.runInWorkspace().

IMHO, the check for null should be added there after, and a suitable message is to be logged in case of getGenerator() returned null.

Also, the method org.eclipse.vjet.eclipse.javatojs.ui.commands.ClassloaderUtils.createClassLoader(ClassLoaderKey) hides exceptions inside try-catch and doesn't reports them into a log. IMHO, it's not a good practice, since it makes difficult to find a real reason of not getting the generator object.