Bug 469031 - SourceTypeCollisionException escapes from compiler
Summary: SourceTypeCollisionException escapes from compiler
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: APT (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows 7
: P3 normal with 5 votes (vote)
Target Milestone: ---   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-01 14:38 EDT by Markus Keller CLA
Modified: 2023-12-05 12:19 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2015-06-01 14:38:51 EDT
Follow-up to bug 468853:

The new BuilderTests#testBug468853() fails with a SourceTypeCollisionException when I use:

	AbstractImageBuilder.MAX_AT_ONCE = 1; // not "= 2"


org.eclipse.jdt.internal.compiler.lookup.SourceTypeCollisionException
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:137)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:199)
	at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:814)
	at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:930)
	at org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:603)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:458)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:367)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:179)
...

The problem is that Compiler#compile(ICompilationUnit[]) calls processCompiledUnits(0) outside of a try-catch SourceTypeCollisionException block, and hence the internal exception escapes from the compiler.

I think this problem was introduced by the fix for bug 437414, which added the unprotected call to processAnnotations(). I can't really judge how big this problem is in practice.
Comment 1 Jay Arthanareeswaran CLA 2016-04-05 04:33:08 EDT
No progress yet and unlikely to get time during 4.6. Moving out.
Comment 2 Mathias Kjærgaard CLA 2017-07-23 05:00:15 EDT
I get this exception with Eclipse Oxygen when importing the Gerrit project:

$ git clone --recursive https://gerrit.googlesource.com/gerrit
$ cd gerrit && tools/eclipse/project.py
# Import gerrit as existing project
Comment 3 Markus Duft CLA 2018-02-15 10:45:50 EST
interestingly i don't get it with gerrit (building that too :)), but with an internal closed source project, which uses the hibernate-jpamodelgen. It's pretty much a blocker for me. any way around it?
Comment 4 Markus Duft CLA 2018-03-21 03:50:34 EDT
We're using ECJ in a semi-headless environment (Eclipse Workbench is running with a headless rendering engine). In this scenario I DON'T get the exception when run from the command line. I do ALWAYS get the Exception when I do the very same by starting the VM running ECJ from another Eclipse (regardless of debug/not-debug).
Comment 5 Markus Duft CLA 2018-12-12 00:33:41 EST
Setting -DmaxCompiledUnitsAtOnce=1000000 seems to help for our scenario.
Comment 6 Eclipse Genie CLA 2020-12-02 17:11:49 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Eclipse Genie CLA 2022-11-25 01:29:08 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 8 Michael Haubenwallner CLA 2023-11-20 06:48:58 EST
Starting with Eclipse 2023-09, using annotation processor from hibernate-jpamodelgen-5.6.15.Final.jar, we face this (or at least related) problem again:
Classes that were successfully generated by the annotation processor,
"cannot be resolved" when they are used in some subequent Java code.
Manually performing some no-op change (add blank) on that Java code to retrigger it's compilation makes the "cannot be resolved" error go away.

Reducing -DmaxCompiledUnitsAtOnce=1000000 to 1000 or even 1 brings back the org.eclipse.jdt.internal.compiler.lookup.SourceTypeCollisionException again.

Thoughts?

Eventually, I may be able to debug this into more detail, but any additional information or hint upfront would be highly appreciated.
Comment 9 Michael Haubenwallner CLA 2023-12-05 12:19:26 EST
(In reply to Michael Haubenwallner from comment #8)
> Starting with Eclipse 2023-09, using annotation processor from
> hibernate-jpamodelgen-5.6.15.Final.jar, we face this (or at least related)
> problem again:
> Classes that were successfully generated by the annotation processor,
> "cannot be resolved" when they are used in some subequent Java code.
> Manually performing some no-op change (add blank) on that Java code to
> retrigger it's compilation makes the "cannot be resolved" error go away.

This is handled in https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1654