Bug 258905

Summary: making java.lang.AssertionError accessible thru resolveWellKnownType method
Product: [Eclipse Project] JDT Reporter: Zsolt Thalmeiner <thaliga>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: Olivier_Thomann, srikanth_sankaran
Version: 3.4.2   
Target Milestone: 3.7 M2   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch for requested enhancement
none
Proposed fix none

Description Zsolt Thalmeiner CLA 2008-12-16 04:29:12 EST
Created attachment 120547 [details]
patch for requested enhancement

We are building control flow graphs from Java sources using the Eclipse AST. In the case of assert statement we have to simulate an AssertionError exception. Unfortunately there is no binding information available about the AssertionError class in the AST if the class was not explicitly referenced.

The patch I'm attached to this enhancement proposal contains the solution of this problem. It is a two-line modification of DefaultBindingResolver.resolveWellKnownType method.
Comment 1 Olivier Thomann CLA 2010-08-05 17:39:08 EDT
Will consider for 3.7M2.
AssertionError are linked to the assert statement and as is it mihgt be interesting to expose it as a well known type binding.
Of course javadoc also needs to be updated.
Comment 2 Olivier Thomann CLA 2010-08-31 16:07:41 EDT
Created attachment 177882 [details]
Proposed fix
Comment 3 Olivier Thomann CLA 2010-08-31 16:08:23 EDT
Released for 3.7M2.
Added regression test in:
org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#test0719
Comment 4 Srikanth Sankaran CLA 2010-09-14 05:21:52 EDT
I noticed two issues with the patch:

1. TESTS_NUMBERS stands uncommented.
2. In the chunk of code below:

+			// none of the well known bindings resolve in a plain AST
+			for (int i = 0; i<wkbs.length; i++) {
+				assertNotNull("No binding for " + wkbs[i], currentAst.resolveWellKnownType(wkbs[i]));
+			}
+
+			// none of the no so well known bindings resolve either
+			for (int i = 0; i<nwkbs.length; i++) {
+				assertNull("Binding for " + nwkbs[i], currentAst.resolveWellKnownType(nwkbs[i]));
+			}

I think the first comment is wrong.

Verified for 3.7 M2 by code inspection.
Comment 5 Olivier Thomann CLA 2010-09-14 07:46:51 EDT
(In reply to comment #4)
> I noticed two issues with the patch:
> 1. TESTS_NUMBERS stands uncommented

> 2. In the chunk of code below:
> I think the first comment is wrong.

I'll fix both problems.
Comment 6 Olivier Thomann CLA 2010-09-14 07:49:38 EDT
Done. We will contribute again to fix this issue.