Erwin Poeze

Greenhorn
+ Follow
since Aug 20, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Erwin Poeze

If I interpret the bug report (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6765597) correctly, it does seem a bug in the compiler. Maybe eclipse faces the same problem in other situations?

The bug has a low priority, it is discovered in Oct 2008 and still seems to exist. For me it is a reason to consider moving from netbeans to eclipse.
14 years ago
I installed eclipse and tested the same class. The Eclipse debugger seems to have no problem interpreting the if statement correctly.
14 years ago
Well, it seems to be a bug in the jdk (i'm using 1.6) that makes the Netbeans debugger (6.7.1) behave wrongly. However, the java code itself shows the correct results.
I added a System.out.println in the second if block and in the debugger the program counter jumps to it. However, the println is not executed.

So, it seems a bug that creates some confusion in the debugger, but has no influence on the actual java execution.
14 years ago
Respons after filing the issue as a bug report:

"This problem is caused by a defect in Java compiler and cannot be fixed in NetBeans. It has been already reported
against JDK, see issue 168365 for more details."

http://www.netbeans.org/issues/show_bug.cgi?id=168365
14 years ago

Rahul.p Kumar wrote:

Delete your class file. Probably your class file and java are not in sync. have you added that if line later than rest of lines ? please don't forget to post the final outcome from netbeans forum.



Deleting the class files has no effect. I'll post the outcome of the Netbeans forum.
14 years ago

Paul Clapham wrote:My guess is that for the first run, you were looking at source code which didn't match the compiled class which you ran. Then you changed the source code and recompiled before the second run. This would explain why the second run did what you expected.

To test my theory, change the code back to the version for the first run and recompile it. If my theory is correct, the third run should also do what you expected.



I did as you asked, but the behaviour is reproducable.

fred rosenberger wrote:i'd verify "Utils.IsTextNode(tNode)" is really returning what you think it is. put in some System.out.println() statements to be sure.


Rahul.p Kumar wrote:Let us say qq = Utils.IsTextNode(tNode) returns boolean. Now qq alone should serve your purpose. Anyway there is no difference between reassigning. So, check for qq, what it is returning, take the opposite meaning.



I included two System.out.println statements:


This proved that the problem is not caused by Java, but by NetBeans. In the debugger the line (Current Program Counter) jumps inside the if statement (to be exact, it jumps to numVNodes++; directly, skipping the second if statement), but this code is not executed. Adding lines above the first if statement influences the debugger behaviour, so it seems that adding the additional qq variable 'solves' the problem, but it is all visual!

Thanks for all your trouble helping me out! I'll pay a visit to the netbeans forum to sort things out.

Thanks again.
14 years ago
Hi,

The following code is from a static class member:



In the test case !Utils.IsTextNode(tNode) returns false. The if statements acts as if it returned true and jumps to the second if statement.

If I assign the result of !Utils.IsTextNode(tNode) to a boolean variable first, then the if statement evaluates the boolean correctly.


I can not think of any reason that explains this behaviour. Any ideas?

Any help is appreciated!
14 years ago
Hi,

I created a Form with a single Item and added two commands. The form is displayed using the setCurrent() method.
This all works.

My question is: How can I change the text of the Item in the form without having to create a completely new form?

I tried to use the set method of the Item using item number 0, but this only works once as the item is removed and
a new item with a new number is created. This results in a exception, which is logical.

Then I removed the current Item from the form with deleteAll() and appended a new Item to the form, but nothing happens.
The deleteAll() method does not seem to have any effect.

I think the second approach maybe the best, but I can be completely wrong. Can any comment on my approach?

Thanks,
Erwin
14 years ago
Yes, I'm using Java6 and a textbook on that version as well. They don't mention the Scanner class which is a pity because this is exactly the thing I would Java expect to have. Thanks for pointing this out and I just order Head Start Java which seems a better book (I read on this forum) and covers Java5.
15 years ago
I read the tutorial on I/O from the command line and the console. The example that is given there, using the console, seems to add another level of difficulty for me.

However, I think I understand the mechanism of the (Buffered)InputStream now.

I edited the example by removing the line "buff.close();" Now I can read multiple input lines.

I followed your suggestion not to use BufferedInputStream too and made an second example. I left out all the lines containing BufferedInputStream and replace "in = buff.read();" with "in = System.in.read();"

Thank you very much for your help. You gave me valuable new insights!
15 years ago
Ok, I understand the part about static methods.

For the input stream, I read about the wrappers in my text book. So the class System has a class variable 'in' that is an InputStream object. The book only mentions the possibility to create a new buffered input stream, but you wrote that that is not necessary. I can not make an instance of InputStream (error message) so you should I use the InputStream object without something like a wrapper?
15 years ago
Hi,

I'm trying to read two lines from the console. The first line is oke, but the second gives and exception "Stream closed"

In the Beginners FAQ I read "Static fields belong to a class, and we all know there's only one of each class, so there's only one copy of each static field."

I'm having trouble to apply the faq to my problem. Can anyone give me a hint?

Thank you

15 years ago