Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023-09: Error while evaluating 'Array' logical structure for type java.util.Collection with the value 'return toArray();' #309

Closed
andy-goryachev-oracle opened this issue Sep 18, 2023 · 59 comments · Fixed by #428
Assignees
Labels
regression Regression from previous release
Milestone

Comments

@andy-goryachev-oracle
Copy link

andy-goryachev-oracle commented Sep 18, 2023

To reproduce:

  • use an existing workspace created with an earlier version
  • debug any program containing either a list or a map.
  • set a breakpoint and try to expand an ArrayList or a HashMap in the Variables view.
  • the node expands, but instead of enumerating the content, it says "Error while evaluating..." (see the two attached screenshots in the comments)

I can see it on macOS with 2023-09.
Is this a resurrection of https://bugs.eclipse.org/bugs/show_bug.cgi?id=559505 ?

This is bad enough, I am forced to downgrade.

Error log:

java.lang.IllegalStateException: The method toArray() is undefined for the type Collection___
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure$EvaluationBlock.log(JavaLogicalStructure.java:200)
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure$EvaluationBlock.evaluate(JavaLogicalStructure.java:149)
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure.getLogicalStructure(JavaLogicalStructure.java:323)
	at org.eclipse.debug.internal.ui.views.variables.LogicalStructureCache$LogicalStructureTypeCache.getLogicalStructure(LogicalStructureCache.java:144)
	at org.eclipse.debug.internal.ui.views.variables.LogicalStructureCache.getLogicalStructure(LogicalStructureCache.java:57)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getLogicalValue(VariableContentProvider.java:215)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getLogicalValue(VariableContentProvider.java:114)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getValueChildren(VariableContentProvider.java:132)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getAllChildren(VariableContentProvider.java:77)
	at org.eclipse.jdt.internal.debug.ui.variables.JavaVariableContentProvider.getAllChildren(JavaVariableContentProvider.java:144)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getChildCount(VariableContentProvider.java:48)
	at org.eclipse.jdt.internal.debug.ui.variables.JavaVariableContentProvider.getChildCount(JavaVariableContentProvider.java:73)
	at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider.retrieveChildCount(ElementContentProvider.java:126)
	at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider$2.run(ElementContentProvider.java:76)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
@andy-goryachev-oracle
Copy link
Author

Screenshot 2023-09-18 at 16 13 47 Screenshot 2023-09-18 at 16 13 58

@andy-goryachev-oracle
Copy link
Author

Session data:

eclipse.buildId=4.29.0.20230907-1200
java.version=20.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=aarch64, WS=cocoa, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product -keyring /Users/REDACTED/.eclipse_keyring
Command-line arguments:  -os macosx -ws cocoa -arch aarch64 -product org.eclipse.epp.package.java.product -keyring /Users/REDACTED/.eclipse_keyring

@andy-goryachev-oracle
Copy link
Author

Stack trace for Map:

java.lang.IllegalStateException: The method entrySet() is undefined for the type Map___
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure$EvaluationBlock.log(JavaLogicalStructure.java:200)
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure$EvaluationBlock.evaluate(JavaLogicalStructure.java:149)
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure.getLogicalStructure(JavaLogicalStructure.java:323)
	at org.eclipse.debug.internal.ui.views.variables.LogicalStructureCache$LogicalStructureTypeCache.getLogicalStructure(LogicalStructureCache.java:144)
	at org.eclipse.debug.internal.ui.views.variables.LogicalStructureCache.getLogicalStructure(LogicalStructureCache.java:57)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getLogicalValue(VariableContentProvider.java:215)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getLogicalValue(VariableContentProvider.java:114)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getValueChildren(VariableContentProvider.java:132)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getAllChildren(VariableContentProvider.java:77)
	at org.eclipse.jdt.internal.debug.ui.variables.JavaVariableContentProvider.getAllChildren(JavaVariableContentProvider.java:144)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getChildCount(VariableContentProvider.java:48)
	at org.eclipse.jdt.internal.debug.ui.variables.JavaVariableContentProvider.getChildCount(JavaVariableContentProvider.java:73)
	at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider.retrieveChildCount(ElementContentProvider.java:126)
	at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider$2.run(ElementContentProvider.java:76)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

@andy-goryachev-oracle andy-goryachev-oracle changed the title Error while evaluating 'Array' logical structure for type java.util.Collection with the value 'return toArray();' 2023-09: Error while evaluating 'Array' logical structure for type java.util.Collection with the value 'return toArray();' Sep 18, 2023
@andy-goryachev-oracle
Copy link
Author

Is this the right place to log the issue?

@iloveeclipse
Copy link
Member

Yes, it is. Please beso kindand attach small self containing example demonstrating the issue.

@andy-goryachev-oracle
Copy link
Author

Thank you.

I've downgraded my eclipse yesterday, so i cannot provide an SCCE. Updated the description and how to reproduce.

@iloveeclipse
Copy link
Member

This reminds me on https://bugs.eclipse.org/bugs/show_bug.cgi?id=543604 , but that was fixed long time ago.
I can't reproduce on master, running on Java 20.0.2 / Linux.

import java.util.HashMap;
import java.util.Map;

public class Test {
	public static void main(String[] args) {
		Map<String, String> map = new HashMap<>();
		map.put("key1", "value1");
		map.put("key2", "value2");
		map.put("key3", "value3");
		System.out.println(map);
	}
}

image

So if you want a fix for your issue, please provide exact steps to reproduce.
May be you can try with the fresh new workspace / clean SDK install etc, may be there are some 3rd party plugins breaking JDT, may be something Mac / Mac JDK specific.

@iloveeclipse iloveeclipse added the needinfo Further information is requested label Sep 20, 2023
@andy-goryachev-oracle
Copy link
Author

Interesting, thank you for looking at this!
Would it be possible to check it on macOS on M1 (arm)?
I'll do a clean install later tonight.

@iloveeclipse
Copy link
Member

Would it be possible to check it on macOS

Not for me, I have no access to any Mac machine.

@andy-goryachev-oracle
Copy link
Author

Don't see the issue with a clean install and a blank project.
Next will try to open a copy of my old workspace.

@SarikaSinha
Copy link
Member

Behaviour on Mac:
I was able to reproduce with existing workspace which had just 1 basic java file.
For same install when I switched to new workspace, this error was not there.

@andy-goryachev-oracle
Copy link
Author

This issue cannot be reproduced when opening (with 2023-09) a clean workspace created with 2023-06.
This indicates that some, possibly much earlier, version leaves the workspace in a state that 2023-09 cannot deal with.

This is still a blocker for migration to 2023-09. Due to corporate restrictions, I cannot attach a copy of the workspace.

@iloveeclipse
Copy link
Member

I guess you can try to regenerate Java index under Preferences / Java. May be some types aren't properly resolved because of broken / not properly updated index?

@andy-goryachev-oracle
Copy link
Author

let me try that, but doesn't 'clean all projects' should take care of everything?

@iloveeclipse
Copy link
Member

No, index is independent from "clean". There are also such things like shared JDK / library symbols etc

@andy-goryachev-oracle
Copy link
Author

[rebuild index] did not help.
is there a specific file or files in the workspace I need to check?

@iloveeclipse
Copy link
Member

No. Please note, you need to wait till index is rebuilt before trying.
If this doesn't help, another possibility to play with advanced lookup preference under Java / Debugger.

@andy-goryachev-oracle
Copy link
Author

waited, even reloaded eclipse.

I respectfully disagree: this is a regression, and a serious one. Pretty much every version since early 2000's could open and work with a workspace created by earlier versions (some even upgraded multiple times) with no issues, at least on my memory. I know it's a complex system, we are also dealing with ever increasing entropy in the Universe, but still - it's a blocker.

What can I do to escalate?

@iloveeclipse
Copy link
Member

What can I do to escalate?

Well, if your organization is member of Eclipse IDE working group, you could ask your representative in that group to raise the priority of this issue on the next IDE WG meeting.

Or you can ask your organization to hire some developer to debug & fix this issue.

@andy-goryachev-oracle
Copy link
Author

Unfortunately, my organization is not a member of Eclipse IDE working group.

@jukzi
Copy link
Contributor

jukzi commented Feb 14, 2024

How to Become a Member:
https://eclipseide.org/membership/

@alerosmile
Copy link

Same here with 2023-12. I get this if the application is started as modular only. That is if the application is modular itself or inside a workspace dependency if it is modular.

@andy-goryachev-oracle
Copy link
Author

How to Become a Member:

not an option for my org, unfortunately.

@andy-goryachev
Copy link

That is if the application is modular itself or inside a workspace dependency if it is modular.

Thank you, you might be on something!
This was the case for the original report. The other project I tried wasn't a modular one.

@andy-goryachev
Copy link

@iloveeclipse
please remove [needinfo] label. the issue is still present in 2024-03 version, and as @alerosmile mentioned it occurs in any modular project.

@iloveeclipse
Copy link
Member

@iloveeclipse please remove [needinfo] label. the issue is still present in 2024-03 version, and as @alerosmile mentioned it occurs in any modular project.

I don't see exact steps to reproduce yet, sorry. If someone can provide something that I (or anyone else) would be able to reproduce, I would remove "needinfo".

@andy-goryachev-oracle
Copy link
Author

andy-goryachev-oracle commented Apr 5, 2024

okay, here are the steps:

  1. macOS 14.4.1 on M1
  2. launch eclipse 2024-03
  3. create a brand new workspace
  4. create a new java project (see a screenshot later in the comments)
  5. create a new java class (screenshot, code later in the comments)
  6. set a breakpoint on line 10.
  7. debug (screenshot)

observe the error:

java.lang.IllegalStateException: The method entrySet() is undefined for the type Map___
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure$EvaluationBlock.log(JavaLogicalStructure.java:194)
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure$EvaluationBlock.evaluate(JavaLogicalStructure.java:143)
	at org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructure.getLogicalStructure(JavaLogicalStructure.java:317)
	at org.eclipse.debug.internal.ui.views.variables.LogicalStructureCache$LogicalStructureTypeCache.getLogicalStructure(LogicalStructureCache.java:143)
	at org.eclipse.debug.internal.ui.views.variables.LogicalStructureCache.getLogicalStructure(LogicalStructureCache.java:56)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getLogicalValue(VariableContentProvider.java:211)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getLogicalValue(VariableContentProvider.java:111)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getValueChildren(VariableContentProvider.java:128)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getAllChildren(VariableContentProvider.java:76)
	at org.eclipse.jdt.internal.debug.ui.variables.JavaVariableContentProvider.getAllChildren(JavaVariableContentProvider.java:143)
	at org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.getChildCount(VariableContentProvider.java:48)
	at org.eclipse.jdt.internal.debug.ui.variables.JavaVariableContentProvider.getChildCount(JavaVariableContentProvider.java:73)
	at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider.retrieveChildCount(ElementContentProvider.java:122)
	at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider$2.run(ElementContentProvider.java:76)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

@andy-goryachev-oracle
Copy link
Author

here is the complete test case:

ModularTest.zip

@andy-goryachev-oracle
Copy link
Author

tried with eclipse-SDK-4.32M1-macosx-cocoa-aarch64.dmg
copied from .dmb to an empty directory, launched from there, opened the workspace.

same issue. I think, as @alerosmile has identified, the issue might be caused by a modular project (notice module-info.java in the zip I've sent earlier).

Screenshot 2024-04-08 at 11 51 26

@iloveeclipse
Copy link
Member

Thanks, I can't promise but I will try to debug this this week.

@andy-goryachev
Copy link

many thanks indeed!

@alerosmile
Copy link

@andy-goryachev-oracle: Can you please confirm that this issue doesn't exist with Eclipse 2023-06?

@andy-goryachev-oracle
Copy link
Author

Yes, it works with built-in JDK17 and JDK21, using Eclipse 4.28.0.20230608-1200 downloaded from
https://www.eclipse.org/downloads/packages/release/2023-06/r

Screenshot 2024-04-09 at 08 01 16

@alerosmile
Copy link

Changing this line to OPTION_JdtDebugCompileMode will fix the error.

But as stated in this commit, this option seems to cause side effects I don't have knowledge of.

@iloveeclipse iloveeclipse added the regression Regression from previous release label Apr 11, 2024
@iloveeclipse
Copy link
Member

OK, finally got time to test the reproducer.
I confirm this is easily reproducible, and related to #260 change.

What was surprising for me: if testing in a Java perspective (with Variables view not activated), the hover over variables shows proper (but not "logical") content without errors.
Only after opening Variables view the hover "remembers" it should actually show logical structures and starts to misbehave. So we have another bug here, but that's not important one.

@alerosmile
Copy link

Isn't that intentional? If I change the option in the Variables view, the way the data is displayed on the hover should change as well.
image

@iloveeclipse
Copy link
Member

Yes, but the hover should be able to understand that preference, if it is set, without Variables view being active.
But please let us discuss the original issue, my fault to add this observation here.

Looking on the code in debugger I see that the two options used differently (well, they are different :-)).

https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java#L219

https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java#L221

@stephan-herrmann : your brain is needed, as it is all about #260 and OPTION_IgnoreUnnamedModuleForSplitPackage not being enough to replace OPTION_JdtDebugCompileMode.

May I ask you to look into this issue? Example self contained project is in https://github.com/eclipse-jdt/eclipse.jdt.debug/files/14909705/ModularTest.zip

@stephan-herrmann
Copy link
Contributor

@stephan-herrmann : your brain is needed, as it is all about #260 and OPTION_IgnoreUnnamedModuleForSplitPackage not being enough to replace OPTION_JdtDebugCompileMode.

May I ask you to look into this issue? Example self contained project is in https://github.com/eclipse-jdt/eclipse.jdt.debug/files/14909705/ModularTest.zip

ack

@stephan-herrmann
Copy link
Contributor

Any chance to debug this in a JUnit test case?

I briefly looked if I could create that test case, but after finding JDT Debug Evaluation Test Suite.launch as the most promising point to start from, I couldn't even get that launch configuration to run any tests. A fresh workbench window opens, and all it does is wait for user input.

@stephan-herrmann
Copy link
Contributor

Initial compile error:
The package java.util is accessible from more than one module: ModularTest, java.base

So, contrary to what we discussed in eclipse-jdt/eclipse.jdt.core#445 the requirement by JDT/Debug is not just about allowing an unnamed/named module conflict, but also a conflict between two named modules should be ignored, right?

The former would be covered by OPTION_IgnoreUnnamedModuleForSplitPackage but the latter would never be acceptable during compilation proper, and hence no user-visible option will sanction this situation.

Is it a hard requirement in JDT/Debug to place the synthetic type Map___ into package java.util and into the current JavaProject? This obviously violates a few Java rules, unless we could tweak the structure in a way that options like --patch-module could be used.

I would indeed prefer a solution that could be made legal wrt JPMS.

If that fails, going back to and fixing OPTION_JdtDebugCompileMode would be a pragmatic approach.

@stephan-herrmann
Copy link
Contributor

I would indeed prefer a solution that could be made legal wrt JPMS.

I didn't find an easy solution down this path.

If that fails, going back to and fixing OPTION_JdtDebugCompileMode would be a pragmatic approach.

See eclipse-jdt/eclipse.jdt.core#2340

@iloveeclipse
Copy link
Member

@stephan-herrmann : once again, many thanks!

Tomorrow I-build on https://download.eclipse.org/eclipse/downloads/ should have the fix for the ticket.

@stephan-herrmann
Copy link
Contributor

@stephan-herrmann : once again, many thanks!

You're welcome 😄
... and sorry for proposing the use of OPTION_IgnoreUnnamedModuleForSplitPackage in the first place.

@iloveeclipse
Copy link
Member

Verified, works fine with I20240414-1800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression from previous release
Projects
None yet
7 participants