| Summary: | [1.9] Allow diamond with anonymous classes | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Jay Arthanareeswaran <jarthana> |
| Component: | Core | Assignee: | Sasikanth Bharadwaj <sasikanth.bharadwaj> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | manoj.palat, markus.kell.r, sasikanth.bharadwaj, stephan.herrmann |
| Version: | 4.5.1 | Flags: | sasikanth.bharadwaj:
review?
(stephan.herrmann) |
| Target Milestone: | BETA J9 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| See Also: |
https://git.eclipse.org/r/78691 https://git.eclipse.org/r/83111 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=8f0eb26398d5c8dde9ae3b5affe939426eea53ca https://git.eclipse.org/r/85256 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=cfc8f74b9c8820b855dd3ffbed748d7233058b28 |
||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 495954 | ||
|
Description
Jay Arthanareeswaran
New Gerrit change created: https://git.eclipse.org/r/78691 New Gerrit change created: https://git.eclipse.org/r/83111 Stephan, please take a look at the change. I'm not sure about a couple of things with this. 1. In AllocationExpression.inferDiamondCOnstructor, the special handling if allocationType isInterface - would it be better to add the no-arg constructor to the PTB and proceed with sfmb.applyTypeArgumentsOnConstructor? 2. All non-private instance methods in an anonymous class using '<>' must be treated as if they are annotated with @override. To achieve this, I'm setting the TagBits.AnnotationOverride bit on the method. Would it be better to handle this in the MethodDeclaration.resolve instead? 3. Have I covered everything? :-) Thanks in advance for your time I wonder why genie did not comment on this bug - I released the change as a first cut implementation so that we will have a build with this feature to demo, leaving the bug open for follow up actions comments Released via commit http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA9&id=8f0eb26398d5c8dde9ae3b5affe939426eea53ca One more thing I'm not sure about that I forgot to mention in earlier comment I assumed redundant type argument specification check would now apply for anonymous diamond too - does that hold? Gerrit change https://git.eclipse.org/r/83111 was merged to [BETA_JAVA9]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=8f0eb26398d5c8dde9ae3b5affe939426eea53ca Y20161110-1000
A "Redundant specification of type arguments" problem is wrongly reported for anonymous types in 1.8 mode:
package p;
import java.util.Comparator;
public class C {
Comparator<String> comparator = new Comparator<String>() { //
@Override
public int compare(String o1, String o2) {
return 0;
}
};
}
This causes various compile errors in platform.ui projects.
The new analysis must only be active for source level >= 9. I'm surprised that we don't have a test case for this in Java 7 or 8 mode.
New Gerrit change created: https://git.eclipse.org/r/85256 Gerrit change https://git.eclipse.org/r/85256 was merged to [BETA_JAVA9]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=cfc8f74b9c8820b855dd3ffbed748d7233058b28 (In reply to comment #7) > The new analysis must only be active for source level >= 9. I'm surprised that > we don't have a test case for this in Java 7 or 8 mode. Thanks Markus. Now we do. Bug 506952 comment 3 identifies some tests that fail when run with JDK9 because of change in behavior w.r.t diamond in anonymous class declarations. Fixed these failures via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA9&id=30f7fbb7f1e3845d31ba25b4ce8dc4eb4bcb844e |