Bug 21180 - Compilation errors are printed to wrong tab in Output window
Compilation errors are printed to wrong tab in Output window
Status: CLOSED WONTFIX
Product: projects
Classification: Unclassified
Component: Ant
-FFJ-
PC Windows ME/2000
: P3 (vote)
: 3.x
Assigned To: David Konecny
issues@projects
:
: 22659 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2002-03-05 13:28 UTC by Milan Kubec
Modified: 2004-03-03 23:05 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
redirected output tab for script building ant module (14.06 KB, text/plain)
2002-03-06 10:21 UTC, Milan Kubec
Details
zip file with simple test app (1.40 KB, application/octet-stream)
2002-04-11 09:26 UTC, David Konecny
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kubec 2002-03-05 13:28:21 UTC
If user executes build script with compilation errors (in sources), new tab in
OW is created and stdout and stderr are printed there. When another build script
with compilation errors (in sources) is executed, stdout is printed to correct
tab for given script but compilation errors (stderr) are printed to the tab
where compilation errors were printed for the first script execution with comp.
errors. It aplies for any other execution of scripts with compilation errors.
Comment 1 Jesse Glick 2002-03-05 19:06:17 UTC
Doesn't happen to me. What build are you using - is this a regression
- or only in Orion and not dev builds? What compiler? Please attach a
sample script and data for it. Windows only, or Unix too?
Comment 2 Milan Kubec 2002-03-06 10:17:29 UTC
I can easily reproduce it on current dev build on linux too. I unziped
last dev build (I didn't change anything in the IDE), mounted nb_all
folder, where only modules nbbuild (bootstrap), core and openide are
built, nothing else. Then I started execution of ant module - it
failed, then I started execution of applet module - it failed too, but
compilation errors were printed to tab where ant compilation errors
were printed. Any other module compilation (only modules with
compilation errors) ended the same way. There is no special script nor
data needed to reproduce it.
Comment 3 Milan Kubec 2002-03-06 10:21:10 UTC
Created attachment 4959 [details]
redirected output tab for script building ant module
Comment 4 Jesse Glick 2002-03-19 16:15:05 UTC
Sorry, I cannot reproduce any problem, at least not on Linux. I made a
build with -Dmodules=ant from sources circa Mar 8. Started on a fresh
userdir. Mounted /space/src/nb_all/ as a directory. Made sure (from a
command prompt) that core/javahelp and debuggercore and debuggerjpda
and applet and ant were all cleaned (no compiled classfiles). Did not
change any settings. Selected ant/build.xml, F6 to run. Failed with
some compilation errors (missing core/javahelp classes). Build
messages and compiler errors both appeared in Running workspace,
output window tab "ant". Went back to Editing, selected
applet/build.xml, F6. New tab "applet" opened, build messages and
compiler errors (missing debugger classes) appeared in that tab
correctly. Please check if this is a Windows-specific problem,
perhaps, or something else specific to your environment, and reopen if
necessary.
Comment 5 Milan Kubec 2002-03-20 09:07:15 UTC
Jesse I must reopen it again, because I just reproduced it on my linux
box and on Win2000 as well. I used todays NetBeans dev build. I did
same steps as you and really error messages were printed to tab where
error messages were printed for the first time. The tab belonging to
the script showed just text:
...
Compile failed, messages should have been provided.
...

Do you have any idea what settings in my env could cause this problem?
I use JDK 1.4.
Comment 6 Jesse Glick 2002-03-20 14:21:49 UTC
I will look at it... does this occur on JDK 1.3.1 for you too? I have 
not tried with 1.4.
Comment 7 Jesse Glick 2002-03-20 18:22:36 UTC
Actually David could you take a look since I don't have much extra 
time for Ant? If you need hints: DemuxOutputStream (part of Ant 1.4.x) 
is used from TargetExecutor to ensure that all stray System.out/err 
prints get sent to Project.log. (Tasks are supposed to use Project.log 
directly, but occasionally they mess up and print to console, in which 
case the demuxer is a backup to ensure Ant still handles the output.) 
Maybe the switching of the system streams to and from the Ant demuxer 
does not work in some situations.

Also check what *kind* of compiler produces the misdirected errors. 
Internal javac may use System.out/err, I am not sure whether the 
<javac> task succeeds in intercepting this directly. External 
compilers ought to trap the Process.get{Input,Error}Stream and 
redirect anything they get to Project.log, in which case the demuxer 
is irrelevant.

Or perhaps a window system bug is involved. But since some parts of 
the output go to one tab and others to another tab, I suspect the 
demuxer as the most likely problem area.
Comment 8 David Konecny 2002-03-21 14:59:56 UTC
ok. thanx for hints!
Comment 9 Milan Kubec 2002-03-21 15:08:43 UTC
I verified that when running on JDK 1.3.1 everything works OK, so
marking as JDK 1.4 specific issue.
Comment 10 David Konecny 2002-04-10 16:18:04 UTC
Jesse,

I tried to fix this bug, but without success. Maybe you will have some 
pointers which could help me.

I patched Ant sources and debug Ant together with Ant module but I 
still don't have any idea where the problem might be. What I did and 
what I know:

In TargetExecutor I changed the NetBeansLogger to write logs directly 
to some file on disk and not to OutputWriterOutputStream. For each 
execution the file on disk is different. If I execute the first 
script, the log1.txt is created and everything is OK. When I execute 
the second script, the log2.txt is created, BUT errors from javac task 
are put into log1.txt and everything else is correctly put into 
log2.txt. How is that possible? The execution of javac task behaves 
like it was executed from first script - the build listener of first 
project is notified. If I changed the compiler to jikes, everything is 
OK. If I change it back to javac, it fails. I put some logs into Ant's 
Javac13.java file and just before the javac is executed, the strerr is 
correctly set and also the project is correctly set. So where the 
problem might be??????????? :-)

Thanx for any help or recommendations.
Comment 11 David Konecny 2002-04-11 09:24:22 UTC
I found it! It is JDK1.4 problem. It took me some time to realize one 
mistake I did. From the description I wrote yesterday it is clear that 
bug must be somewhere in javac compiler - it must cache stderr on 
first execution and on second and following executions it uses this 
cached stderr. So I wrote simple program which just executes javac 
twice on some uncompilable java file and each time the stderr is 
redirected to different file. Damn! This worked OK. But it took me a 
day or two to realize that I executed the testing application on 
JDK1.3. Grrr!! So today I executed it on JDK1.4 and voila! the same 
error as in Ant appeared. The JDK I'm using is:

1.4.0; Java HotSpot(TM) Client VM 1.4.0-b92

maybe it works on newer JDKs?

In attachment you will find zip file containing my test app. It 
contains two batch files in which you must modify paths to your JDKs 
and then execute them. The result for JDK1.4 is that error output of 
second compilation is sent to _first_ stderr (ie to first file).

And what to do  now? Milan, could I ask you to check BugTraq for this 
error and file bug if necessary? I've never done that before, so it 
would take me ages to do it ;-)

I propose to close this bug as WONTFIX.
Comment 12 David Konecny 2002-04-11 09:26:16 UTC
Created attachment 5370 [details]
zip file with simple test app
Comment 13 Jesse Glick 2002-04-11 13:31:04 UTC
It should not be closed WONTFIX until there is a bug in BugTraq. BTW
if you don't want to use the BugTraq native interface on SWAN, you can
also do it publically (which involves some filtering of your report by
Sun employees confirming it, but this is not necessarily bad):

http://developer.java.sun.com/developer/bugParade/index.jshtml

I think it would be best to look for a workaround, since 1.4 is our
preferred platform, and 'modern' is the default compiler for <javac>.
This bug could be quite visible. Maybe Javac's internal cache can be
cleared using reflection?
Comment 14 Milan Kubec 2002-04-11 15:08:24 UTC
I tried to search for such bug in bugtraq but found nothing, but it
doesn't necessarily mean that the bug is not there since bugtraq is
difficult to search in :-(.
Comment 15 David Konecny 2002-04-11 15:24:37 UTC
Milan, before we file bug I would like to double check it in JDK 
sources. It will take me some time to get them. I will let you know 
then.
Comment 16 David Konecny 2002-04-23 08:16:20 UTC
*** Issue 22659 has been marked as a duplicate of this issue. ***
Comment 17 David Konecny 2002-04-29 13:29:52 UTC
The problem is in JDK1.4.0. There is 

static final PrintWriter defaultWriter = new PrintWriter(System.err);

in com.sun.tools.javac.v8.util.Log class which caches the stderr. 
However in 1.4.1 this should be fixed, so there is no need to file 
bug against JDK. 

I tried to workaround it for 1.4.0, but I did not find any simple way 
how to do that. The variable is "final" so I cannot modify it by 
reflection. Therefore I'm closing this as WONTFIX. If you have some 
suggestion about possible workaround, please, let me know.
Comment 18 Jesse Glick 2002-04-30 02:11:23 UTC
OK. I cannot think of any other workaround on our side. I suggest it
be documented that 1.4.0 users should use a non-internal compiler:
external javac, Jikes, etc.
Comment 19 Patrick Keegan 2002-07-24 16:46:33 UTC
proposed readme text:

Description: Compilation errors are printed to wrong tab in Output 
window when running an Ant script. This may occur if you are using the 
IDE's internal compiler and the IDE is running on JDK 1.4.0.<br><br>

Workaround: Use a different JDK or use a different compiler (such as 
external javac).
Comment 20 David Konecny 2002-07-25 08:39:26 UTC
Sentence "if you are using the IDE's internal compiler" is not right. 
Ant script does not use IDE's compilers. It should be "if you are 
compiling with modern or classic compiler" or something like that 
(see help for Ant javac task). The workaround is to use a diff JDK or 
use a diff compiler (eg. jikes or extJavac).

Comment 21 Jesse Glick 2002-07-25 18:21:35 UTC
And please emphasize that 1.4.1 JDK is OK.
Comment 22 Patrick Keegan 2002-08-08 20:07:52 UTC
Revised release note:

Description: Compilation errors are printed to wrong tab in Output 
window when running an Ant script. This may occur if you are using 
the "classic" or "modern" compiler. <br><br>

Workaround: Use a different JDK (including JDK 1.4.1) or use a 
different compiler (such as external javac or Jikes).
Comment 23 David Konecny 2002-08-08 23:02:05 UTC
The mention that this happens only when IDE is running on JDK 1.4.0
left out. Otherwise OK.
Comment 24 Patrick Keegan 2002-08-08 23:31:23 UTC
added " and you are running on JDK 1.4" to the end.
Comment 25 Quality Engineering 2003-06-30 14:43:50 UTC
Resolved for 3.3.x or earlier, no new info since then -> closing.

Comment 26 Quality Engineering 2003-06-30 14:45:48 UTC
Resolved for 3.3.x or earlier, no new info since then -> closing.

Comment 27 Patrick Keegan 2004-03-03 23:05:23 UTC
removing RELNOTE keyword as this issue seems to be much more marginal
(how many people don't run on 1.4.1 or above?).


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