For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

JNI viewer randomly crashes

dave bramall's picture
Forums: 

Problem:

When displaying a AIS_Shape, created via JNI, the viewer (also loaded via JNI) works for a short while then crashes with

the message,

javaw.exe Aplication error

The instruction at Ox???????? referenced memory at 0x????????. The memory could not be "read".

Debugging the error with Visual Studio gives

Unhandled exception in javaw.exe(JVM.DLL) 0x??????? Access violation

The shape is drawn and can be rotated, zoomed before crashing at what seems to be a random point (but especially when the viewer

window is resized). The Viewer does not crash when only the pre-defined shapes in the sample code (generated from

BRepPrimAPI_MakeBox etc) are loaded so it must be something I am doing wrong?

Has anyone else managed to use the JNI to display shapes or come across this problem? I have given the code below if anyone is

interested and can help.

Many thanks,

Code:

I am using JNI (based upon the JAVA samples for NT downloaded from the Open Cascade website) to create the 3D viewer and to display

a simple TopoDS_Shape created using MakePrism. The extra code which I have written to do this seems to be working OK i.e I think

that I have succesfully created an AIS_Shape (which is seen in the viewer for a short time) so I think the problem seems to be with

the viewer itself. I pass my AIS_Shape to the context (which is generated using exactly the same code as the sample viewer) calling

a JNI method 'Test';

on a button event -> { SampleViewer3DPackage.Test(myAISContext, new CAPABLETest().getAISShape()); } ... Picked up on the C++ side as; ... { // Get the C objects Handle(AIS_InteractiveContext) the_aContext = *((Handle(AIS_InteractiveContext)*) jcas_GetHandle(env,aContext)); Handle(AIS_Shape) the_aShape = *((Handle(AIS_Shape)*) jcas_GetHandle(env,aShape));

// Call the display method SampleViewer3DPackage::Test(the_aContext, the_aShape); } ...

The Test method actually does the following,

void SampleViewer3DPackage::Test(const Handle(AIS_InteractiveContext)& aContext, Handle(AIS_Shape)& aShape) { aContext->SetMaterial(aShape,Graphic3d_NOM_SILVER); aContext->SetDisplayMode(aShape,1); aContext->Display(aShape); }