Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 250975 - [1.5][compiler] Stack overflow on static import.
Summary: [1.5][compiler] Stack overflow on static import.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-15 13:12 EDT by Brian Bunker CLA
Modified: 2009-02-03 12:05 EST (History)
4 users (show)

See Also:
jerome_lanneluc: review+


Attachments
.metadata/.log file (676.93 KB, text/plain)
2008-10-15 13:12 EDT, Brian Bunker CLA
no flags Details
Proposed patch (13.14 KB, text/plain)
2008-10-24 13:52 EDT, Philipe Mulet CLA
no flags Details
Proposed patch for 3.4 (13.96 KB, patch)
2008-10-24 16:24 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Bunker CLA 2008-10-15 13:12:50 EDT
Created attachment 115167 [details]
.metadata/.log file

This is on Eclipse Platform Build id: M20080911-1700

I have a class called "AqtiumNode" (in package "node"), which has many static methods called "node" which take different arguments.

If, in another class, I have

import static node.AqtiumNode.*;

then everything is fine. However, if I type

import static node.AqtiumNode.node;

then immediately I get a pop-up window "An Internal Error has occured 'Requesting Java AST from Selection'" and a pop-up window "Internal Error" recommending that I exit the workbench. Looking in the .log file in .metadata, I see that it's a stack overflow. A sample logfile is attached.

When this happens, the build fails and most .class files are not written out.

Also, in the "problems" pane, a problem shows up for the class in which I type the afflicted line: Description "Other", location "unknown", Type "Java Problem".

This has also occured on version 3.3.1.1 on MacOS, and on version 3.2.2 on a PC.

Note that I don't get any compile errors. Moreover, if I build outside of eclipse using the same Java version (I think), it runs fine.

If this bug is new/important, I can potentially try to reproduce in some self-contained code. As is, the code is fairly proprietary, so I don't want to send the sample code as-is. Please advise.

Thanks, Brian
Comment 1 Remy Suen CLA 2008-10-19 09:06:08 EDT
Reproduced on I20081007-1600.

--------------

Test class with static methods:
package node;

public class Test {
	
	public static void node() {}

}

--------------

Test class with static import:
package node2;

import static node.Test.nod;

public class Test2 {

}

--------------

Complete the third line of Test2 with the character 'e' and the aforementioned StackOverflowError will be thrown and the workbench is forced to terminate immediately.
Comment 2 Philipe Mulet CLA 2008-10-24 13:52:42 EDT
Created attachment 116082 [details]
Proposed patch

Kent - pls review.

I believed the loop got introduced by fix for bug 93913; which by the way did not handle field scenarii (only method collision case).

My change avoids the reentrant call alltogether by ensuring supplying a mask during import resolution.
Comment 3 Kent Johnson CLA 2008-10-24 14:02:01 EDT
looks good
Comment 4 Philipe Mulet CLA 2008-10-24 14:50:36 EDT
Added StaticImportTest#test070-072 + LookupTest#test091-094
Comment 5 Philipe Mulet CLA 2008-10-24 14:57:36 EDT
Released for 3.5M3
Fixed
Comment 6 Philipe Mulet CLA 2008-10-24 16:24:03 EDT
Created attachment 116109 [details]
Proposed patch for 3.4
Comment 7 Philipe Mulet CLA 2008-10-24 16:25:48 EDT
Jerome - shall we fix it for 3.4.2 ?
StackOverflow is fairly bad, and the fix is quite reasonable.
Comment 8 Jerome Lanneluc CLA 2008-10-27 06:00:29 EDT
+1 for 3.4.2 since the bug is very bad, and the fix is reasonable.
Comment 9 Philipe Mulet CLA 2008-10-27 06:34:13 EDT
Released for 3.4.2.
Comment 10 Philipe Mulet CLA 2008-10-27 07:02:33 EDT
Released into 3.3.x maintenance branch
Comment 11 Kent Johnson CLA 2008-10-28 13:13:10 EDT
Verified for 3.5M3 using I20081026-2000 build.
Comment 12 Kent Johnson CLA 2009-02-03 12:05:27 EST
Verified for 3.4.2 using M20090127-1710