Bug 199293 - Erroneous "Uncompilable source code" error when running
Erroneous "Uncompilable source code" error when running
Status: RESOLVED FIXED
Product: java
Classification: Unclassified
Component: Source
7.0.1
PC All
: P2 with 2 votes (vote)
: 7.3
Assigned To: Jan Lahoda
issues@java
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-09 00:29 UTC by eialbur
Modified: 2013-07-28 18:55 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
Test case in zip file (21.76 KB, application/octet-stream)
2012-12-01 19:09 UTC, bht
Details

Note You need to log in before you can comment on or make changes to this bug.
Description eialbur 2011-06-09 00:29:38 UTC
This is an intermittent issue and I haven't figured out how to reproduce yet.

Netbeans will sometimes give me an "Uncompilable source code - Erroneous sym type" error then there is no error.  All of the code compiles just fine.  Sometimes when this happens I can just touch (add a space to the end of a line) the file in question and save - then the problem goes away.  However, sometimes it is much more persistent .. occasionally the only solution I've found is to exit, come back up in 7.0 Beta, run in 7.0 Beta, save, exit, then come back up in 7.0 Release.

In 7.0 Beta I used to get files that just didn't compile (without touching, as above), and files with no errors that showed an error badge (touching would usually fix).  That was annoying, but simpler to solve than this issue.

Sorry I don't have more details on how to reproduce ... it just happens sometimes.
Comment 1 lucrus 2011-08-13 07:36:04 UTC
This still happens to me also, it happened in 7.0 and still happens in 7.0.1.
I'm not sure the compiler is the component responsible for the bug, because the project compiles correctly and the exception shows up at runtime.

I add that running the jar from the command line works as expected and no exception is thrown.
Comment 2 lucrus 2011-08-19 09:46:24 UTC
From the nbusers mailing list I got the following hint:

"workaround it by deselecting 'Compile On Save' in the project options".

It actually works. I felt like changing the product for this bug report because I think "java" is not really responsible for this, while the ide is. Consequently I choose "Import settings" as component, but that's only a guess. Feel free to switch that back to "java/compiler" if I misunderstood the meaning of the "product" field.
Comment 3 lucrus 2011-08-19 09:47:36 UTC
From the nbusers mailing list I got the following hint:

"workaround it by deselecting 'Compile On Save' in the project options".

It actually works. I felt like changing the product for this bug report because I think "java" is not really responsible for this, while the ide is. Consequently I choose "Import settings" as component, but that's only a guess. Feel free to switch that back to "java/compiler" if I misunderstood the meaning of the "product" field.
Comment 4 Dusan Balek 2011-10-26 08:34:12 UTC
Hard to fix without a reproducible test case. The workaround is to switch the Compile-On-Save off in project's properties.
Comment 5 jjazzboss 2011-12-20 11:08:52 UTC
I submitted the same issue I think, see 206266. I just attached an application to reproduce the problem.
Comment 6 jmkgreen 2012-05-08 13:04:21 UTC
This error just hit me. Switching off compile in save is a workaround but creates a PITA too.

Product Version: NetBeans IDE 7.1 (Build 201112071828)
Java: 1.7.0; Java HotSpot(TM) 64-Bit Server VM 21.0-b17
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)

I have a maven web app which uses Morphia (MongoDB). It was when I created a test using a Query<Entity> that Netbeans fell over.
Comment 7 bht 2012-05-09 05:59:19 UTC
Have a look at issue 210053 - there are some clues and patches that may help diagnosis. I could not reproduce it :(
Comment 8 PECI 2012-06-07 18:56:02 UTC
WHEN I HAD AN ISSUE WITH UPPERCASE & LOWERCASE PACKAGE NAMES, THIS ERROR HAPPENED, I TRIED DISABLING COMPILE ON SAVE AND IT STILL THERE, WHAT WORKED TO ME WAS A CLEAN AND BUILD, HOPE IT HELPS
Comment 9 lucrus 2012-06-08 07:36:26 UTC
After reading comment #8 I briefly looked at the calendar: «No, it's not april fools'...»
Comment 10 janvo 2012-07-10 12:50:32 UTC
since I switched to 7.2 I have this problem to.
so netbeans 'corrupts' the classfiles 
and my 'run' from the command line fails at runtime (also in classes I did not change!)
Comment 11 squib 2012-08-03 08:19:27 UTC
Today we installed NB7.2 and created a new project with compile on save enabled. Source code was already there and has been imported into this project. Suddenly we got "erroneous type" messages too. Disabling compile on save, clearing file history and index cache then restarting NB solved it.
Comment 12 andreasfreyer 2012-08-13 00:51:03 UTC
I have the same bug. Clearing the netbeans cache helps for a while. Then I get the "Uncompilable source code - Erroneous ctor sym type" exception when running my application. After clearing the cache again it works again for a while.
Comment 13 bht 2012-08-25 07:43:33 UTC
I have the same issue with 7.3 dev now, very often. I originally filed issue 210053. I have tried many times to make a reproducible test case but it became clear that it is impossible to do.

So while this hasn't been fixed or cannot be fixed, where is plan B?

We cannot consider the clearing of the cache manually. Would it be possible to create an IDE action to clean up a project without having to shut down?

Or is there a way that the IDE can diagnose such events?
Comment 14 bht 2012-08-25 19:50:39 UTC
The following scenario can cause this error on a large scale:

In a J2EE project dependent on glassfish-3.1.2.2, I upgraded the EclipseLink persistence provider with the latest version as follows:

- Stop GlassFish
- remove the following files from C:\Program Files\glassfish-3.1.2.2\glassfish\modules
javax.persistence.jar
org.eclipse.persistence.oracle.jar
org.eclipse.persistence.antlr.jar
org.eclipse.persistence.asm.jar
org.eclipse.persistence.core.jar
org.eclipse.persistence.jpa.jar
org.eclipse.persistence.jpa.modelgen.jar
org.eclipse.persistence.moxy.jar
- copy new files from eclipselink-plugins-2.4.0.v20120608-r11652.zip
javax.persistence_2.0.4.v201112161009.jar
org.eclipse.persistence.oracle_2.4.0.v20120608-r11652.jar
org.eclipse.persistence.antlr_3.2.0.v201206041011.jar
org.eclipse.persistence.asm_3.3.1.v201206041142.jar
org.eclipse.persistence.core_2.4.0.v20120608-r11652.jar
org.eclipse.persistence.jpa.jpql_2.0.0.v20120608-r11652.jar
org.eclipse.persistence.jpa.modelgen_2.4.0.v20120608-r11652.jar
org.eclipse.persistence.jpa.osgi_2.4.0.v20120608-r11652.jar
org.eclipse.persistence.jpa_2.4.0.v20120608-r11652.jar
org.eclipse.persistence.jpars_2.4.0.v20120608-r11652.jar
org.eclipse.persistence.moxy_2.4.0.v20120608-r11652.jar

- Start GlassFish

GlassFish does not care about the names of the files.

Meanwhile, all projects depending on GlassFish break because the file javax.persistence.jar is missing. The file javax.persistence_2.0.4.v201112161009.jar just needs to be renamed.

The IDE appears to recompile files that depend on javax.persistence.jar e.g.
import javax.persistence.EntityManager;
, and in my case it put "uncompilable sourcecode" in the constructor of many files that I did not touch at all.

It did not help that I later renamed javax.persistence_2.0.4.v201112161009.jar to javax.persistence.jar and the project did not have any errors. It just failed when running the tests.

The affected files were all JUnit test files in the project's test directory.

It would not surprise me if I did not change a single line of Java code to create these errors.
Comment 15 Jan Lahoda 2012-08-27 10:28:54 UTC
Thanks for the description. I have found a bug where a timestamp is not cleared from the cache after a jar is deleted - if a jar (re-)appears at the same place with the same timestamp, it is not reindexed again. Is there a chance this would match your usecase?

Thanks.
Comment 16 bht 2012-08-27 16:29:53 UTC
Jan, This looks close. But the jars have different timestamps. The new version has a later date: 
24 May 2012, 7:20:44 a.m. vs Sunday, 15 July 2012, 3:38:08 p.m. and the sizes are different.
Comment 17 noikhongduoc 2012-09-08 11:23:53 UTC
I get the same error when put compile on save off it seem to be running fine. Using Netbean 7.2
Comment 18 Quality Engineering 2012-11-22 02:43:35 UTC
Integrated into 'main-golden', will be available in build *201211220002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/c3a8525b2847
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #199293: when a jar file is deleted, its timestamp must be forgotten as well, so that is the file re-appears with the same timestamp, it is processed again.
Comment 19 Jan Lahoda 2012-11-28 12:32:30 UTC
The above changeset fixes the problem with jar disappearing and appearing with the same timestamp. For possible other problems, I am afraid that some pointers on how to reproduce are needed.
Comment 20 bht 2012-12-01 19:04:46 UTC
How to reproduce:
- Install NetBeans including GlassFish
- Run NetBeans in a separate userdir
- Start NetBeans in separate userdir - do not import settings
- Menu|Tools|Options|Miscellaneous|Files|Uncheck "Enable auto-scanning of sources"
- Open the attached project "Cache"
- In the services window, start Java DB and ensure that the sample database exists: jdbc:derby://localhost:1527/sample
- Run the test CustomerSessionTest.java (should succeed)
- In the GlassFish installation dir C:\Program Files\glassfish-3.1.2.2\glassfish\modules, rename javax.persistence.jar to javax.persistence.hide.jar
- Menu|Source|Scan for external changes and wait for the project to break because of missing javax.persistence.jar
- Rename javax.persistence.hide.jar back to javax.persistence.jar
- Menu|Source|Scan for external changes and wait for the project to fix itself
- Run the test CustomerSessionTest.java (should succeed)

Result:

Testcase: ejb.session.CustomerSessionTest:	Caused an ERROR
Uncompilable source code - Erroneous ctor sym type: <any>
java.lang.RuntimeException: Uncompilable source code - Erroneous ctor sym type: <any>
	at ejb.session.CustomerSessionTest.setUpClass(CustomerSessionTest.java:31)
Comment 21 bht 2012-12-01 19:09:19 UTC
Created attachment 128696 [details]
Test case in zip file
Comment 22 Jan Lahoda 2012-12-03 17:48:18 UTC
Thank you very much - reproducible.
Comment 23 bht 2013-01-01 10:16:58 UTC
I have had a different, very common scenario that produces the same result:

Incorrect error badges detected after Exception in Log.

Happened after I had deleted an overriding method in a session bean that implements a local interface.

Subsequently I fixed the resulting error of not implementing that method by deleting the method in the interface.

Then the session bean java file kept the old error badge and the IDE warned me of errors in the project when I tried to run a junit test for a single session bean method. I had to wait a long time because in log WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: Going to recompute root=

Finally afer a long time, the error badge disappeared from the session bean.

But when I tried to run the junit test then there was an ExceptionInInitializerError in setUpClass() which was caused by uncompilable source code in the session bean that had the wrong error badge.

I have saved all the data from this scenario so please ask if you need it.
Comment 24 Quality Engineering 2013-01-03 02:39:15 UTC
Integrated into 'main-golden', will be available in build *201301030001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/394c4cf7bf07
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #199293: reporting a synthetic error when invoking a resolvable constructor with erroneous type, unless it can be expected an error was already reported. Needed to handle introduction of a new type that fixes the constructor, but does not recompile the usages of the constructor.
Comment 25 Jan Lahoda 2013-01-04 16:19:32 UTC
The test case from comment#20 should be fixed by the above changeset. The test case from comment#23 is hopefully fixed by:
http://hg.netbeans.org/main-silver/rev/2616124d1342

Before testing please clear $CACHE_DIR/index, so that old broken data do not affect the testing. Thanks.
Comment 26 Quality Engineering 2013-01-05 02:30:54 UTC
Integrated into 'main-golden', will be available in build *201301050001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/2616124d1342
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #199293: the behavior of 'find subclasses' depends on the given ElementHandle's ElementKind - indexing needs to use OTHER when unsure (otherwise e.g. subtypes of an interfaces would not be found, leading to false compile errors)
Comment 27 everflux 2013-07-28 18:55:36 UTC
I had the problem with a maven project in 7.4dev as well:

Product Version: NetBeans IDE Dev (Build 201307262300)
Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b15

I fixed it by "clean and build" after searching quite some time for an error that was not there...


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