i have a method something like this in my code (java).
public void DoSomeStuff() {
Log.i(TAG,"1");
Log.i(TAG,"2");
Log.i(TAG,"3");
}
This is called from C++ through JNI. I'm 100% sure the JNI works and has nothing to do with my problem.The problem is: Only the first line of the code runs (the output is "1"), and the rest gets ignored. It doesn't matter what i write in the first line... only that gets executed.There aren't any error messages, freezes, or any relevant information to help in debugging.I have also tried to clear the bin/gen folders but no success.The worst part is that, sometimes it works... and sometimes it doesn't.
Thanks
you could post the code for i method, maybe there is something within its body that is causing this behaviour?
Have you tried calling different methods? Not neccessarly from Log?
Good luck.
Related
I want to write a program that counts the lines of code being executed when
a test, lets say TestA(), runs. More importantly, I need to store the
lines of code being executed
by TestA(), into a codeLines: String.
I find this concept really bizarre and so far, I did not have any luck with
online resources. Do you know of any way that such functionality could be achieved?
From what I understand of the question, it seems like the closest functionality that you can easily attain is by using a debugger, which lets you step through lines, step into lines, and see what line is doing what in the code.
Expectedly, this SystemClock.sleep(paramMaybeNegative) is being used in a multi-threaded context, if that is relevant. The negative would come from an uninitialized object property in some yet unforseen circumstance.
Here is the documentation regarding what I am asking about:
developer.android.com:SystemClock.sleep(long). It doesn't mention an exception or forever or something else that might be expected.
Putting this question here to remember to answer it later and handle the consequences in some code I am writing, as much as in hopes someone knows what to expect already and wants to type about it before I get to (super-informative and helpfully interesting factoids about SystemClocks also welcome:).
It calls Thread.sleep(millis) which throws an IllegalArgumentException.
You can find out by reading the src code, or by trying out.
From reading and guessing at source code running in emulator I would expect it to not throw error and act like a SystemClock.sleep(0); it throws to logcat and crashes app:
java.lang.IllegalArgumentException: timeout arguments out of range
at java.lang.VMThread.sleep(Native Method)
...
...
...
I am as likely as not looking at wrong source file.
so, I've written programs using ifstream in the past, successfully. yet this time, I can't seem to correct this "cannot read characters from string" error shown in the image. I basically declare ifstream inputFileStream in the class header, then try stating inputFileStream("text.txt"); and I already have that given error in the debugger.
More specifically, I construct an instance of the given class in the main method, and call (from the main method,) the public method which contains the statement inputFileStream("text.txt");.
I've made sure that the given text file is actually in the same folder as the project. Anybody familiar with this error?
I looked up the cccccccc error code and it has to do with an uninitialized stack something, but why would that be relevant to this?
The closest post to this was here, but im still trying to decipher the problem How to end up with a pointer to 0xCCCCCCCC
so, I got it working. I'm using visual studio 2013. all I had to do was copy the code into a new project, and compile it there. no idea why this worked as such
Im using Java (JNA) to use a function in a third party .dll file. The functions I'm calling are returing the integer value 1.
After reading, I've discovered that this return value is traditionally 0 if everything runs correctly.
Was wondering if this is always the case or if theres any way to determine what it should be?
In the .h file bundled with the .dll it has the comment
// rc: EXIT_SUCCESS means NO ERROR
After the function.
Check actual dll documentation, there should be the way to tell what's wrong.
If nothing helps try calling GetLastError() WinAPI - some meaningful error code might be reported.
Also try to look at debug output during function call - some traces might be there even in Release build
Yes, zero typically means success in the C/C++ world.
In the days before exception handling you had to have a way to indicate failure and the return value was pretty much reserved for failure/success. As for what '1' means, you will have to look in the header of the dll for the function that is returning '1' and see if they included anything about error conditions. There are too many possibilities without seeing the code or knowing more about the dll to provide any easy answers.
What is the name of the function? What is it attempting to do? What can you do if you know the function failed?
I have some code like the following that I'm running in a debugger in Eclipse:
FileOutputStream fstream = new FileOutputStream(new File("foo"));
byte[] ba = someBytes();
fstream.write(bytes);
// tried with and without the following two lines. no difference
// fstream.flush();
// fstream.getFD().sync();
fstream.close();
When I step through this code in the Eclipse debugger, the file does not exist just after fstream.close() is called (verified via file.exists() from another File object created with the same path, as well as looking for the file in a bash shell).
I assume this is some kind of race condition, but I haven't been able to find what's going on. I tried adding fstream.flush() and fstream.getFD().sync(), per another StackOverflow question, but this did not help.
The ultimate symptom of this is that some test cases fail somewhat non deterministically. The behavior appears the same for consecutive identical runs, either with debugging or without, but if I change the breakpoints in the debugger, the behavior can change. I believe it usually/always works when I'm running the code outside of the debugger, but it's troubling that the same code can fail inside of a debugger.
What could be happening here? Is there a good way to make sure the file is written when I think it is?
**UPDATE: I figured out a little of what is going on. The following hack forces the file to be written:
fstream.close();
fstream = new FileOutputStream(file, true);
This is a hack, but seems to force the OS to finish its writing.
This seemed to be an issue with the Eclipse debugger. The hack I mentioned in my edit is the only way I found to force the expected behavior.