Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 391201 - [1.8][compiler] Compiler fails to reject type annotations at 1.7-
Summary: [1.8][compiler] Compiler fails to reject type annotations at 1.7-
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: BETA J8   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 287648
  Show dependency tree
 
Reported: 2012-10-05 04:43 EDT by Srikanth Sankaran CLA
Modified: 2012-10-09 10:43 EDT (History)
0 users

See Also:


Attachments
Proposed fix (16.40 KB, patch)
2012-10-08 11:34 EDT, Jay Arthanareeswaran CLA
no flags Details | Diff
Updated patch (15.88 KB, patch)
2012-10-09 06:27 EDT, Jay Arthanareeswaran CLA
no flags Details | Diff
Same patch with minor message rewording (17.04 KB, patch)
2012-10-09 07:17 EDT, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2012-10-05 04:43:11 EDT
BETA_JAVA8:

The following program when built as a 1.7- project but built against
a 1.8 JRE compiles fine. It should not as it uses type annotations.

// -----------
public class X< T> {
	@Marker int foo() {
		return 0;
	}
}

@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_USE)
@interface Marker {
}
Comment 1 Jay Arthanareeswaran CLA 2012-10-08 11:34:00 EDT
Created attachment 222027 [details]
Proposed fix

This patch contains fix for this bug and bug 391196, bug 391314 and bug 391315.

New tests have been added and some existing tests have been rewritten for bug 391314. The new test AnnotationTest.testBug391201() fails in 1.8 compliance level. I still have to find an appropriate place that only runs below 1.8.

Srikanth, please review.
Comment 2 Srikanth Sankaran CLA 2012-10-09 02:06:50 EDT
Here are some comments:

    - Let us merge messages 649 and 652 into one:
"Annotation types that don't specify explicit target element type cannot be applied here" and

    - merge the two methods explitAnnotationTargetRequired and
explitAnnotationTargetRequired2 into the former itself.

    - These two changes allow us to get rid of IProblem and CompilerInvocationTests changes.

    - AnnotationTest#testBug391201 should be moved to ComplianceDiagnoseTest
Comment 3 Srikanth Sankaran CLA 2012-10-09 02:18:27 EDT
Sorry for the truncated message:

Here are some comments:

    - Let us merge messages 649 and 652 into one:
"Annotation types that don't specify explicit target element type cannot be applied here" and

    - merge the two methods explitAnnotationTargetRequired and
explitAnnotationTargetRequired2 into the former itself.

    - These two changes allow us to get rid of IProblem and CompilerInvocationTests changes.

    - AnnotationTest#testBug391201 should be moved to ComplianceDiagnoseTest
This test should not be run on 1.8+

    - Expected message for 1.7- is wrong, it should print a message saying
type annotations are illegal at source below 1.8
Comment 4 Jay Arthanareeswaran CLA 2012-10-09 06:27:51 EDT
Created attachment 222058 [details]
Updated patch

This patch incorporates changes suggested in the previous comment.
All Java 8 tests pass will report after running all the tests.
Comment 5 Srikanth Sankaran CLA 2012-10-09 07:17:23 EDT
Created attachment 222063 [details]
Same patch with minor message rewording

All Java8 tests pass. Jay, please release and remember to close all bugs.
Checkin comment should mention all 4 bug and in each mention the cumulative
fix has been released mentioning commit id - Thanks!