Something funny happening

Hello folks!
I have this java program:
import java.*;
public class Try {
public String s;
public native String Initialize(String mess);
public native void WriteMessage();
public static void main(String[] args){
Try k = new Try();
k.s = "hello";
String m =k.Initialize(k.s);
System.out.println("m = "+m);
k.WriteMessage();
static{
System.loadLibrary("try");
and the native method is wrapper.c
#include <jni.h>
#include <stdio.h>
#include <iostream.h>
#include "Try.h"
#include "myclass.h"
static myclass *cl;
JNIEXPORT jstring JNICALL
Java_Try_Initialize(JNIEnv *env, jobject obj,jstring s){
// initialize C++ myclass
char message = (char )env->GetStringUTFChars(s,0);
cl = new myclass(message);
(env)->ReleaseStringUTFChars(s,message);
return s;
JNIEXPORT void JNICALL
Java_Try_WriteMessage(JNIEnv *env, jobject obj){
cl->Message();
which calls functions written in C++, myclass.cpp:
#include <string.h>
#include <iostream.h>
#include "myclass.h"
myclass::myclass( char *m ) {
cout << "Message on constructor: " << m << endl;
strcpy( message, m );
void myclass::Message() {
cout<<"you enter the Message method"<<endl;
cout << "Message: ";
cout << message << endl;
When I make the program run, everything works well, EXCEPT that it gives these answers:
Message on constructor: hello
m = hello
you enter the Message method
Message: helmo
Note that I should have hello instead of helmo. Identically, if the word is "bachi", I have this answer: bacii
For words longer than 8 letters, it runs into a VM crash!!!
I think it has something to do with the length of the Strings...
Any answer?
What can I do to correct this mistake?

1. Your C code looks goofy. It copies "message" onto itself.
2. You are misusing the booelan argument to getStringUTF. The argument should be a boolean that is filled in by the call. You should then be checking the boolean to determine whether or not to release memory.
3. You seem to be releasing memory that was - perhaps - allocated to hold the converted message - before you try to print it.

Similar Messages

  • Has something 'funny' happened?

    I ask because after someone else used my imac, I ran a 'Verify Disk Permissions' for safety...
    and got the following;
    Group differs on "private/var/root/Library/Preferences/.GlobalPreferences.plist", should be 0, group is 90.
    Permissions differ on "System/Library/CoreServices/RawCamera.bundle/Contents/CodeResources", should be -rw-r--r-- , they are lrwxr-xr-x .
    Group differs on "private/etc/cups", should be 0, group is 26.
    Permissions differ on "System/Library/PrivateFrameworks/iLifeMediaBrowser.framework/Versions/A/CodeRe sources", should be -rw-r--r-- , they are lrwxr-xr-x .
    Maybe I'm being paranoid, but the mention of the camera worries me.
    Anyway, I ran a 'Repair Disk Permissions' and hope it's ok.
    Anyone see anything there I should suspect? Or am I being unduly suspicious?

    chimes2 wrote:
    I ask because after someone else used my imac, I ran a 'Verify Disk Permissions' for safety...
    Running verify is useless. You should always run repair. If you get warnings or errors you will need to run repair anyway, so running verify is a waste of time.
    If you run repair twice, what are the messages you get after the first repair? Those are the onlhy ones that are important and even then, if they are the standard warnings, they are to be ignored until Apple fixes the bug. They are harmless but annoying little pests.

  • Something has happen my ipad air 2 it wont let me download or update any apps, when I press the button do update or download it looks like it is but it doesn't so if anyone knows what's going wind please help me

    Something has happen my ipad air 2 it wont let me download or update any apps, when I press the button do update or download it looks like it is but it doesn't so if anyone knows what's going wind please help me

    Do you have any restrictions for purchasing apps on the phone? Settings > General > Restrictions. If you have a Mac computer or another Apple device can you purchase things in the App Store using the same Apple ID on something else?

  • I bought the adobe photoshop elements 13 and adobe premiere elsements 13 in box in the store for my Mac;  I've entered my 25 character product key - now I have been waiting for nearly an hour for something to happen with no luck. Ron

    I bought the adobe photoshop elements 13 and adobe premiere elsements 13 in box in the store for my Mac; 
    I've entered my 25 character product key - now I have been waiting for nearly an hour for something to happen
    with no luck. Has anyone else had this problem?  I'm using MacBook Pro with Yosemite OS 10.10 etc. Help!
    Ron in Fort Worth, TX

    Also, Elements programs are not part of the Cloud
    Photoshop Elements Forum http://forums.adobe.com/community/photoshop_elements
    Premiere Elements Forum http://forums.adobe.com/community/premiere_elements

  • I recently had my iphone 4s screen repaired because the screen was cracked. It was all ok and then a few weeks later something strange happened. My touchscreen works, but the screen doesnt show, you can see the light in the background but no picture?

    I recently had my iphone 4s screen repaired because the screen was cracked. It was all ok and then a few weeks later something strange happened. My touchscreen works, but the screen doesnt show, you can see the light in the background but no picture? has anyone got any ideas as to what the problem is, is it self-repairable or even repairable at al?

    The LCD Display connector has partially come loose from the logic board connector, and simply needs to be pressed back down into place. Or the front screen assembly is now faulty, and needs to be replaced again.

  • Clicked on Send for a cmposed email but it was not sent and the symbol circling showed something was happening.

    I clicked on Send for an email I had composed. All that happened is that the rotating symbol showed that something was happening but the usual message that the email had been sent did not appear within about ten minutes. I have had this problem occur occasionally with Firefox on this computer and on another one. I have lost parts of a number of emails due to this problem as the version I tried to save had more in it than in the last saved version.

    The timing does make one think the two things are related, but it may not be so.  I've spent hours debugging problems thinking they were related to coincidental occurances, when they were not, so do not make assumptions.  If you are concerned, take the phone to an apple store to have it checked out.

  • Something weird happening in JSP

    Hi guys
    I have a JSP based app made out of frames.
    There is a left navigation frame and a main frame int he center.
    When I click on a link in the left , the page will be displayes correctly on the main frame . At this time I can see the status bar going all the way to the right in the browser.
    Then the status bar starts again from the beginning and it is not getting completed.
    Any idea??

    Thank you for taking the time to research this matter. I did delete the app and dowloaded again and presto! it cleared it up. Thanks again!
    Date: Fri, 18 May 2012 17:58:55 -0600
    From: [email protected]
    To: <Email address removed for privacy.>
    Subject: Re: Something Weird Happening...on Pantech Breakout - Re: Something Weird Happening...on Pantech Breakout
    Re: Something Weird Happening...on Pantech Breakout created by Verizon Wireless Customer Support in Android - View the full discussion
    Hi Leerod
    That is a very wierd issue. Let's see if we can get this fixed. Please try: Menu>settings> applications>manage applications> all> then clear data on all 3 applications and retest.
    Have you tried deleting the facebook and devotions application and downloading them again?
    I've researched the issue. It may have been a temporary issue with the application. Are you still experiencing problems with the foreign language? Please let me know if this fixes this issue.
    Thank you
    JoeL_VZW
    Please follow us on twitter @vzwsupport
    Reply to this message by replying to this email -or- go to the message on Verizon Wireless Community
    Start a new discussion in Android by email or at Verizon Wireless Community
    © 2011 Verizon Wireless
    Verizon Wireless | One Verizon Way | Mail Code: 180WVB | Basking Ridge, NJ 07920
    We respect your privacy. Please review our privacy policy for more information.
    Not interested in these emails anymore, or want to change how often they come? Update your email preferences.
    Message was edited by: Verizon Moderator

  • What is going on with Lion???? Something has happened to my Mac Pro since I got Lion! I cannot save documents in Word and as a consequence have lost files....God knows where they are!!! HELP!

    What is going on with Lion??? Something has happened to my Mac Pro since I got Lion!  I cannot save documents in Word, or at least if I do I have no idea where they are after I save then, Word does not know either! I have never seen this before? As a conseqience I have lost files despite saving them in the usual way......God knows where they are! In the middle of all this I am suddenly asked for my Mobile Me password,,,,,in Word??? What is going on? Help!

    Update to latest patched version that no longer relies on Rosetta and PowerPC
    Visit www.RoaringApps.com for a list and table of what version is supported, can be updated and which are not.
    A year ago this was news.
    Hopefully people kept a boot drive with the old OS so they could dual boot for a month or two whiile sorting out the changes and updates.

  • Yesterday, something weird happened to all my apps, please help!!

    Yesterday, something weird happened to all my apps on all my apple products, when I open the app store on my iPhone, iPad and my the Mac app store on my Mac, it says that all my apps are updated and it's a lie!! cause I have a lot of apps that need an update, I don't know why this is happening, please help!

    Okay all good we got into the layers - there was an non editable group/path/second layer. Clicked the circle next to that layer to select all, I was now able to click and edit my artwork but the colours were still stucj in a transparency and were at 100% tint & opacity - fixed that by copying and pasting in document. I dont know how, I dont know why but it worked and big thanks to my special friend for figuring it out and hleping me

  • Help! Something has happened in that my iCloud, find my iPhone is not opening up and I don't know how to fix it

    Help- something has happened in that mhy iCloud/find my iPhone is not opening up- all I see is a blue background and the whirling wheel...

    Hi asyl,
    That is strange. I use Firefox as well, and it is working fine for me....
    Cheers,
    GB

  • HT3702 Hello there. Im having problems purchasing items in a game I downloaded, I managed to top up the game before w/ my credit card, however something has happened and is no longer possible. Purchases at itunes are normal, however. Please help

    Hello there. Im having problems purchasing items in a game I just downloaded, I managed to top up the game before w/ my credit card, however something has happened and this is no longer possible. The tricky part is that Purchases at itunes are normal, since I just bought a tune...Please help

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • Image Processing Error "Something major happened"

    I am trying to Image Process a folder from RGB color space to SRGB color space. It wouldn't even start to run - a window popped up saying "Sorry, something major happened and I can't continue! Would you like to see more info?" WHen I say yes - another window pops up and reads: "Error: User cancelled the operation : 1548" I didn't cancel...please help!

    OK, that doesn't make much sense.
    Are you talking about the "Image Processor" script?
    Please also read http://www.adobeforums.com/webx/.2cd06cd9

  • All of a sudden firefox wants me to update from 3.6 to 6.something - what happened to 4 and 5? - and I don't know what google cupcakes are, but I don't think I want them - I like simple; help.

    All of a sudden firefox wants me to update from 3.6 to 6.something - what happened to 4 and 5? - and I don't know what google cupcakes are, but I don't think I want them - I like simple; help.

    Screen shot of my new tabs page. There used to be little boxes with fast ways to get to my most visited sites. Please help

  • "Hi,I need a help something wrong happen with my ITunes ,during to the download progress,after few seconds is report ; U can not download,err" in Using iPad • 0 bookmarks

    "Hi,I need a help something wrong happen with my ITunes ,during to the download progress,after few seconds is report ; U can not download,err"
    in Using iPad •

    It's better to post the URL of the feed (as you have subsequently done) than the contents of the feed .
    From the FeedValidator report the feed is basically OK for iTunes. There are several occasions where 'content:encoded' sections (following immediately on 'guid' tags) should be enclosed in
    <description>...</description>
    tags: however all this will be ignored by iTunes anyway and only applies to other readers. The 'potentially dangerous content' referred to by FeedValidator is within the 'content:encoded' tags and so isn't relevant to iTunes. They are referring to an inline css style, and I don't know whether this might cause a problem elsewhere.
    You should really have a language tag, e.g.
    <language>en-us</language>
    (you have a dc:language tag but that's for a different system). This should be placed in the top section, before the first 'item' tag.
    It's advisable to have an 'itunes:explicit' tag for each 'item' -
    <itunes:explicit>yes IF CONTAINS ADULT MATERIAL, OTHERWISE no</itunes:explicit>
    it's not compulsory if you have no adult material, but you must have a 'yes' if you do.
    You can check your feed by subscribing in iTunes from the 'Advanced' menu - this has the same result as clicking the 'Subscribe' button on the Store page. If it works OK there you are ready to submit it.

  • TV listings not loading. (Oops something unexpected happened) etc etc.

    I'm trying to find out what's wrong with the tv listings. Theses pages are loading way too slow or not loading at all. When you click on program info, I get the  "Oops something unexpected happened etc etc".This has been going on for over a week. I'm using Windows 7 and have all updates. Also I'm using the most recent Google Chrome. I have cookies enabled for Comcast/Xfinity. I use a ad block add on but this condition persist regardless of it's settings. I deleted all cookies, cleared the cache and started over on all that with no luck. There appears to be some spy ware associated with the listings page after I used "PageSpeed Insight" to look at the page. I saw reference to Facebook, some ad stuff, and some errors after the program analyzed the page, but I believe the problem is somewhere else. I would appreciate any help with this. I've seen others post similar problems with this tv schedule, but I have not seen much in a remedy besides, "use another listing service". I depend on this but it appears to be undependable. Thanks...jim  

        A technician did call today and he was sure, in a more than non cordial way, that the problems were on our end. He was also sure that Comcast could come out and load the grid on their laptop for 49.95 + tax, which may be true. While this guy was explaining how smart he was, he also explained that Comcast did not fix computers (again, in a more than uncongenial way)  You could tell that this tech did not want to be bothered on his day off, and I may try to contact corporate on that.  Anyway, I tried 3 of the top browsers...IE, Chrome, and Firefox, all with the same results. I also un-installed Flash Player and Java and re-installed those with no luck. In the end, I may have a technician come out to check my pc. The reason I doubt that the pc is the problem is that I just re-installed the operating system. Sunday night....Suddenly, everything is trying to load correctly. It may be a cookie issue. I just checked the option to allow 3rd party cookies (which I don't care to do) All the followers on this subject may try that. I'm going to try to fine tune the cookie thing for Comcast only. By the way...thanks to the very smart Comcast tech...for nothing.

Maybe you are looking for

  • Help !   SRM 4.0 - Was (dispatcher) doesn't start     =(

    Hi everyone, I'm trying to do a fresh install of SAP SRM 4.0 (Wintel, SQL), at this moment I'm installing the WAS.     The installation process was fine, but I'm having problems doing the post-processing activities (start / stop the server). Any clue

  • Blue Screen of Death Problem

    Hi, I have a Toshiba Satellite L455D-S5976 with Windows 7 Home Premium and a 32-bit operating system. I've been having problems with getting BSODs for well over a month now (I was out of town for most of it), sometimes within a couple minutes of rest

  • Can't connect to my wifi on iPhone 5

    I can't connect to my home wifi from either my iPad Air of my iphone 5. I have to manual assign a ip address, etc.  This just started last night.  No idea why?

  • VPD with single connection

    Hi, I have a, perhaps stupid, question about VPD. What if I'm in an environment with connection pooling etc., where all connections to the database are as a single application user, say 'scott'. Can I use vpd to limit row access based on what I put i

  • Live Effects Not Working

    I'm trying to record using my MacBook and Firepod, however the effects won't work while recording. They only can be heard during playback. I never had an issue with this in the past - it worked before. What could be the problem. Is there a setting th