Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 56341 - [41cat] Output window not displaying final EOL and text without EOL.
[41cat] Output window not displaying final EOL and text without EOL.
Product: projects
Classification: Unclassified
Component: Ant
All All
: P3 (vote)
: 6.x
Assigned To: Jesse Glick
: 18508 45294 64037 68617 71637 74019 74270 98940 102079 108570 108961 113753 (view as bug list)
Depends on: 121009
Blocks: 112839
  Show dependency treegraph
Reported: 2005-03-13 23:40 UTC by lleland
Modified: 2008-09-25 19:00 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT

Useful test class (586 bytes, text/plain)
2007-08-14 17:27 UTC, Jesse Glick
More interesting test case (972 bytes, text/plain)
2007-08-14 20:35 UTC, Jesse Glick

Note You need to log in before you can comment on or make changes to this bug.
Description lleland 2005-03-13 23:40:01 UTC
[ BUILD # : Dev 20050312 ]
[ JDK VERSION : 1.5.0_01 ]

Neither the final newline of text output using System.out.println(...), nor any text output using System.out.print(...) that does not end in a newline, is displayed in the output window, even if you call System.out.flush().

This is not readily seen if there is no console input or you do not sleep the main thread. It is a real problem for console input prompts, since they are never displayed until the next line that does end in a newline is displayed.

Using this snippet, you can see this behavior. The output window displays "Console Test", but the cursor remains at the end of that line (not displaying the EOL) and does not display the prompt (not displaying text that does not end in an EOL). When you enter a line of text and hit return, the prompt is finally displayed, followed by the input line.

package com.TheSnakePitDev.Test;

import static java.lang.System.out;

class Main {
    public static
    main(String[] args)
        BufferedReader in = new BufferedReader(new InputStreamReader(;

        out.println("Console Test");
        out.print("> ");

        String line;
        try {
            line = in.readLine();
            if (line == null) line = "<Null>";
        } catch (IOException e) {
            line = "<Exception>";

Comment 1 Milos Kleint 2005-03-14 08:06:06 UTC
i've noticed lately that print() and write() methods are not properly
implemented in output2, everything is line based. I'm trying to come up with a
fix, not sure it makes it into 4.1 though.

How does ant handle reading (or is it printing?) of lines? line by line, or by
Comment 2 Jesse Glick 2005-03-14 14:52:21 UTC
Mostly line by line, I think. Note that running such a program inside Ant from
the command shell doesn't really work either (using a trunk Ant with console
input support, <java fork="true" .../>):

$ /space/src/ant/dist/bin/ant -f /tmp/main.xml 
Buildfile: /tmp/main.xml

     [java] Console Test
[[[I type here: 'foo']]]
     [java] > foo

Total time: 7 seconds

I.e. it is probably ultimately an Ant bug that cannot be fixed in NetBeans, thus
needs to be filed as such. More investigation likely required.
Comment 3 Milos Kleint 2005-03-15 09:43:16 UTC
while it can be an ant bug, we're not innocent either. Some PrintWriter methods
are ignored and some are converted to println() in the current implementation,
which is wrong.
Comment 4 Milos Kleint 2005-03-16 14:33:09 UTC
on branch ISSUE_56341 I've rewritten the storage, Lines model and Output writer
to accept single charaters, incomplete lines etc. covered by tests.
Comment 5 Jesse Glick 2005-04-06 20:07:10 UTC
Fixing the OW won't make any difference for Ant uses since Ant only sends
complete lines. Just FYI.
Comment 6 Milos Kleint 2005-10-19 06:39:52 UTC
the partial line fix code is actually in trunk, reassigning to ant. Jesse, feel
free to close if you have a separate bug for the ant part of the process, I
could not find it.  
Comment 7 Jesse Glick 2005-11-08 20:07:45 UTC
Cannot be fixed in NetBeans alone. Not for 5.0.
Comment 8 Milos Kleint 2005-11-14 07:04:43 UTC
*** Issue 68617 has been marked as a duplicate of this issue. ***
Comment 9 Milos Kleint 2006-01-23 08:37:39 UTC
*** Issue 71637 has been marked as a duplicate of this issue. ***
Comment 10 Milos Kleint 2006-03-27 11:23:37 UTC
*** Issue 74019 has been marked as a duplicate of this issue. ***
Comment 11 Milos Kleint 2006-04-03 08:19:09 UTC
*** Issue 74270 has been marked as a duplicate of this issue. ***
Comment 12 Milos Kleint 2006-06-14 12:58:03 UTC
I have at least a partial solution to the problem that I applied to the Netbeans
BlueJ edition.

1. I have a special ant task that extends the java task and reroutes it's
output+input directly to the output window.
2. I have this task to map over the default java task. So when running within
the IDE, my task gets called instead of the default java one.

1. separate tab for user program output
2. reading character by character results in partial lines being shown as well
3. no ant script tweaks, should run also with a custom ant on the command line
(but in the wrong mode of line-by-line)

1. prints out a warning to the build output.
2. reading char-by-char is not optimized for high throughtput.
3. writing 
will only print out 1 and then wait for the finish of the line. From a brief
evaluation, it looks like a bug in output window implementation.

Comment 13 Jesse Glick 2006-06-14 14:47:20 UTC
This sounds promising. Comments:

Adv #1 is not specific to this implementation. Any AntLogger could choose to
send output elsewhere if it wanted. Conversely, using a special task could send
output to the build tab if desired (might require an API modification; TBD).

Adv #2 is the key.

Adv #3 is not a goal, it is a constraint.

Dr #1 may be solvable using AntLogger.

Dr #2 is probably solvable using local optimizations. Just read into a byte[]
buffer and write as much as you can get at once.

Dr #3 does sound like an OW bug.

Another aspect of getting a direct handle on the j.l.Process that I have been
thinking about is that it would make it more feasible to do things like initiate
thread dumps in the target process (or more generally use the JDK 6 Attach API
to do all sorts of nice things). You still need a mapping from Process instance
to remote VM ID. On the Sun Unix JDK I know this is easy (using reflection); on
other vendor/platform combos it is probably still feasible.
Comment 14 Milos Kleint 2006-06-15 09:05:32 UTC
Dr.1: i'm not sure where the message is coming from. it appears in the output
tab even before the buildStarted(AntEvent event) method is called in my antlogger.
Comment 15 Milos Kleint 2006-07-10 14:45:46 UTC
Dr#3 is fixed in trunk.
Comment 16 Jesse Glick 2006-11-21 01:54:04 UTC
*** Issue 64037 has been marked as a duplicate of this issue. ***
Comment 17 Milos Kleint 2007-01-02 13:14:58 UTC
*** Issue 45294 has been marked as a duplicate of this issue. ***
Comment 18 Milos Kleint 2007-01-09 08:57:15 UTC
*** Issue 18508 has been marked as a duplicate of this issue. ***
Comment 19 Jiri Prox 2007-03-26 16:11:39 UTC
*** Issue 98940 has been marked as a duplicate of this issue. ***
Comment 20 Milos Kleint 2007-07-09 07:44:28 UTC
*** Issue 108961 has been marked as a duplicate of this issue. ***
Comment 21 Milos Kleint 2007-07-10 13:08:44 UTC
*** Issue 108570 has been marked as a duplicate of this issue. ***
Comment 22 Antonin Nebuzelsky 2007-07-17 15:33:01 UTC
To be evaluated for 6.0. Now, as the input is integral part of the output area, this one is still remaining to have the
"input in output" experience complete.
Comment 23 Jesse Glick 2007-07-17 16:05:39 UTC
No minor fix is possible; need to completely change how the IDE interacts with external processes spawned from Ant, by
replacing the <java> task. Promising but too risky for 6.0.
Comment 24 Milos Kleint 2007-08-01 12:48:03 UTC
*** Issue 102079 has been marked as a duplicate of this issue. ***
Comment 25 Jesse Glick 2007-08-01 16:37:50 UTC
*** Issue 68770 has been marked as a duplicate of this issue. ***
Comment 26 Jesse Glick 2007-08-14 17:27:33 UTC
Created attachment 46591 [details]
Useful test class
Comment 27 Jesse Glick 2007-08-14 20:35:02 UTC
Created attachment 46604 [details]
More interesting test case
Comment 28 Jesse Glick 2007-08-14 20:37:02 UTC
Also instructive to override -init-macrodef-java and modify <java>:

  output="/tmp/out" error="/tmp/err" input="/tmp/names"


---%<--- /tmp/names
Comment 29 Jesse Glick 2007-08-14 20:55:04 UTC
I think I have it. A lot of subtleties here, may be regressions I don't know about yet. What I can confirm works:

1. System.out.print with no trailing newline gets printed, and you can use after a prompt.

2. Works on Ubuntu and XP, including differing newline conventions.

3. Stack traces in process output still hyperlinked.

4. System.out and .err distinguished by color.

5. input="...", output="...", and error="..." on <java> work.

6. Entering and printing non-ASCII text (Czech) works on Ubuntu (UTF-8 system encoding).

7. Output missing a final newline at program end is still printed.

8. Performance of large output still seems reasonable.

9. Stopping a build in the middle of producing output succeeds and produces no visible exceptions or other errors (that
I can find).

What I know does not work:

1. (See issue #68770.)

2. Lines of input get retroactively shifted down to a new line after pressing Enter. Probably core/output2 bug.

3. Perhaps same as #2: partial lines of text, while printed, are incorrectly followed by a newline in the display.
Definitely a core/output2 bug.

4. Programs which send characters other than newline to output incrementally at intervals of less than 250 msec will not
display that output until EOL or a longer pause. Might affect, for example, the line of dots printed by programs like
jhat when starting up.

5. Conversely to #4, programs which send complete lines which is piped into NB extremely slowly (e.g. under heavy system
load) might see portions sent as incomplete lines, which (besides the compound effect of problem #3) might result in
missing stack trace hyperlinking.

6. Ant scripts which override <java> themselves (e.g. nbjdk.xml) might not see the benefit of this bug fix. Should not
affect j2seproject, and probably irrelevant for NBM projects, but might affect freeform projects with custom JDKs
configured which use stdio. Not yet tested.

I think these issues are relatively minor compared to this bug and are thus not blockers.

Checking in src/org/apache/tools/ant/module/bridge/;
/shared/data/ccvs/repository/ant/src/org/apache/tools/ant/module/bridge/,v  <--
new revision: 1.37; previous revision: 1.36
RCS file: /shared/data/ccvs/repository/ant/src-bridge/org/apache/tools/ant/module/bridge/impl/,v
Checking in src-bridge/org/apache/tools/ant/module/bridge/impl/;
/shared/data/ccvs/repository/ant/src-bridge/org/apache/tools/ant/module/bridge/impl/,v  <--
initial revision: 1.1
Checking in src-bridge/org/apache/tools/ant/module/bridge/impl/;
/shared/data/ccvs/repository/ant/src-bridge/org/apache/tools/ant/module/bridge/impl/,v  <--
new revision: 1.44; previous revision: 1.43
Checking in src/org/apache/tools/ant/module/run/;
/shared/data/ccvs/repository/ant/src/org/apache/tools/ant/module/run/,v  <--
new revision: 1.12; previous revision: 1.11
Comment 30 Jesse Glick 2007-08-14 21:02:00 UTC
What also works:

10. Running same program twice in parallel so two windows are shown; input sent to the right instance.

Some QE verification would be very much appreciated.
Comment 31 Jesse Glick 2007-08-15 15:55:16 UTC
Reverting (I hope temporarily) due to issue #112839, under investigation.
Comment 32 Jesse Glick 2007-08-15 18:01:25 UTC
Found & fixed a problem with stream closing when running other tasks after <java> (see issue #112839).

Checking in ant/src-bridge/org/apache/tools/ant/module/bridge/impl/;
/shared/data/ccvs/repository/ant/src-bridge/org/apache/tools/ant/module/bridge/impl/,v  <--
new revision: 1.46; previous revision: 1.45
Checking in ant/src-bridge/org/apache/tools/ant/module/bridge/impl/;
/shared/data/ccvs/repository/ant/src-bridge/org/apache/tools/ant/module/bridge/impl/,v  <--
new revision: 1.2; previous revision: 1.1
Comment 33 Milos Kleint 2007-08-28 07:10:17 UTC
*** Issue 113753 has been marked as a duplicate of this issue. ***
Comment 34 Jesse Glick 2008-09-25 19:00:27 UTC
For the record, this impl has been obsoleted by t_h's changes in ForkedJavaOverride.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo