Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319087 - Detail formatter could not resolve existing type
Summary: Detail formatter could not resolve existing type
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.6   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-07 04:28 EDT by Ulli Hafner CLA
Modified: 2019-11-14 08:31 EST (History)
2 users (show)

See Also:


Attachments
Projects that expose the bug (2.05 KB, application/octet-stream)
2010-07-14 04:46 EDT, Ulli Hafner CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ulli Hafner CLA 2010-07-07 04:28:52 EDT
Build-ID: I20100608-0911

I tried to add a detail formatter for a new type but I always getting the following error in the variables view, display or when hovering over the corresponding element:

Detail formatter error: could not resolve type

Usecase 1: 
- I'm running my RCP application within the debugger
- In the Display view I'm inspecting an object 'individual' that is of type uk.ac.manchester.cs.owl.owlapi.OWLNamedIndividualImpl. That type comes from a bundle owlapi. 
- Then I have a static formatter method de.faktorlogik.core.util.Ontology.toString that accepts a OWLNamedIndividualImpl as a parameter. This type is in another bundle faktorlogik.core (that has a dependency to owlapi).
- When adding the new formatter, then code completion correctly works, it resolves all types.
- When I'm executing the following expression in the Display view, then everything is correctly printed:

de.faktorlogik.core.util.Ontology.toString(individual)
	 (java.lang.String) from root individual with betrifft to Antennenanlage

- However, when I'm executing the following expression in the Display view, then an error occurs:

individual
	 (uk.ac.manchester.cs.owl.owlapi.OWLNamedIndividualImpl) Detail formatter error:
		could not resolve type: de.faktorlogik.core.util.Ontology

There is neither an exception on the console or error log. Is there a way (logging level) to get more details about this exception? 

Usecase 2: 
When I'm debugging the same classes using a Junit test (not a JUnit plug-in test) then the details formatter works, so this might be a OSGi class loading problem...
Comment 1 Darin Wright CLA 2010-07-12 14:50:48 EDT
If you could boil this down to a simple sample project it would help debug the problem.
Comment 2 Ulli Hafner CLA 2010-07-14 04:46:03 EDT
Created attachment 174267 [details]
Projects that expose the bug

Two eclipse projects that expose the bug.
Comment 3 Ulli Hafner CLA 2010-07-14 04:51:17 EDT
You can reproduce the bug with the following steps:

1. Debug the FormatterTest as a unit test (or plug-in unit test)
2. Stop with a breakpoint at line 12
3. Add a new detail formatter for the selected variable 'demo'
4. Enter 'java.lang.String' as FQN
5. Enter 'formatter.Formatter.format(this)' as snippet
6. After pressing ok, the Variables view shows the error 

Detail formatter error:
		could not resolve type: formatter.Formatter
Comment 4 Darin Wright CLA 2010-07-14 09:51:50 EDT
This is because the type "java.lang.String" does not have visibility to "formatter.Formatter".

Detail formatters are compiled/executued in the context of the type the formatter is associated with. Referenced types are retrieved from the classloader assocaited with this type (String). The class loader used to load "java.lang.String" (which is the bootstrap class loader), does not have visibility of the type "formatter.Formatter".
Comment 5 Ulli Hafner CLA 2010-07-14 10:21:23 EDT
I see. But compilation and CRTL-SPACE seems to resolve this type (otherwise you won't be able to close the window). Shouldn't these features be in sync with the dynamic class loading resolution?
Comment 6 Ulli Hafner CLA 2010-07-14 10:26:15 EDT
And one more thing: isn't the main reason for adding a detail formatter the ability to change the toString() formatting of an existing not-changeable type?

I.e., you have a library with type T that has no (good) toString. Then you add a new formatter in your own code that improves the output. That will not work if the library classloader is used.
Comment 7 Darin Wright CLA 2010-07-14 10:50:29 EDT
Yes, unfortunately content assist is not in synch since content assist is project based (not class-loader based).

A system library is associated with one project in the workspace (although it is referenced by many). The java model will pick one project to associate the JRE with.

I agree that it would be nice to synch code assist such that the user cannot create expressions that will not execute, and that it is useful to enhance objects with details... Depending what details you want to add, this is still possible, but having more code in the detail formatter itself, rather than referencing another class to do the formatting.
Comment 8 Gary Levin CLA 2010-09-01 11:57:16 EDT
I have the same problem, but I found that once the detail formatter class is loaded, the error goes away.  So if I open a Watch expression and use the formatter, or if the program has already used the formatter, no error.  I don't understand why Watch works, but Inspect and Variables display does not.

Anyway, people can try that as a work around.
Comment 9 Gary Levin CLA 2010-10-26 11:05:25 EDT
More details.  I had this working fine (with my workaround) and then it stopped.  I had added another project to the workspace.  If the other project is open, my detail formatter expression "cannot be resolved to a type".  Without the other project (which comes alphabetically earlier than the one I am debugging, if that matters), the workaround works again.

This suggests that the classloader used is dependent on more than the type of the expression being formatted.  I am using a static method to format Map and Collections, which should be base classes.



(In reply to comment #8)
> I have the same problem, but I found that once the detail formatter class is
> loaded, the error goes away.  So if I open a Watch expression and use the
> formatter, or if the program has already used the formatter, no error.  I don't
> understand why Watch works, but Inspect and Variables display does not.
> 
> Anyway, people can try that as a work around.
Comment 10 Eclipse Genie CLA 2019-11-14 08:31:16 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.