Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354427 - Overridden @PC @PD methods do not get called if the overridden version is not annotated
Summary: Overridden @PC @PD methods do not get called if the overridden version is not...
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.1   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-10 14:37 EDT by Remy Suen CLA
Modified: 2011-10-05 16:04 EDT (History)
2 users (show)

See Also:


Attachments
Context tests patch v1 (3.01 KB, patch)
2011-08-11 08:04 EDT, Remy Suen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2011-08-10 14:37:47 EDT
If a class defines @PreConstruct and @PreDestroy methods but they get overridden and their overridden versions are not annotated with those annotations then they do not get called.
Comment 1 Remy Suen CLA 2011-08-11 08:04:55 EDT
Created attachment 201309 [details]
Context tests patch v1
Comment 2 Oleg Besedin CLA 2011-10-03 10:55:15 EDT
After looking into it in more details, the current behavior is in line with the JSR 330.

The JSR does not define PreConstruct / PostDestory annotations, however, it goes into some details for the @Inject annotation.

For @Inject annotations it specifies that overridden methods (overridden in the Java language sense) that do not have "@Inject" annotation should be treated as if they remove the "@Inject" annotation from the method definition.

See, for instance, test  
 Convertible.Tests.testProtectedMethodNotInjectedWhenOverrideNotAnnotated()
in the TCK.
Comment 3 Paul Webster CLA 2011-10-05 15:13:30 EDT
Remy, do we have examples in our own code that show this problem?  Or do we have API (more or less :-) where we expect the client to subclass (and would need to explicitly tell them in javadoc they *must* extend that method)?

PW
Comment 4 Remy Suen CLA 2011-10-05 16:04:11 EDT
(In reply to comment #3)
> Remy, do we have examples in our own code that show this problem?  Or do we
> have API (more or less :-) where we expect the client to subclass (and would
> need to explicitly tell them in javadoc they *must* extend that method)?

None of our DI'd objects are API (they're usually just interfaces instead of abstract classes).

For protected and public methods we usually explicitly say whether the client should _extend_ or _override_ it with their own implementations.