| Summary: | [javadoc] AccessRestriction compiler error in JavaDoc | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Jochen Hiller <jochen.hiller> | ||||||||
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> | ||||||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||||||
| Severity: | minor | ||||||||||
| Priority: | P3 | CC: | b.kolb, eric_jodet, frederic_fusier, jerome_lanneluc | ||||||||
| Version: | 3.3 | ||||||||||
| Target Milestone: | --- | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Windows XP | ||||||||||
| Whiteboard: | stalebug | ||||||||||
| Attachments: |
|
||||||||||
(In reply to comment #0) > 3. Now add to bundle an import for "org.osgi.service.log". --> why not add org.osgi.service.http (which is the correct location of HttpService) instead of org.osgi.service.log? > Now I will get an AccessRestriction compiler error for > org.osgi.service.http.HttpService. --> works as designed: I'll attach a screen shot where you'll notice the access rules once import org.osgi.service.log is added to the MANIFEST.MF. To fix the 2 errors: - remove the "org.osgi.service.log" from the import section of the MANIFEST.MF. - add org.osgi.service.http import to the MANIFEST.MF. - save your changes --> no error, no warning on the Javadoc link. My MANIFEST.MF reads: Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: TestBug204234 Plug-in Bundle-SymbolicName: testBug204234 Bundle-Version: 1.0.0 Bundle-Activator: testbug204234.Activator Import-Package: org.osgi.framework;version="1.3.0", org.osgi.service.http;version="1.2.0" Eclipse-LazyStart: true Created attachment 78949 [details]
[screen shot] access rules for org.osgi.service.log
#2: To fix the 2 errors: - remove the "org.osgi.service.log" from the import section of the MANIFEST.MF. - add org.osgi.service.http import to the MANIFEST.MF. - save your changes --> no error, no warning on the Javadoc link. Sure, thats not the problem. My requirement is, that I refer in class comment to a class, which is currently not visible. Thats OK, because I really do NOT use the HttpService, I only want to refer to it in the comment. Did I miss some (PDE or JDT) compiler settings, where I can set this behaviour ? In general, its OK to get an AccessRestriction when writing code, but not when writing a comment. Sorry, forgot to mention: when referring to HttpService in commment without import of org.osgi.service.log, I do NOT get a compile error. It only happens, when I added another import to bundle (additionally to org.osgi.framework). (In reply to comment #3 and comment #4) 2 way to get rid of the problems: 1 - Fix the javadoc broken link issue: (remove the org.osgi.service.log import) Edit project's properties Go to: Java Compiler --> Javadoc - check the "Enable project specific settings" to override default settings - Uncheck "Report errors in tags" option - click OK then Yes to rebuild. --> the javadoc warning should be cleared 2 - Fix the compile errors (with the org.osgi.service.log import added to the manifest): Edit project's properties Go to: Java Compiler --> Errors / Warnings and expand the Deprecated and Restricted API section. Set the Forbidden reference (access rules) to "ignore" - click OK then Yes to rebuild. --> the 2 compile errors should be cleared. Hi, I want to clarify the problem better.
I am using this code. See comment within Activator class, why I refer to another class. This code will produce the compiler error about AccessRestriction.
--- MANIFEST.MF ---
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bug_javadoc Plug-in
Bundle-SymbolicName: bug_javadoc
Bundle-Version: 1.0.0
Bundle-Activator: bug_javadoc.Activator
Import-Package: org.osgi.framework;version="1.3.0",
org.osgi.service.log;version="1.3.0"
Eclipse-LazyStart: true
--- MANIFEST.MF ---
--- bug_javadoc.Activator.jar ---
package bug_javadoc;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
/**
* For whatever reason, I want to refer to a class
* {@link org.osgi.service.http.HttpService} which is not visible in current
* bundle. I know, this would produce an error when using JavaDoc, but it is yet
* very annoying that I get this message in my IDE.
*/
public class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception {
// simplified example
int i = LogService.LOG_DEBUG;
}
public void stop(BundleContext context) throws Exception {
}
}
--- bug_javadoc.Activator.jar ---
When I remove usage of LogService:
--- MANIFEST.MF ---
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bug_javadoc Plug-in
Bundle-SymbolicName: bug_javadoc
Bundle-Version: 1.0.0
Bundle-Activator: bug_javadoc.Activator
Import-Package: org.osgi.framework;version="1.3.0"
Eclipse-LazyStart: true
--- MANIFEST.MF ---
--- bug_javadoc.Activator.jar ---
package bug_javadoc;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
* For whatever reason, I want to refer to a class
* {@link org.osgi.service.http.HttpService} which is not visible in current
* bundle. I know, this would produce an error when using JavaDoc, but it is yet
* very annoying that I get this message in my IDE.
*/
public class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception {
}
public void stop(BundleContext context) throws Exception {
}
}
--- bug_javadoc.Activator.jar ---
I will NOT get any compile errors. And THATS strange !!!
(In reply to comment #6) OK, I see your point now (sorry for the delay). Even when not validating the Javadoc, the error is still here. The JavadocParser should use its own (to be created) method in order to report the access restriction issue only when "Report errors in tags" is enabled. So that, once this bug fixed, your code as proposed in comment #6 will have no error with: - the compiler option "Deprecated and Restricted API" set to error, - the "Report errors in tags" disabled. Created attachment 78966 [details]
[test case]
Project demonstrating the issue.
Created attachment 103110 [details]
[proposed patch + test cases] on top v_871
When access restricted types are referenced inside javadoc, use a (new) dedicated javadoc message instead of the compiler error.
This new javadoc message will be displayed depending on javadoc validation settings (visibility, tag arguments validation, ...)
Not sure I'll have enough time to fix the proposed patch which contains some problem, hence need some extra work to be finalized... Satyam, please investigate. Thanks. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Build ID: 3.3 Steps To Reproduce: 1. Create a new bundle project, target Equinox, create Activator. The bundle manifest includes imports from org.osgi.framework 2. Add for Activator a javadoc for class. Add within JavaDoc a "{@link org.osgi.service.http.HttpService}" reference. Everything is fine 3. Now add to bundle an import for "org.osgi.service.log". Now I will get an AccessRestriction compiler error for org.osgi.service.http.HttpService. More information: I think wrong JavaDoc entries, even when classes are not visible should be acceptable. And if there are no additional imports, it seems to work as I would expect.