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 154372 - IDE doesn't complain about anything, but file won't compile
Summary: IDE doesn't complain about anything, but file won't compile
Status: RESOLVED WORKSFORME
Alias: None
Product: apisupport
Classification: Unclassified
Component: Harness (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-02 15:36 UTC by Petr Dvorak
Modified: 2012-06-20 16:13 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample file, file "org.netbeans.test.editor.suites.keybindings.KeyMapTest.java" in Editor module (4.00 KB, text/plain)
2008-12-02 15:37 UTC, Petr Dvorak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Dvorak 2008-12-02 15:36:23 UTC
Product Version: NetBeans IDE Dev (Build 200812020201)
Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b13
System: Linux version 2.6.27-10-generic running on i386; UTF-8; en_US (nb)

I tried to add "ProjectSupport" class to a NB functional test (Keymap test in editor module). Import for Project support
is added and recognized by CC (I type "import org.netbeans.junit.ide." and "ProjectSupport" is offered, when I type
"ProjectSupport." inside a method, "waitScanFinished();" is correctly offered to me), but when I invoke Run File, errors
are listed in the output tab.

What IDE sees should be consistent with the real state of things.

To reproduce:

1. Replace file "KeyMapTest.java" (functional tests for Editor module) with file bellow (simplified snapshot of the file)
2. Invoke "Run File"
-> File does not compile...
Comment 1 Petr Dvorak 2008-12-02 15:37:47 UTC
Created attachment 74429 [details]
Sample file, file "org.netbeans.test.editor.suites.keybindings.KeyMapTest.java" in Editor module
Comment 2 Dusan Balek 2008-12-09 10:05:56 UTC
Inconsistency between classpaths used by editor and "Run File".
Comment 3 Jan Lahoda 2008-12-09 12:36:12 UTC
The ProjectSupport class is in the j2seproject's unit tests (which, IMO, is a bug itself). The classpath contains the
jar file with the tests (nbbuild/build/testdist/unit/java2/org-netbeans-modules-java-j2seproject/tests.jar). As the
SourceForBinaryQuery provides an answer for this jar, the sources (j2seproject/test/unit/src) are used, and the
ProjectSupport class is found. At compile time, the tests.jar file is not created, and so the compilation fails. So,
either the project type (apisupport.project) should compile tests including necessary dependencies, or the user should
be aware of this and compile the j2seproject's tests manually.
Comment 4 Jesse Glick 2008-12-09 16:06:14 UTC
It is intentional that ProjectSupport is in j2seproject. Leftover from XTest madness. Better not to use it at all if you
can avoid it. Just exposes a method from java.source.

Anyway, to your problem - the harness will in fact compile tests of modules you have test dependencies on. Do you have a
test dep on j2seproject? (Check project.xml.) For efficiency, this step is sometimes skipped in incremental builds if it
seems that test deps have already been compiled; I can't remember the exact criteria offhand.
Comment 5 Petr Dvorak 2008-12-16 15:35:30 UTC
Adding functional test dependency to (non-API) module "Java SE Project" solved the issue. If the inconsistency between
what IDE sees and what compiler sees is very specific and influences only NetBeans testers, this issue can be closed as
invalid.

> Better not to use it at all if you can avoid it.

Use of ProjectSupport::waitScanFinished() is the easiest way to determine that the project has been scanned and that
testing itself can start... this is important for test stability.
Comment 6 Jesse Glick 2008-12-16 15:52:12 UTC
ProjectSupport.waitScanFinished just delegates to a deprecated method of the same name in SourceUtils in java.source.
Tests should probably be using RepositoryUpdater.getDefault().waitScanFinished() instead; this is not deprecated, it
just needs a non-exported package (which tests but not regular module code can see).

To reiterate, the only reason this method is in j2seproject to begin with is because XTest dumped a bunch of test
methods into one class and exposed it to all functional tests by default. Since we cannot break apart a class, it had to
go somewhere. open/closeProject are already deprecated in favor of a utility in projectui; createProject has to be in
the j2seproject module.

If jlahoda agrees, I would mark PS.wSF deprecated and ask that test authors use RU.gD().wSF().

Anyway, this is all tangential to the filed bug, which is some kind of problem in the harness' calculation of which
upstream modules need to have their tests built in advance.
Comment 7 Petr Dvorak 2008-12-16 16:30:21 UTC
> Tests should probably be using RepositoryUpdater.getDefault().waitScanFinished() instead;

Thanks for the tip, works nicely...
Comment 8 Jaroslav Tulach 2012-06-20 16:13:19 UTC
Please give me steps to reproduce the problem in NetBeans 7.2.