Community
Participate
Working Groups
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...
If you could boil this down to a simple sample project it would help debug the problem.
Created attachment 174267 [details] Projects that expose the bug Two eclipse projects that expose the bug.
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
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".
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?
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.
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.
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.
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.
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.