System.NullReferenceException: Object reference not set to an instance of an object.

21 views
Skip to first unread message

Murali Manohar

unread,
Jun 15, 2021, 4:21:21 PMJun 15
to jni4net
Hi 

I have the below snippet in sample.proxygen.xml and upon execution of proxygen.exe  to generate jni4net jar and DLL for sample.jar getting error as shown here.

Tried by giving all the classes of sample.jar using <JavaClass> as below, still facing same error. 
  <JavaClass TypeName="com.sample.JavaClassName"/>
instead of 
   <ClassPath Path="..\sample.jar" Generate="true" />

Note: com.sample.JavaClassName is part of sample.jar

Please suggest if sample.proxygen.xml needs any corrections, as I am not sure whether the xml content is correct here. 
Error is not pointing out the specific java class in which the failure is. 
Please help in this regard. Thanks.

=======================================
sample.proxygen.xml
  <TargetDirJvm>target2\jvm</TargetDirJvm>
  <TargetDirClr>target2\clr</TargetDirClr>
<ClassPath Path="..\dom4j.jar"/>

        <ClassPath Path="..\sample.jar" Generate="true" />
</jni4net-proxygen>
=======================================
Error:
System.NullReferenceException: Object reference not set to an instance of an object.
   at net.sf.jni4net.proxygen.generator.CLRGenerator.CreateMethodSignature(CodeTypeDeclaration tgtType, GMethod method, Boolean isProxy, Boolean fieldSetter)
   at net.sf.jni4net.proxygen.generator.CLRGenerator.CreateMethodC2J(GMethod method, CodeTypeDeclaration tgtType, String uName, Boolean isProxy, Boolean fieldSetter)
   at net.sf.jni4net.proxygen.generator.CLRGenerator.CreateMethodC2J(GMethod method, CodeTypeDeclaration tgtType, String uName, Boolean isProxy)
   at net.sf.jni4net.proxygen.generator.CLRGenerator.GenerateStatic(CodeNamespace nameSpace)
   at net.sf.jni4net.proxygen.generator.CLRInterfaceGenerator.Generate(CodeNamespace nameSpace)
   at net.sf.jni4net.proxygen.generator.CLRGenerator.GenerateNamespace()
   at net.sf.jni4net.proxygen.generator.CLRGenerator.Generate()
   at net.sf.jni4net.proxygen.generator.Generator.GenerateAll()
   at net.sf.jni4net.proxygen.Program.Main(String[] args)

Regards,
Murali

Murali Manohar

unread,
Jun 21, 2021, 5:47:27 AMJun 21
to jni4net
Found it myself, issue occurs in one of the below condition

if the Interface contains any member fields
if the Class member fields are public
if the Enum is public

Note: if you are specifying java classes in proxygen xml, exclude the enum files.

Regards,
Murali
Reply all
Reply to author
Forward
0 new messages