Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334355 - [DOM] Single Static Import Declaration node, marked as MALFORMED
Summary: [DOM] Single Static Import Declaration node, marked as MALFORMED
Status: CLOSED DUPLICATE of bug 331702
Alias: None
Product: Objectteams
Classification: Tools
Component: OTDT (show other bugs)
Version: 0.8   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 0.8 M4   Edit
Assignee: Project Teams CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-14 04:03 EST by arlindolima CLA
Modified: 2013-06-18 17:16 EDT (History)
2 users (show)

See Also:


Attachments
Add regression test (2.10 KB, patch)
2011-01-14 10:32 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description arlindolima CLA 2011-01-14 04:03:06 EST
Build Identifier: M20100909-0800

In the example Imports.java file below (in Steps to Reproduce), the import:

import static testepackage.StaticTest.cos;

is flagged as malformed.

Another issue: the IMethodBinding of the "cos" import declaration, corresponds to the _last_ "cons" method declared in StaticTest. Is this the intended behaviour?

Reproducible: Always

Steps to Reproduce:
1. Create a project with the following two classes:

******************************************************************
File testepackage/StaticTest.java
******************************************************************
package testepackage;

public class StaticTest {
	public static int cos() {
		return 3;
	}
	
	public static int cos( int x) {
		return x;
	}
	
	public static int cos( int x, Double z) {
		return 2;
	}
}

******************************************************************
File testepackage/Imports.java
******************************************************************
package testepackage;

import static testepackage.StaticTest.cos; // MALFORMED

public class Imports {

	void method() {
		cos();
	}
}
Comment 1 arlindolima CLA 2011-01-14 07:48:19 EST
I've now noticed a simple:

import static java.lang.Math.*;

is also consideed malformed.
Comment 2 Olivier Thomann CLA 2011-01-14 08:21:01 EST
What source settings is used to build the DOM ?
Comment 3 arlindolima CLA 2011-01-14 09:17:54 EST
This is the code I'm using:

ASTParser parser = ASTParser.newParser( AST.JLS3);
parser.setKind( ASTParser.K_COMPILATION_UNIT);
parser.setSource( cUnit);
parser.setResolveBindings( true);

Map<?, ?> options = JavaCore.getOptions();
JavaCore.setComplianceOptions( JavaCore.VERSION_1_5, JavaCore.getOptions());
parser.setCompilerOptions(options);

parser.createAST(null /* IProgressMonitor */);
Comment 4 Olivier Thomann CLA 2011-01-14 10:02:56 EST
I cannot reproduce.
I only get the MALFORMED node if the compliance/source are set to 1.4 or if I don't use the JLS3 kind.
Comment 5 arlindolima CLA 2011-01-14 10:23:35 EST
I might be wrong. I'll add more info tomorrow.
Comment 6 Olivier Thomann CLA 2011-01-14 10:32:24 EST
Created attachment 186828 [details]
Add regression test

This patch reflects the submitted test case and shows that the import declaration node is not malformed.
Comment 7 arlindolima CLA 2011-01-17 16:22:13 EST
I confirm this bug. They're flagged as malformed. This also happens with eclipse 3.4 (with ASTView installed).

I have the ObjectTeams plug-in installed. Could that be introducing errors?
Comment 8 Olivier Thomann CLA 2011-01-17 17:00:30 EST
(In reply to comment #7)
> I confirm this bug. They're flagged as malformed. This also happens with
> eclipse 3.4 (with ASTView installed).
> I have the ObjectTeams plug-in installed. Could that be introducing errors?
Stephan, any idea about this ?
I could not reproduce if the compiler settings are set to 1.5 and the JLS level is JLS3.
Is it possible to provide a test case that is causing the problem ? I tried what was given in comment 3 and I could not reproduce.
If you can reproduce without having Object team installed this would help to narrow it down.
Comment 9 Stephan Herrmann CLA 2011-01-17 17:28:48 EST
(In reply to comment #8)
> (In reply to comment #7)
> > I confirm this bug. They're flagged as malformed. This also happens with
> > eclipse 3.4 (with ASTView installed).
> > I have the ObjectTeams plug-in installed. Could that be introducing errors?
> Stephan, any idea about this ?

sorry, this slipped my attention.

Looks like bug 331702 (in OTDT) (the one which gave rise to bug 331736 in JDT).

Arlindo, could you try if it also occurs in M4 
(Eclipse 3.7M4 with OTDT 0.8M4) ?
Comment 10 Olivier Thomann CLA 2011-01-17 17:34:00 EST
(In reply to comment #9)
> Looks like bug 331702 (in OTDT) (the one which gave rise to bug 331736 in JDT).
Looks like it.
Moving to Objectteams to close as a duplicate.

*** This bug has been marked as a duplicate of bug 331702 ***
Comment 11 arlindolima CLA 2011-01-17 17:47:03 EST
Didn't notice the other bug. Fortunately, it has been solved.
Comment 12 Stephan Herrmann CLA 2011-01-17 18:20:56 EST
(In reply to comment #11)
> Didn't notice the other bug. Fortunately, it has been solved.

Feel free to re-open if you still see the bug with M4.

Also: when in doubt please file future bugs against Object Teams.
If it's not in the OT code, I'll quickly re-assign to JDT.

It's better not to waste the time of the JDT team :)