[vtkusers] Re: problems with VTK and Java / is vtk thread safe

Peter J. Carr pjc at hootenanny.org
Wed Jan 30 14:23:29 EST 2002


I solved my problem but am still open to answers to my questions.

My code looked like the following:

    class Test {
          public static void main(String args[]) {
              //load all of the vtk libraries
              System.loadLibrary("vtkCommonJava");


             // put a vtkPanel in a frame
             vtkPanel p = new vtkPanel();
             Frame f = new Frame();
             f.add(p);
             f.pack();
             f.show();
          }
    }

After  removing  the loadLibrary statements the program runs without 
crashing.
So the new question:
    Why would loading the library in my main program cause me to have 
problems interactive with the vtkPanel?

The answer isn't urgent since my code is now working.



Peter J. Carr wrote:

> I am having problems running vtk code from a java application on my 
> linux machine.
> I am still trying to identify the cause of the problem.
> The symptom is the java program crashes with the following message:
>
> An unexpected exception has been detected in native code outside the VM.
> Unexpected Signal : 11 occurred at PC=0x4ac5f197
> Function name=Azimuth__9vtkCamerad
> Library=/home/pcarr/Projects/vtk/VTK/lib/libvtkRendering.so
>
> Current Java thread:
>   at vtk.vtkCamera.Azimuth_23(Native Method)
>   at vtk.vtkCamera.Azimuth(vtkCamera.java:104)
>   at vtkPanel.mouseDragged(vtkPanel.java:178)
>   at java.awt.Component.processMouseMotionEvent(Component.java:3759)
>   at java.awt.Component.processEvent(Component.java:3548)
>   at java.awt.Component.dispatchEventImpl(Component.java:2593)
>   at java.awt.Component.dispatchEvent(Component.java:2497)
>   at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
>   at 
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131) 
>
>   at 
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98) 
>
>   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
>   at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
>
> I suspect it has something to do with X/Motif - Java - VTK threads. 
> But I am not sure how to narrow it down.
>
> Questions:
>   1. Has anyone else seen this type of error? How did you get around it?
>   2. How do I find out more about threads in X libraries, specifically 
> how do I make sure that threads are enabled when I start x.
>   3. Is vtk thread safe by default. I have noticed on some marginally 
> related news groups mention of the -D_REENTRANT flag being used during 
> compilation of C and C++ libraries. Is this something that is needed 
> to build the VTK Java shared libraries?
>   4. Is there something I need to do from my java application to 
> prevent this kind of bug?
>
> Thanks,
> Peter Carr
>
>
>
>
>
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>





More information about the vtkusers mailing list