Possible bug when loading dll through JNI

Hi guys,
I have come accross a strange occurance, if anyone can help me out i'd appreciate it lot.
I have written an unmanged (MFC) dll which connects to a managed(.NET) dll.
If I load the MFC dll without using any of the references to the managed dll everything is ok.
But as soon as I include a call to initialize a managed member my java program just exits. Then if i try and run it again it gives me a stack overflow exception.
The dll works absolutely 100% perfectly from other c++ applications (I've called all of its methods via a simple dos program), so it seems that there may be some protective layer that java is wrapping the dll in that isn't letting it make any managed calls.
Has anyone had this problem before or know how to get around it?
Below is the code from the unmanged (MFC) dll
     CNewDLLTestApp();
     void WriteToDevice(int Value);
     char ReadFromDevice();
        // this is the managed call, gcroot lets you call managed code from an unmanged area
     gcroot<JavaIntegrateManagedClass::Class1*>c;In the exposed java functions I initialize the class member c, and then call the regular dll functions.

Sadly that is the complete error message.
I've tried putting the load("DLL") in a try catch block but it never catches it. The debugger output screen just prints StackOverflowException.
The JNI calling code doens't even get invoked at this point.
* Class:     MainInterface
* Method:    WriteToDevice
* Signature: (I)V
JNIEXPORT void JNICALL Java_MainInterface_WriteToDevice
  (JNIEnv *, jobject, jint Value)
     MessageBox( (HWND)NULL,"In java function","Unmanged DLL",MB_OK);
     //theApp.c->WriteToDevice(Value);
}If I put the commented line back in the StackOverflowException occurs. If I leave it out everything is fine.
c is a class within a managed DLL, which in turn links to a managed class.
The layers may seem excessive but I understood it was needed to fool java into thinking it was calling unmanaged code.
What I don't understand is how a standard C++ console application can make the calls no problem, but Java can't. Surely the execution of the dll process should be exactly the same.
Thanks
DRB2k5

Similar Messages

  • Getting HeapDump on out of memory error when executing method through JNI

    I have a C++ code that executes a method inside the jvm through the JNI.
    I have a memory leak in my java code that results an out of memory error, this exception is caught in my C++ code and as a result the heap dump is not created on the disk.
    I am running the jvm with
    -XX:+HeapDumpOnOutOfMemoryError
    -XX:HeapDumpPath=C:\x.hprof
    Any suggestions?
    Thanks

    I'll rephrase it then.
    I have a java class named PbsExecuter and one static method in it ExecuteCommand.
    I am calling this method through JNI (using CallStaticObjectMethod). sometimes this method causes the jvm to throw OutOfMemoryError and I would like to get a heap dump on the disk when this happens in order to locate my memory leak.
    I've started the jvm with JNI_CreateJavaVM and I've put two options inside the JavaVMInitArgs that is used to create the Jvm. -XX:+HeapDumpOnOutOfMemoryError and -XX:HeapDumpPath=C:\x.hprof
    which supposed to create a heap dump on the disk when OutOfMemoryError occurs.
    Normally if I would execute normal java code, when this exception would occur and I wouldn't catch it the Jvm would crash and the heap dump would be created on the disk.
    Since I need to handle errors in my C++ code I am use ExceptionOccured() and extracts the exception message from the exception it self and write it.
    For some reason when I execute this method through JNI it doesn't create the dump.

  • Excessive memory consumption when loading Customers through Component Inter

    Hi All,
    I'm facing a big problem with the high memory consumption when loading Customers, Companies and Sites using the Component Interfaces delivered by the product (RD_CONSUMER_CI_API, RD_COMPANY_CI_API, RD_SITE_CI_API) within Application Engine programs. I'm loading about 7 million customers, an amount that is not so big in my opinion, but the memory consume is too high.
    We have 3 Batch Servers, each one running under Red Hat OS with 32 GB RAM memory plus 32 GB Swap memory in each server. We are running 2 Process by Server and with a day and half the servers crash with 100% of memory consumed (RAM and SWAP).
    There's a good pratice to use Component Interface in a heavy load process?
    There are parameters in the process scheduler configuration file that could help to reduce the memory consumption?
    There's a way to free the memory through PeopleCode or by running another process?
    Thanking you in advance.

    You may want to try and cut down on the input data to ascertain that the load might be a problem.
    You may try and use the GarbageCollector, but might not help in your case.
    To get an idea of the size allocated in buffer for the Rowset being used, you may want to check out the memory overhead ...
    Also, could check, which is the process that is consuming a lot of memory

  • Error 225 When Loading DLL Compiled on This Computer

    Brief background and intent: Building a small high-precision math library for use in a special-purpose scripting language under development
    Recently completed a revision of the 64-bit DLL library's assembly source to improve performance of existing 128-bit division routines. Now when I load the library from any executable I get Windows
    Error 225 (ERROR_VIRUS_INFECTED). Furthermore, Windows 7 is deleting the files
    without notice at every call to LoadLibrary at the path. I can rebuild the file, but I cannot copy it out of its project folder using Explorer because it somehow
    immediately deletes copies without warning (I kid not), though cmd copy works.
    At prior versions the file had previously loaded successfully when built from earlier source. Now I cannot even test the file as a DLL without removing the new code sections.
    I have of course scanned the file with Avast, and it checks out. Object and library even disassemble and show components as expected.
    So is Windows doing some manner of static analysis of my executable? If so, what patterns in my design might be causing the false positives? Admittedly, there's a bit of spaghetti within the 600 bytes that make up the new division section, but I've
    seen far more grievous sins load up just fine. I can provide [ugly] source if it's deemed useful.
    Relevant System Details:
    Operating System:
    Windows 7 Home Premium SP1, 64 bit
    Associated Tools:
    Assembler: NASM version 2.11.05
    Linker: LINK version 12.00.30501.0
    LINK command line:
    link /DLL /ENTRY:DllMain /OUT:BigTypes.dll BigTypes.obj
    ...Yes, I run very minimal when I've the option to do so.

    Before sending the issue to the development forum I performed some further investigation regarding what characteristics of a DLL will cause Windows 7 to refuse to load it due to a false positive on virus identification.
    Technical explanation: Any time routines share a common exit point that is not declared as 'export' for the purposes of the DLL, the Windows loader could raise the red flag if the jump crosses another exported label that the loader does
    not understand to be part of the the body of the routine. This would cause critical components of a program to fail to load, likely without notice to the user.
    Seems to be a well-intended but poorly-conceived security feature of the Windows 7 loader.
    Potential consequences: As evidenced by my example, Windows also deletes the suspect file - also completely bypassing the recycle bin, and without warning -
    so for most users the error would be unrecoverable even with a system restore.
    Conclusion: Not sure if this is a Windows 7-specific issue or if this is a 'feature' of all versions of Windows. Had I a 64-bit machine running any other OS version I would be happy to test it. This makes me wonder specifically if early
    64-bit Windows XP loaders would behave similarly; and if not, this could help explain why some users report anonymous failures of certain programs to load with Vista and upward, or even after some updates to XP.
    Once I have time to create a more formal report I plan on submitting it to whomever at Microsoft is best equipped to address or in the very least
    document the behavior so both end-users and developers alike are aware of why application components are failing.

  • Error when loading hierarchy through flat file

    Dear All,
    We are facing an issue during hierarchy upload through flat file.
    Below is the message :-
    Error 8 when compiling the upload program: row 658, message: A newer version of data type /BIC/B0000559000 was.
    Message no. RSAR233.
    Nothing else is being displayed.
    Request you to guide on this.
    Thanks & Regards,
    Anup

    Hi,
    I faced the same issue earlier.
    This is what i did. SE38-RS_TRANSTRU_ACTIVATE_ALL run the program and give your sourcesystem name this activates all the structure including new version /BIC structure what you have stated.
    After which you need to refresh the RSA1 Tcode and do the same process again to load the hierarchy.
    It should work fine now.
    Hope this helps.
    Regards,
    Harish
    Edited by: Harish3152 on May 18, 2010 2:23 PM
    Edited by: Harish3152 on May 18, 2010 2:32 PM

  • Data Load Error: When loading Hierarchy through a flat file

    Hi Bw experts,
    I am getting the error message:  Info object is not available: Message RSAR210, when trying to  load the Hierarchy through flat file upload with IDOC processing.The info object is active. I am getting this error message only for one hierarchy, other hierarchies for the same inof object are loaded successfully.Can some one help me in this?
    Thanks in Advance.
    Regards,
    Bala

    Hi Bala,
    Can you please share the solution asap..
    As we are also facing the same issue.
    Your quick response will be appreciated a lot
    Regards,
    Sai

  • How to solve these Errors when generating .dll (using JNI) ?

    Hello,
    I am very new about JNI. As I have been trying to generate my dll (sysHook.dll) as I followed this topic http://forums.sun.com/thread.jspa?threadID=632369 (by Jbgohlke ) by putting this command:
    cl -I"C:\Program Files\Java\jdk1.6.07\include" -I"C:\Program Files\Java\jdk1.6.07\include\win32" sysHook.cpp -FesysHook.dll Then many errors are popped up as follows:
    sysHook.obj :error LNK2019: unresolved external symbol __imp__CallNextHookEx@16 referenced in function "long__stdcall HookKeyboardProc(int,unsigned int,long)" (?HookKeyboardProc@@YGHIJ@Z)
    sysHook.obj :error LNK2019: unresolved external symbol __imp__SetWindowsHookExA@16 referenced in function " void__cdecl Init(void)" (?Init@@YAXXZ)
    sysHook.obj :error LNK2019: unresolved external symbol __imp__UnHookWindowsHookEx@4 referenced in function "void__Cleanup(void)" (?Cleanup@@YAXXZ)
    sysHook.dll : fatal error LNK1120: 3 unresolved externals
    If anyone of you know this PLEASE!! point me out!!
    [email protected]
    Thanks in advance

    Specify the appropriate library when linking.
    This is not a JNI question. It is a Windows/C/C++ programming question.
    Locking this thread.

  • Possible bug when creating multiple detail view objects

    using jdev 11.1.1.0.0 to build jsf/adf applications. I wanted to report what seems like a bug in 11g. I have a parent table which has two child tables. After creating the appropriate entities, associations, views, and view links, the app module looks like this:
    MasterView
    --DetailView1
    --DetailView2
    The two detail view objects are on the same level, they are both direct children of the Master view.
    Here's what's happening:
    1) I create the master entity/view objects (MasterView)
    2) I create one of the detail entity/view objects (DetailView1).
    3) I create the association and view link to establish relationship between MasterView and DetailView1. Everything works fine.
    4) I create the entity/view objects for second detail view (DetailView2)
    5) When I attempt to create a second view link (based off an association) to establish the relationship between MasterView and DetailView2, the query clauses of the Create View Link wizard (screens 4 and 5) do not get created properly. I finish the wizard and save. Not only does this view link not get created properly, but in the process the query clauses that were defined in the first view link between MasterView and DetailView1 are wiped out. This will break any coordination between master and detail views in both the app module tester and runtime. Has anyone seen this problem?

    fyi, it looks like this issue has been resolved with jdev 11.1.1.0.2 (Update 2)

  • Possible Bug When Binding Data to ContentPresenter ToolTip Attribute

    Hello everyone,
    I'm developing a small application using WPF. I have a custom ListBox control which contains a number of CheckBox entries paired up with a ContentPresenter object which displays some text obtained from a custom generic object.
    If I bind the ContentPresenter 'Content' node to one of the properties of my class, it will display the text I want correctly. However, I cannot do the same with its 'ToolTip' attribute.
    Here's an excerpt of my XAML.
    <Window.Resources>
    <local:SandboxProfiles x:Key="profiles"/>
    <DataTemplate x:Key="ListBoxItemTemplate">
    <!-- The ToolTip attribute doesn't accept dynamic data bindings (maybe a bug?) within the ContentPresenter node.
    Therefore, the attribute has to be inserted in the parent node (WrapPanel) for it to work. -->
    <WrapPanel ToolTip="{Binding Element.FriendlyDescription}">
    <CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center" />
    <ContentPresenter Content="{Binding Element.TypeString, Mode=OneTime}" Margin="2,0" />
    </WrapPanel>
    </DataTemplate>
    </Window.Resources>
    This line works absolutely fine like this,
    <ContentPresenter Content="{Binding Element.TypeString, Mode=OneTime}" Margin="2,0" />
    However, this doesn't work
    <ContentPresenter Content="{Binding Element.TypeString, Mode=OneTime}" ToolTip={Binding Element.TypeString} Margin="2,0" />
    Note I'm using the exact same pattern here, only that I'm applying it to the ToolTip attribute instead of Content. This doesn't work. It compiles, no exceptions, but no tooltip is displayed.
    However, if I bind the ToolTip attribute of the CheckBox node or the parent WrapPanel node in the exact same way, it
    does work. This works,
    <WrapPanel ToolTip="{Binding Element.TypeString}">
    And this works too,
    <CheckBox IsChecked="{Binding IsSelected}" ToolTip="{Binding Element.TypeString}" VerticalAlignment="Center" />
    I've searched the documentation and nowhere does it say I should expect ContentPresenter's 'ToolTip' attribute to behave differently than with any other XAML component.
    This has led me to believe this is a bug in the WPF runtime. If, on the other hand, I'm missing something here, please, do let me know.
    Thank you.

    Your problem is because you're putting  a tooltip on a contentpresenter - which isn't going to respond to mouse over unless you get your mouse over it just so.
    You can easily reproduce that if you throw a little markup in a new mainwindow:
    <Grid Name="myGrid">
    <ContentPresenter ToolTip="Banana"/>
    </Grid>
    Substitute TextBlock for contentpresenter
    <TextBlock Text="Whatever" ToolTip="Banana"/>
    And it works easily.
    <TextBlock Text="{Binding Element.TypeString, Mode=OneTime}" Margin="2,0" />
    Maybe I'm missing something but I can't really see why you have a contentpresenter at all.
    Assuming typestring is a string as it's name rather implies.
    Hope that helps.
    Recent Technet articles:
    Property List Editing ;  
    Dynamic XAML
    Substituting the ContentPresenter node for a simple TextBlock as you said worked for me, thank you.
    But Magnus is right in that you do have mouse-over events with ContentPresenter components; only that for some reason I don't know, they only work when the ToolTip attribute is set to a hardcoded string and no bindings are happening. So it does respond to
    the mouse but it doesn't display anything that has been dynamically bound to it, for some reason.

  • Possible bug when syncing between iCal & iPhone

    Am I doing something wrong. Here's the scenario.
    I have set up a continuous repeating appointment in iCal for my daughter
    Mon-Fri inclusive. 'School'
    I then went and changed selected events to 'Summer Holiday' where applicable, each time I changed a day it asked whether I wanted to change 'Just this event' or 'All future events'.
    I selected 'Just this event'.
    iCal worked fine and showed the new event on the correct days, but when I synced with the iPhone, the iPhone showed two events, the original repeating event and now the amended event as a new one. After the sync iCal still showed as correct
    It seems to be a flaw in the sync between the iPhone and iCal.
    Does this make sense?
    Can anyone else duplicate this scenario, or am I doing something wrong?
    What is the best way to report this to Apple as a sync bug, if it is one?
    cheers for listening to this waffle
    Paul

    Yes, I've experience the same problem. In addition, when I enter a calendar event in iCal it syncs to the iPhone. When I enter a calendar event in the iPhone it does NOT sync to iCal on my intel based macbook. I've followed the "iPhone Troubleshooting Assistant" to the end without fixing the problem.

  • Is it possible to call c# dll using JNI

    Using JNI we can invoke native code written in c or c++.
    Steps:
    1) All we have to do is write a class and have a method of type native.
    2) Invoke javah with -jni option to create a .h file.
    3) Include this header file and implement the method in c or c++ code.
    Now my question is:
    Is it possible to call I want to know whether we can implement the native method in c# instead of c or c++.
    Thanks

    No you can't, but you can have the JNI C/C++ code call C# code. How to do that is no longer a JNI question but a C# question.

  • Possible bugs when adjusting column width in Query Builder

    Good morning,
    we use Oracle SQL Developer 3.2.20.09 with included JDK on Windows 7 32 bit.
    When we open a sql file, in the Query Builder the criteria columns don't auto-adjust accordingly with the length of text present in the columns.
    Also, if we modify or type a new criteria in a column, and immediately after drag the column header to widen the cell, the cell content is erased (if we click first in another cell the problem doesn't occur).
    Thanks for reading and best regards.
    Marco - Italy

    Hi Marco,
    Please note that SQL Developer has included a Query Builder from a third-party since the 3.0 release. I will ping the developer that acts as liaison; perhaps you will get a more definitive response. I can only assume any UI bugs would have to be fixed by the third-party company at his request.
    Regards,
    Gary
    SQL Developer Team

  • Q: Possible bug when creating DB_LINKS

    One for Apex Development,
    I don't know if this is a bug but it looks a bit strange.
    I created a DB_LINK in APEX using SQL Workshop and it appears to work fine but the name of the db_link has the following domain amended upon creation.
    <DATABASE LINK NAME>.REGRESS.RDBMS.DEV.US.ORACLE.COM
    Is this correct or should I be able to specify the domain somewhere in the APEX setup ?
    My installation was ungraded from v2.0 to v2.2 if that might make a difference. I do not know if the situation was the same in v2.0
    Thanks in advance
    Chris

    I think that's a database version issue. When we upgraded our databases to 10gV2, we started getting that stuff appended to our db link names, whether we created db links in sql plus, Toad or Apex. Try putting double quotes (") around the database link at creation time and see if that doesn't solve the problem.

  • Possible bug when using Key Command

    Greetings,
    Can someone confirm this behavior in Logic 9? When I'm editing a plugin and hit my key command to go to a location, enter the measure # and hit enter - all **** breaks loose. It's as though I'm scrolling through a bunch of screensets and the enter location window still stays on top.
    Am I the only experiencing this? Misery sure does love company.
    Cheers

    fyi, it looks like this issue has been resolved with jdev 11.1.1.0.2 (Update 2)

  • Possible Bug when selecting the "text" tab on a Line Chart

    Thought I would pass this on.  Not sure if it has been logged yet or not.  Sometimes when building a line chart, the properties field locks up when I try and select the "text" tab.  The dialog boxes in the "text" tab do not show up and the "layout" tab is also highlighted.  I do not know what causes this, but it has happened to me numerous times.  The only solution is to totally delete the line chart and start all over.  It may be related to copying and pasting.  I set up a chart the way I need it and then copy/paste it rather than making all the changes on a default settings chart when I need another chart.
    Stan

    Hi Stan,
    Are you encountering this problem in the RTM version or SP1?
    Can you list the exact steps to reproduce this problem in the most simple case?
    Example:  add line chart, bind to data, copy, paste, click on text tab...............
    Thanks,
    Gerrit

Maybe you are looking for

  • Portions of my library are not showing up in itunes

    On my mac, only 1/5th of my library is visible in iTunes.  My entire library is available on my desktop PC. Match is on.

  • My hard drive crashed and I lost everything. How do I get all my itunes purchases restored?

    My hard drive carshed so Best Buy installed a new one. I had to reinstall all my apps including itunes. how do I get all the songs I've pirchased back?

  • Email adress refused by the server

    Sometimes my iPad is notava le to scende email and I have th message: email adress refused by the server; sometimes everything work an hour later or the day  after!

  • Question for a class

    Hey, I'm doing basic flash in a school class right now, and I have a question... ... there's a "vegetable term" used to describe following/seeing the motion path an object is taking. Do any of you know what it is?

  • INSTANCE MISSING IN SAPMMC

    Hi to all Please, help me with the following issue: I have two intsnces: 02 y 03, which one I view in SAPMMC. By a software installation, I have that restart the server, but, when I start the SAP services,.... surprise !!:  Don't appear my 03 instanc