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

Bug 409244

Summary: [1.8][compiler] Type annotations on redundant casts dropped.
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: 4.3   
Target Milestone: BETA J8   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 409235    

Description Srikanth Sankaran CLA 2013-05-28 03:54:18 EDT
BETA_JAVA8:

"If the compiler eliminates an annotated cast, it is required to retain the 
annotations on the cast in the class file (if the annotation type has at least 
RetentionPolicy.CLASS retention). When a cast is removed, the compiler may need 
to adjust (the locations of) the annotations, to account for the relationship between the expression’s type and the casted-to type. Consider:" ...

At the moment ECJ is not in compliance here.
Comment 1 Srikanth Sankaran CLA 2013-05-28 03:54:39 EDT
Andy, thanks for following up.
Comment 2 Andrew Clement CLA 2013-06-11 18:08:11 EDT
I have a partial implementation - the simple cases work but generic casts are the problem. Before I can finish it I'm waiting on confirmation of a spec query on jsr308-discuss:

https://groups.google.com/forum/?fromgroups#!topic/jsr308-discuss/_oa82wxTKpc
Comment 3 Srikanth Sankaran CLA 2013-08-05 01:58:30 EDT
(In reply to comment #2)
> I have a partial implementation - the simple cases work but generic casts
> are the problem. Before I can finish it I'm waiting on confirmation of a
> spec query on jsr308-discuss:
> 
> https://groups.google.com/forum/?fromgroups#!topic/jsr308-discuss/_oa82wxTKpc

Andy, I would be happy with a solution that simply always emits a runtime
cast if the cast carries an annotation. I do not believe it is a big deal
to emit a cast in this situations. We can always raise a follow up defect to
implement the fuller solution and tackle it at leisure.

What do you think ?
Comment 4 Andrew Clement CLA 2013-08-06 12:39:42 EDT
Yes, I was coming to the same conclusion.
Comment 5 Srikanth Sankaran CLA 2013-08-07 08:22:35 EDT
(In reply to comment #4)
> Yes, I was coming to the same conclusion.

Great, in that case do you want to propose a patch - org.eclipse.jdt.internal.compiler.ast.CastExpression.tagAsNeedCheckCast() should
be useful it looks like.

If you are very busy this week otherwise, I can wrap this up. I am keen to 
drive down the open issues count for 308.
Comment 7 Andrew Clement CLA 2013-08-19 11:29:17 EDT
Thanks for getting to this Srikanth, sorry I didn't manage to find the time.