Calling JNI wrapper methods using reflection, receiving java.lang.NegativeArraySizeException
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Michael_Garwood
Posted On:   Wednesday, December 24, 2003 10:49 AM

I have just taken my first dive into reflection with a project at work. I am calling a class that contains JNI wrapper methods through reflection. I am receiving the following exception: java.lang.NegativeArraySizeException at java.lang.reflect.Method.copy(Method.java:368) at java.lang.reflect.Constructor.getParameterTypes(Constructor.java:122) at java.lang.Class.getConstructor0(Class.java:1924) at java.lang.Class.newInstance0(Class.java:278) at java.lang.Class.newInstance(Class.java:261) at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381) at java.security.AccessController.doPrivileged(Native Method) at sun.reflect.   More>>

I have just taken my first dive into reflection with a project at work. I am calling a class that contains JNI wrapper methods through reflection. I am receiving the following exception:




java.lang.NegativeArraySizeException

at java.lang.reflect.Method.copy(Method.java:368)

at
java.lang.reflect.Constructor.getParameterTypes(Constructor.java:122)
at java.lang.Class.getConstructor0(Class.java:1924)
at java.lang.Class.newInstance0(Class.java:278)

at java.lang.Class.newInstance(Class.java:261)

at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
at java.security.AccessController.doPrivileged(Native Method)

at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
at sun.reflect.MethodAccessorGenerator.generateMethod(MethodAccessorGenerator.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:28)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.citistreet.tbo.nextgen.util.NativeLibInvoker.invoke(NativeLibInvoker.java:57)
at com.citistreet.tbo.nextgen.util.mapping.CPtr.setShort(CPtr.java:455)
at com.citistreet.tbo.nextgen.util.mapping.CMalloc.setShort(CMalloc.java:374)
at com.citistreet.tbo.nextgen.util.mapping.CStructMapper.toCStruct(CStructMapper.java:295)
at com.citistreet.tbo.nextgen.util.mapping.CStructMapper.toCStruct(CStructMapper.java:450)
at com.citistreet.tbo.nextgen.pensions.StartupPenCalc.initCLayer(StartupPenCalc.java:541)
at com.citistreet.tbo.nextgen.pensions.StartupPenCalc.main(StartupPenCalc.java:109)
at com.citistreet.tbo.nextgen.pensions.PenCalcStartupListener.contextInitialized(PenCalcStartupListener.java:42)
at weblogic.servlet.internal.WebAppServletContext$FireContextListenerAction.run(WebAppServletContext.java:6357)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)
at weblogic.servlet.internal.WebAppServletContext.notifyCreated(WebAppServletContext.java:1648)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3115)
at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:5559)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:853)
at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2012)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2053)
at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.activateContainer(SlaveDeployer.java:2558)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2483)
at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2308)
at weblogic.management.deploy.slave.SlaveDeployer$Task.checkAutoCommit(SlaveDeployer.java:2390)
at weblogic.management.deploy.slave.SlaveDeployer$Task.prepare(SlaveDeployer.java:2302)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2455)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:829)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:538)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:496)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)




Has anyone here ran into this problem before? If so please let me know what is going on here. If I did not provide enough information please let me know.




Regards,
Michael

   <<Less

Re: Calling JNI wrapper methods using reflection, receiving java.lang.NegativeArraySizeException

Posted By:   Michael_Garwood  
Posted On:   Friday, December 26, 2003 06:21 AM

Let me try to be a little more specific with my question.


The following JDK code throws an NegativeArraySizeException at the line Class[] out = new Class[l];:




static Class[] copy(Class[] in) {
int l = in.length;
if (l == 0)
return in;
Class[] out = new Class[l];
for (int i = 0; i < l; i++)
out[i] = in[i];
return out;
}



Can someone explain how it is possbile to create an array with a negative size?


Regargs,


Michael

About | Sitemap | Contact