Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 445671

Summary: Any Detail Formatter for java.io.File seems to fail at execution
Product: [Eclipse Project] JDT Reporter: Kevin Lubick <kjlubick>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: CLOSED INVALID QA Contact:
Severity: minor    
Priority: P3 CC: Michael_Rennie
Version: 4.3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 8   
Whiteboard:
Attachments:
Description Flags
Screenshot of problem
none
output of unit.toString() for working ArrayList detail formatter
none
output of unit.toString() for broken File detail formatter none

Description Kevin Lubick CLA 2014-10-01 10:32:00 EDT
I've normally had good luck with the DetailFormatters in the debugging pane.  However, when I tried to make one for java.io.File, no matter what I put in I always get "Detail formatter error: Evaluations must contain either an expression or a block of well-formed statements" on execution.

For example, `return String.format("%s",toString());` should be valid, but trips up java.io.File.

The unusual part is that same code works fine for other types, just not File.

To be clear, I reached this by making the DetailFormatter, stopping running code at a breakpoint and attempting to view the file.
Comment 1 Michael Rennie CLA 2014-10-20 11:41:32 EDT
This is working for me using Mars (4.5) I20141014-0800 with the formatter:

return String.format("%s",toString());

and the snippet:

import java.io.File;

public class Bug {
	public static void main(String[] args) {
		File f = new File("foobar");
		System.out.println(f); //bp here
	}
}

Kevin, can you try a newer version of Eclipse to see if the problem persists? Also could you attach any exceptions from the error log / snippets / steps that might help us reproduce the failure?
Comment 2 Kevin Lubick CLA 2014-10-20 14:10:01 EDT
Created attachment 248026 [details]
Screenshot of problem
Comment 3 Kevin Lubick CLA 2014-10-20 14:10:57 EDT
I can still reproduce it in Kepler, but I didn't see anything in the Error log.

I followed basically the same steps as you did - run code in debug up to a break point (I tried your sample as well, and the problem still sufficed), go enable a detail formatter from the Variables view by right clicking on the File f.  

I was also able to reproduce it on (vanilla) Luna Service Release 1 (4.4.1).

I was also able to reproduce it on a (vanilla) Version: Mars Milestone 2 (4.5.0M2)
Build id: 20141002-0151 installation.


This was on the 32bit installation, on Windows 8.1, running the 64bit 1.7.0_67-b01 version of Java.

I've attached a screenshot of the problem in Mars.
Comment 4 Kevin Lubick CLA 2014-10-20 15:31:59 EDT
I did a little digging through use of creative breakpoint and compared the broken File code with a working example, specifically at at ASTEvaluationEngine.java -> createExpressionFromAST(String snippet, EvaluationSourceGenerator mapper, CompilationUnit unit) 

I'll attach the full compilation unit dump in a minute

unit.getProblems() from working: [Pb(2) java cannot be resolved to a type, Pb(233) Syntax error on tokens, delete these tokens, Pb(233) Syntax error on tokens, delete these tokens, Pb(233) Syntax error on tokens, delete these tokens, Pb(231) Syntax error on token ">", { expected after this token, Pb(240) Syntax error, insert "}" to complete Block, Pb(105) Void methods cannot return a value]

unit.getProblems() from broken file detailFormatter: [Pb(236) Syntax error on token(s), misplaced construct(s), Pb(2) java cannot be resolved to a type, Pb(236) Syntax error on token(s), misplaced construct(s), Pb(240) Syntax error, insert "}" to complete Block, Pb(232) Syntax error on token "void", delete this token, Pb(105) Void methods cannot return a value, Pb(232) Syntax error on token "}", delete this token, Pb(204) Syntax error on token "boolean", @ expected, Pb(240) Syntax error, insert "enum Identifier" to complete EnumHeader, Pb(204) Syntax error on token "int", new expected, Pb(232) Syntax error on token "}", delete this token, Pb(756) The type PathStatus may not subclass Enum<File.PathStatus> explicitly, Pb(526) Bound mismatch: The type File.PathStatus is not a valid substitute for the bounded parameter <E extends Enum<E>> of the type Enum<E>, Pb(236) Syntax error on token(s), misplaced construct(s), Pb(240) Syntax error, insert ";" to complete Statement, Pb(240) Syntax error, insert "}" to complete MethodBody]

"Pb(232) Syntax error on token "void", delete this token" and "Pb(232) Syntax error on token "}", delete this token" are considered runMethodErrors, causing the problem we see.
Comment 5 Kevin Lubick CLA 2014-10-20 15:32:46 EDT
Created attachment 248027 [details]
output of unit.toString() for working ArrayList detail formatter
Comment 6 Kevin Lubick CLA 2014-10-20 15:33:33 EDT
Created attachment 248028 [details]
output of unit.toString() for broken File detail formatter
Comment 7 Kevin Lubick CLA 2014-11-19 11:37:48 EST
As it turns out, my Eclipse somehow was pointing to the JRE instead of the JDK.  Switching back has resolved this issue.