Bug 565677 - Detail formatters encounter classloading-related issues
Summary: Detail formatters encounter classloading-related issues
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.16   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-29 20:16 EDT by Greg Merrill CLA
Modified: 2022-06-17 03:29 EDT (History)
3 users (show)

See Also:


Attachments
screenshot1 (63.07 KB, image/png)
2020-07-29 20:17 EDT, Greg Merrill CLA
no flags Details
screenshot2 (74.42 KB, image/png)
2020-07-29 20:17 EDT, Greg Merrill CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Merrill CLA 2020-07-29 20:16:48 EDT
Detail formatters encounter classloading-related issues which prevent them from rendering properly.  Consider this sample program:




package test;

import java.util.Calendar;

public class Test {

	public static void main(String[] args) {
		Calendar cal = Calendar.getInstance();
		System.out.println(cal);
	}
	
}


And this detail formatter:

java.text.SimpleDateFormat fmt = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
fmt.setTimeZone(this.getTimeZone());
return fmt.format(this.getTime()) + " " + this.getTimeZone().getID();


This produces the following error from the detail formatter:

Detail formatter error:
		The method getTimeZone() from the type GregorianCalendar refers to the missing type TimeZone
		The method getTime() is undefined for the type GregorianCalendar
		The method getTimeZone() from the type GregorianCalendar refers to the missing type TimeZone



However, the same essential expression works fine in a Debug Shell:

java.text.SimpleDateFormat fmt = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
fmt.setTimeZone(cal.getTimeZone());
fmt.format(cal.getTime()) + " " + cal.getTimeZone().getID();
Comment 1 Greg Merrill CLA 2020-07-29 20:17:19 EDT
Created attachment 283741 [details]
screenshot1
Comment 2 Greg Merrill CLA 2020-07-29 20:17:37 EDT
Created attachment 283742 [details]
screenshot2
Comment 3 Greg Merrill CLA 2020-07-29 20:18:50 EDT
Note - we are using:

openjdk version "13.0.2" 2020-01-14
Comment 4 Tom Zauner CLA 2021-10-19 08:07:04 EDT
Same here with openjdk11.

Detail formatter has java.util.GregorianCalender: this.getTime()

Following error is displayed: 
Detail formatter error:
		The method getTime() is undefined for the type GregorianCalendar


Also happens with eclipse 2021/09.
Comment 5 Sarika Sinha CLA 2021-10-19 14:52:36 EDT
Can reproduce the same with the latest Java 17 also.

Problem is in the ability to add the methods of super class Calendar to the GregorianCalendar.

Even the content assist does not show these methods in the detail Formatter snippet area.
Comment 6 Christian Fröhlich CLA 2022-06-17 03:29:03 EDT
The problem still persists in the current version 2022-03 and JDK11. I have found a workaround for the GregorianCalendar with:

String str = this.toString();

String[] arr = str.split(",");

String year = arr[29].split("=")[1];
String month = arr[30].split("=")[1];
String day = arr[33].split("=")[1];
String hour = arr[39].split("=")[1];
String minute =  arr[40].split("=")[1];
String second =  arr[41].split("=")[1];

return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;