This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 88632 - Single compilation of a jsp file fails due to a uncompilable java source which is not used in the jsp file.
Summary: Single compilation of a jsp file fails due to a uncompilable java source whic...
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: JSP (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Matthew Bohm
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-03 22:13 UTC by ssoong
Modified: 2009-11-02 11:14 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Project z (15.03 KB, application/x-compressed)
2006-12-13 16:34 UTC, ssoong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ssoong 2006-11-03 22:13:43 UTC
NetBeans IDE Dev (Build 200610221800)
1.6.0-beta2; Java HotSpot(TM) Client VM 1.6.0-beta2-b86
Windows XP version 5.1 running on x86
=======================================================
I realise I would be advised of current efforts to merge v5.5 and v6.0.

Despite, I would like to bring to attention a regression in behaviour.

My web app project has a testPattern.jsp
<%@ page import="java.util.regex.Pattern" %>

The project also has an incomplete java class file TestPattern.java which I 
shall not show here. Obviously TestPattern.java will compile with errors. 

I was editing TestPattern.jsp. I pressed [f9], which should focus on compiling 
TestPattern.jsp. But no, [f9] tried to compile TestPattern.java too.
Note that TestPattern.jsp does not include or use any beans or 
TestPattern.java at all.

The jspcompiler should my its own business and not stray into attempting to 
solve the whole world's problems by compiling other files not associated with 
the jsp it is currently compiling. I need to be given the latitude to create 
lots of syntactically incomplete stub java files and not have the compiler 
bother with them until I build the whole project.

I will verify if this happens in 5.5 too. If so, I will change priority to P1. 
Because this would make project work impossible.
Comment 1 ssoong 2006-11-03 22:15:36 UTC
"The jspcompiler should my its own business ..."
I meant to say
"The jspcompiler should mind its own business ..."
Comment 2 ssoong 2006-11-30 16:32:45 UTC
This affects NB5.5 20061124/JDK1.5_5 too.

It is too debilitating. I have to move all my incomplete stub source files out 
of the view of the IDE. I also need to move all my incompletely modified files.

Issue needs to be on P1.
Comment 3 Petr Pisl 2006-11-30 19:00:03 UTC
I don't think that this is regression. I have just tested this with NetBeans 5.0
FCS and NetBeans 5.5 FCS and the behavior is the same and IMHO it works in way
how I expect this.

I did a new web application and created new java class. Then I did the java
class uncompilable and did the <%@page import %> in the index jsp. Then I
compiled (through F9) the index and as I expected the build failed due to the
uncompilable class.  I also look through the sources and I didn't find a commit
which should changed the behavior.

In which build it works differently?
Comment 4 Petr Jiricka 2006-12-07 21:45:45 UTC
This behavior is intentional. Since JSP pages may import JavaBeans, the JSP
compiler requires that this bean is compiled, in order to compile the JSP. 

Try for example adding the following to the page:
<jsp:useBean id="x" class="com.foo.MyBean"/>

If you don't have a class called com.foo.MyBean, you will get compilation
errors, not runtime errors. If we did not compile Java classes before compiling
JSPs, this could result in some hard to find errors, such as that I add a
property into my class, then try to use in <jsp:getProperty... />, and the IDE
reports compilation errors, although the code is correct.

It is the same situation as when javac always determines dependencies, and when
you want to compile class X, it compiles all the classes that X depends on (if
they are not up to date), not only X.

I suggest marking this as invalid.
Comment 5 ssoong 2006-12-11 21:28:16 UTC
I'm afraid you misunderstood the problem I am hi-liting.
Let me restate.

My project has a a.jsp.
It does not depend on any class or beans.
I decide to create a few incomplete java files.
a.jsp still does not depend on nor imports any of the new impending classes.
Impending, because they are merely uncompilable java source files.
Now, I click on F9 just to validate a.jsp.

Well, the JSP compiler could not mind its own business and dependencies and 
crawled around attempting to compile java files that has nothing to do with 
a.jsp simply because they are in the same project.


Comment 6 ssoong 2006-12-11 21:31:08 UTC
I forgot to say that you need to have a b.jsp which depends on one of the 
incomplete java files.

But still the same, I am trying to compile/validate a.jsp not b.jsp.
Comment 7 Petr Jiricka 2006-12-12 08:51:05 UTC
I understand. However, the JSP compiler has no way of knowing what Java classes
the JSP uses, without actually compiling the JSP. So in order to find out which
classes the JSP needs, we need to run the JSP compiler. If we run the JSP
compiler and we find out that a.jsp depends on class X and class X is not
compiled, it is too late - compilation of a.jsp will fail even if everything is
correct. 

I understand you may not like the fact that the compilation is currently too
defensive, but I would not classify this as a bug. I think at some level, the
request you describe makes sense, so we are willing to consider the change of
the behavior. Any suggestions on how it all should behave so it behaves
plausibly in all the cases? 

I am changing this to P2 enhancement.
Comment 8 ssoong 2006-12-13 16:34:44 UTC
Created attachment 36651 [details]
Project z
Comment 9 ssoong 2006-12-13 16:50:36 UTC
[quote]
If we run the JSP compiler and we find out that a.jsp depends on class X and 
class X is not compiled, it is too late
[/quote]

No, no, no ... I think there is still a misunderstanding:
If a.jsp depends on class X and class X is not compiled, then I want JSP 
compiler to show error. I request not to change that behaviour.


Zttachment 36651 (Project z) is a simple project.
a.jsp is an empty file.
xyz.a.java is a bare-bone java source that compiles properly.
xyz.b.java is a bare-bone java source that has an intentional error and would 
not compile.

When I compile xyz.a.java, the java compiler does not react with errors.
When I compile/validate a.jsp (which does not depend on any beans - since it 
is empty - not even on xyx.b.java), compilation fails showing that xyz.b.java 
has errors.

Why is it that compiling xyz.a.java would not stop on errors due to xyz.b.java,
but compiling a.jsp would? In more colloquil terms, why is compiling 
xyz.a.java able to mind its on business while compiling a.jsp can't keeps its 
hands off its neighbour's properties?

Please let me restate - a.jsp is empty - has no dependencies. But its 
compilation stops on errors in xyz.b.java.

~ thou shalt not covet thy neighbour's java class on which you have no 
dependencies.




Comment 10 Petr Pisl 2006-12-13 17:40:14 UTC
Yes I agree with ssoong. If the behavior is different, that should be
consolidate and there is real use case. I'm marking the issue back as defect, at
least to evaluate again. 
Comment 11 Petr Pisl 2007-08-03 09:37:10 UTC
The compile-single-jsp target depends on compile target, which compiles the java sources. I think, whether there is a
way how to say ant target don't fail, if the depend target fails, then this issue can be fixed.
Comment 12 Petr Pisl 2007-08-03 13:26:31 UTC
I changed the summary of this issue, because the original one "Case of busybody jsp compiler" doesn't mirror the real
problem. 
Comment 13 Petr Pisl 2007-08-08 16:22:17 UTC
Yesterday I was playing with this issue. I'm able to change the ant script in a way that when the compilation of the
java files fails, then the jsp compilation continue. 

The problem is that java files are compiled with javac. Javac at first round try to parse all java sources and if there
is a syntax error (no compilation error), then it stops and doesn't produce any class file. The solution for this
obstacle is that we would find out all classes needed for the jsp file compilation. But this solution has performance
disadvantages. You need to find out all the jsp files, which are needed for compilation (included files, tag files,
preludes, codas) and obtain the list of needed classes. In the current state it means that the jsp files will be parsed
twice. One time for finding needed information and second time during compilation. After this we can try to compile with
javac the obtained list of java sources.

IMHO the suggested solution is too much work and I'm not sure whether it worth doing this. I tried Idea and Eclipse as
well and in both IDE it doesn't work as I expect. 

I close this issue as WONTFIX. If you don't agree, reopen and switch to enhancement. 
Comment 14 ssoong 2007-08-10 21:49:49 UTC
I find it difficult to accept that the compiler
treats direct and jsp-precompiled java source files
differently.

I have a.jsp, b.java and c.java.
a.jsp has no errors.
b.java has no errors.
c.java has errors.

I have b.java up on the editor.
I press F9 specifically on b.java .
The compiler behaves properly and minds its own business.
It does not put a telescope at its neighbour (c.java)
 and say "hey you have sinned!"
It minds its own business.

Now, I put a.jsp up on the editor and press f9.
Holy smoke, why is the jsp compiler so busybody and pokes
 its nose at c.java where it doesn't belong?

How is it that compiling a java class does not face the problem?
How is it that we are able to detect the b.java does not depend on c.java?

Let's say that a.jsp is precompiled to a_jsp.java.
There should be no discrimination between compiling
 a_jsp.java and b.java.
a_jsp.java is just another source file.

If the compiler could detect that b.java does not depend on c.java,
why can't it detect that a_jsp.java also does not depend on c.java?

I am not changing the status but I simply need to express my
frustration because, as I said, I need the latitude to put in experimental
and incomplete classes within the project. If I had perfect classes that
compiled correctly the first time why would I even need an IDE??
Comment 15 Petr Pisl 2007-08-21 15:36:16 UTC
I understand your point and basically I agree with you. I will try to implement a solution, which will look for the
classes, which are used in the compiled jsp file, and compile just these classes. I'm opening this issue just for
tracking this issue, because IMHO it is not very often use case. Also I'm increasing the priority. 
Comment 16 Jiri Prox 2008-04-11 01:11:52 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 17 Matthew Bohm 2008-11-21 04:11:36 UTC
Here's my understanding of the issue. ppisl, please let me know if any of the following is inaccurate.

The limitation in question appears to stem from the fact that the jasper JSP compiler (org.apache.jasper.JspC) needs to
know a classpath specifying the classes on which the generated servlet will depend. In other words, it requires that
such classes already be compiled. The IDE, not knowing exactly on which classes these are, compiles all the classes in
the project before invoking the JSP compiler. In order to compile just the classes on which the generated servlet will
depend, the IDE would have to perform the extra step of examining the JSP source and calculating a list of those
classes. It could then compile just those classes and then invoke the JSP compiler.

As I see it, considering the development time it would require to implement this behavior, and given that there will be
a performance hit for this extra step, however potentially slight, I'm not convinced we ought to implement this without
more demand from the community. The fact that this is not a common request probably indicates that among those
developers who explicitly attempt to precompile JSPs during their development, most do not find it unreasonable to make
their Java classes compilable first.

It's not that the request is impossible to implement. It is just that the JSP compiler doesn't selectively compile the
relevant Java classes; rather, it expects the relevant Java classes already to be compiled. So the work of selective
compilation would have to fall to the IDE. The question is whether the IDE ought to implement it.

I think it only makes sense if there is a fair amount of community demand. ppisl, do you agree?
Comment 18 Petr Jiricka 2008-11-21 11:55:52 UTC
I agree with this assessment. We can probably mark this as RESOLVED/LATER.
Comment 19 Matthew Bohm 2008-11-21 16:10:44 UTC
Marking resolved/later.
Comment 20 Quality Engineering 2009-11-02 11:14:27 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX