Bug 520675 - [9] Java Model Exception: Java Model Status - module-info does not exist
Summary: [9] Java Model Exception: Java Model Status - module-info does not exist
Status: REOPENED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-08 07:30 EDT by Noopur Gupta CLA
Modified: 2024-05-06 18:48 EDT (History)
3 users (show)

See Also:


Attachments
Sample project (1.65 KB, application/x-zip-compressed)
2017-08-08 07:30 EDT, Noopur Gupta CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2017-08-08 07:30:14 EDT
Created attachment 269736 [details]
Sample project

- Import the attached project.
- In Package explorer, copy module-info.java file and paste it in the package "p". We get this exception in Error log view:

org.eclipse.jdt.core
Error
Tue Aug 08 16:56:54 IST 2017
JavaBuilder handling ImageBuilderInternalException while building: Test1

Java Model Exception: Java Model Status [module-info [in module-info.java [in p [in src [in Test1]]]] does not exist]
	at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:558)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:592)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:318)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:304)
	at org.eclipse.jdt.internal.core.Member.getNameRange(Member.java:343)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.createProblemFor(AbstractImageBuilder.java:409)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.acceptResult(AbstractImageBuilder.java:187)
	at org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:615)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:472)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:423)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:376)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:334)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:309)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:139)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:267)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:195)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
...
Comment 1 Stephan Herrmann CLA 2017-08-09 18:17:04 EDT
I checked if I could find a connection to bug 501507 and this is what I found:

org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.acceptResult(CompilationResult) fails to account for module-info in several regards, in particular each call to findType() / getType() may return an IType that does not exist() if the name is "module-info".

For this specific exception a snippet like the following - inserted right before createProblemFor() - would prevent the exception:

	if (type != null && CharOperation.equals(TypeConstants.MODULE_INFO_NAME, typeName)) {
		try {
			type = type.getCompilationUnit().getModule();
			typeName = type.getElementName().toCharArray();
		} catch (JavaModelException e) {
			type = null;
		}
	}

(assuming type is changed to IMember).

But at a closer look, isDuplicateLocator() should never have triggered in this case. Interestingly, duplication is detected even if one of the module-infos is changed to "module Test2 {}". It seems that duplication is detected based on the unqualified name "module-info" rather then on the real name.

=> As nothing in this analysis hints at a connection to the UI issue of where we show module-info in package explorer, I gratefully leave this bug to Jay :)
Comment 2 Eclipse Genie CLA 2017-08-09 18:19:31 EDT
New Gerrit change created: https://git.eclipse.org/r/102818
Comment 3 Stephan Herrmann CLA 2017-08-09 18:20:34 EDT
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/102818

Dumped my last WIP for your entertainment, which somewhat sanitizes the current code section without fixing the root problem.
Comment 4 Eclipse Genie CLA 2020-04-11 03:38:13 EDT
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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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 5 Noopur Gupta CLA 2020-05-19 03:24:52 EDT
Still reproducible with 4.16 latest build.
Comment 6 Eclipse Genie CLA 2022-05-13 19:46:25 EDT
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 2024-05-06 18:48:24 EDT
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.