Thread View: comp.sys.mac.programmer.codewarrior
5 messages
5 total messages
Started by Leon
Wed, 01 May 2002 20:16
CW7.2 and jnilib and C++ Exception woes
Author: Leon
Date: Wed, 01 May 2002 20:16
Date: Wed, 01 May 2002 20:16
47 lines
2650 bytes
2650 bytes
How come C++ exceptions do not work on MacOSX with a CW7.2 compiled
jnilib???
As a simple test, I modified the included HelloWorld JNI example, located in
the (Codewarrior Examples):CodeWarrior Java:Metrowerks Sample
Projects:Native examples:JNI example:Sources folder to create a JNILIB
(convert to Mach-O bundle target), and added the following method:
class A() {};
JNIEXPORT void JNICALL Java_com_mw_example_HelloWorld_throwMethod
(JNIEnv *env, jobject obj)
{
try
{
throw A();
}
catch (...)
{
printf("Caught!\n");
};
}
Of course, changes were also made in HelloWorld.java and TestHelloWorld.java
to reflect the new method.
The example works as it should calling each native function, but when it
calls throwMethod(), it crashes (segmentation fault). Upon further
inspection with GDB, it reported the following:
Program received signal EXC_BAD_ACCESS, Could not access memory.
ExPPC_FindExceptionRecord (returnaddr=0x15ac7b0 "H", info=0xbfffe88c) at
ExceptionPPC.cp:874
874 if ((returnaddr >= (char *) p->functionaddr)
What's going? Do I need to register my exception or something??
I've updated my Universal Headers and have recompiled all the MetroWerk
related projects (precompiled headers, MSL runtimes, MSL C++, etc...).
Could anyone verify that this indeed is a problem or is there something
wrong with my Mac...
--
Remove the underscores to reply to me.
l_e_o_n @ c_h_a_r_a_c_t_e_r_m_o_t_i_o_n . c_o_m
Re: CW7.2 and jnilib and C++ Exception woes
Author: Leon
Date: Wed, 01 May 2002 20:18
Date: Wed, 01 May 2002 20:18
6 lines
1345 bytes
1345 bytes
I forgot to say, C++ compiler and C++ Exceptions are enabled in the TargetSettings preferences panel. -- Remove the underscores to reply to me. l_e_o_n @ c_h_a_r_a_c_t_e_r_m_o_t_i_o_n . c_o_m
Re: CW7.2 and jnilib and C++ Exception woes
Author: Leon
Date: Mon, 06 May 2002 19:20
Date: Mon, 06 May 2002 19:20
61 lines
3300 bytes
3300 bytes
How did you initialize MSL in your MacOSX jnilib? -- Remove the underscores to reply to me. l_e_o_n @ c_h_a_r_a_c_t_e_r_m_o_t_i_o_n . c_o_m "Kent Brockman" <Kent.Brockman@channelsix.news> wrote in message news:3CD640DC.5040109@channelsix.news... > Leon, Ron, > > My CW Pro 6.2 cannot deal with mack-o. But I did a little work to see > how far I could get on MacOS X by using carbon. I first started with a > PPC library and I had to make the alterations as I described earlier to > intitiale MSL. Without the extra intialization the application would > crash. My test library succesfully catches the exception. It works with > the CW app and it works with JBindery. > > Creating a carbon version of the library was easy enough, but much to my > supprise does CW not provide a carbon version of their application that > runs my java classes. > > So I have a question too. Does CW Pro 8 provide a carbon version of the > application that makes my classes a clickable app? > > Eddy Walet > PTH > > NOTE Since the printf would create a > SIOUX window, that is starved from > events and thus freezing my app, > I did some extra work. I wrote a > function in C++ called "systemprintln". > It takes the same parameters as printf, > but writes to the java System.out > stream through the println method. > Just wanted to share this to show > how far you can get with JNI. > > Leon wrote: > > > Here is the HelloWorld example that I modified to demonstrate my problem. > > The project contains a target called HelloWorld_MACH that I added to produce > > libHelloWorld.jnilib for MacOSX. Perhaps I goofed on the settings, that's > > why it's causing exceptions to crash. > > > -- > ============================= > This mail-address is not valid. It is used to prevent my own address > from being harvested by a bot. > If you want to contact me you can use: > brockman-AT-xs4all-DOT-nl > Sorry for any inconvenience this may give. > Kent Brockman is not my real name. > ============================= >
Re: CW7.2 and jnilib and C++ Exception woes
Author: Kent Brockman
Date: Mon, 06 May 2002 20:27
Date: Mon, 06 May 2002 20:27
29 lines
2222 bytes
2222 bytes
The point I was trying to make: I did not. I have no carbon environment
for running java and I can not make a mach-o library with CW6.2, so all
I could do was building for PPC.
But the information you are looking for is in:
{COMPILER}:MacOS Support:Runtime:Runtime PPC:(sources):Startup.c
I use __initialize and __terminate in the functions that initialize and
terminate my library.
Eddy Walet
PTH
Leon wrote:
> How did you initialize MSL in your MacOSX jnilib?
>
>
--
=============================
This mail-address is not valid. It is used to prevent my own address
from being harvested by a bot.
If you want to contact me you can use:
brockman-AT-xs4all-DOT-nl
Sorry for any inconvenience this may give.
Kent Brockman is not my real name.
=============================
Re: CW7.2 and jnilib and C++ Exception woes
Author: Eric Albert
Date: Sat, 11 May 2002 19:11
Date: Sat, 11 May 2002 19:11
16 lines
1477 bytes
1477 bytes
In article <3CD6E728.3060008@channelsix.news>, Kent Brockman <Kent.Brockman@channelsix.news> wrote: > The point I was trying to make: I did not. I have no carbon environment > for running java and I can not make a mach-o library with CW6.2, so all > I could do was building for PPC. Java on Mac OS X can only use Mach-O libraries through JNI. You'll have to upgrade to CodeWarrior 7 (ideally 8, now) or use the command-line tools. -Eric -- Eric Albert ejalbert@stanford.edu http://www.stanford.edu/~ejalbert/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads