Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 103110 Details for
Bug 204234
[javadoc] AccessRestriction compiler error in JavaDoc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
[proposed patch + test cases] on top v_871
v05.txt (text/plain), 35.40 KB, created by
Eric Jodet
on 2008-06-02 09:24:50 EDT
(
hide
)
Description:
[proposed patch + test cases] on top v_871
Filename:
MIME Type:
Creator:
Eric Jodet
Created:
2008-06-02 09:24:50 EDT
Size:
35.40 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v >retrieving revision 1.93 >diff -u -r1.93 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 22 Feb 2008 09:49:36 -0000 1.93 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 2 Jun 2008 13:17:27 -0000 >@@ -348,22 +348,25 @@ > // ignore cases where field is used from within inside itself > field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } >- >+ > if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) { > AccessRestriction restriction = > scope.environment().getAccessRestriction(field.declaringClass.erasure()); >- if (restriction != null) { >+ if (restriction != null && (this.bits & ASTNode.InsideJavadoc)== 0) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=204234 >+ // access restriction inside javadoc should have already been warned on Type >+ // @see ASTNode#isTypeUseDeprecated(TypeBinding, Scope) > scope.problemReporter().forbiddenReference(field, this, > restriction.classpathEntryType, restriction.classpathEntryName, > restriction.getProblemId()); > } > } >- >+ > if (!field.isViewedAsDeprecated()) return false; >- >+ > // inside same unit - no report > if (scope.isDefinedInSameUnit(field.declaringClass)) return false; >- >+ > // if context is deprecated, may avoid reporting > if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; > return true; >@@ -375,8 +378,8 @@ > } > > /* Answer true if the method use is considered deprecated. >- * An access in the same compilation unit is allowed. >- */ >+ * An access in the same compilation unit is allowed. >+ */ > public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope, > boolean isExplicitUse) { > // ignore references insing Javadoc comments >@@ -393,7 +396,10 @@ > // warnings, one on type, the other on constructor), because of the 'super()' case. > AccessRestriction restriction = > scope.environment().getAccessRestriction(method.declaringClass.erasure()); >- if (restriction != null) { >+ if (restriction != null && (this.bits & ASTNode.InsideJavadoc)== 0) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=204234 >+ // access restriction inside javadoc should have already been warned on Type >+ // @see ASTNode#isTypeUseDeprecated(TypeBinding, Scope) > scope.problemReporter().forbiddenReference(method, this, > restriction.classpathEntryType, restriction.classpathEntryName, > restriction.getProblemId()); >@@ -427,8 +433,8 @@ > } > > /* Answer true if the type use is considered deprecated. >- * An access in the same compilation unit is allowed. >- */ >+ * An access in the same compilation unit is allowed. >+ */ > public final boolean isTypeUseDeprecated(TypeBinding type, Scope scope) { > > if (type.isArrayType()) { >@@ -448,8 +454,14 @@ > if (refType.hasRestrictedAccess()) { > AccessRestriction restriction = scope.environment().getAccessRestriction(type.erasure()); > if (restriction != null) { >- scope.problemReporter().forbiddenReference(type, this, restriction.classpathEntryType, >- restriction.classpathEntryName, restriction.getProblemId()); >+ if ((this.bits & ASTNode.InsideJavadoc)!= 0) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=204234 >+ // access restriction inside javadoc requires dedicated message >+ scope.problemReporter().javadocForbiddenReference(this.sourceStart, this.sourceEnd, scope.getDeclarationModifiers()); >+ } else { >+ scope.problemReporter().forbiddenReference(type, this, restriction.classpathEntryType, >+ restriction.classpathEntryName, restriction.getProblemId()); >+ } > } > } > >Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v >retrieving revision 1.233 >diff -u -r1.233 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 21 Apr 2008 10:45:21 -0000 1.233 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 2 Jun 2008 13:17:29 -0000 >@@ -376,6 +376,7 @@ > 460 = Empty block should be documented > > ### DOC >+461 = Reference not visible due to access restriction > 462 = Invalid URL reference. Double quote the reference or use the href syntax > 463 = Description expected after this reference > 464 = Unexpected duplicated tag @{0} >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.370 >diff -u -r1.370 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 27 May 2008 22:21:14 -0000 1.370 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 2 Jun 2008 13:17:29 -0000 >@@ -290,6 +290,7 @@ > case IProblem.JavadocHiddenReference: > case IProblem.JavadocMissingTagDescription: > case IProblem.JavadocInvalidSeeUrlReference: >+ case IProblem.JavadocForbiddenReference: > return CompilerOptions.InvalidJavadoc; > > case IProblem.JavadocMissingParamTag: >@@ -1122,6 +1123,7 @@ > case IProblem.JavadocNotVisibleMethod: > case IProblem.JavadocNotVisibleType: > case IProblem.JavadocHiddenReference: >+ case IProblem.JavadocForbiddenReference: > if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsNotVisibleRef)) { > return ProblemSeverities.Ignore; > } >@@ -3935,6 +3937,12 @@ > messageSend.sourceEnd); > } > } >+public void javadocForbiddenReference(int sourceStart, int sourceEnd, int modifiers){ >+ if (!javadocVisibility(this.options.reportInvalidJavadocTagsVisibility, modifiers)) return; >+ int severity = computeSeverity(IProblem.JavadocForbiddenReference); >+ if (severity == ProblemSeverities.Ignore) return; >+ this.handle(IProblem.JavadocForbiddenReference, NoArgument, NoArgument, sourceStart, sourceEnd); >+} > public void javadocHiddenReference(int sourceStart, int sourceEnd, Scope scope, int modifiers) { > Scope currentScope = scope; > while (currentScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE ) { >Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v >retrieving revision 1.199 >diff -u -r1.199 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 27 May 2008 22:21:14 -0000 1.199 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 2 Jun 2008 13:17:27 -0000 >@@ -822,6 +822,11 @@ > * Javadoc comments > */ > /** >+ * Problem warned on a restricted access reference. >+ * @since 3.5 >+ */ >+ int JavadocForbiddenReference = Javadoc + Internal + 461; >+ /** > * Problem signaled on an invalid URL reference. > * Valid syntax example: @see "http://www.eclipse.org/" > * @since 3.4 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java,v >retrieving revision 1.15 >diff -u -r1.15 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 27 May 2008 23:54:00 -0000 1.15 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 2 Jun 2008 13:17:32 -0000 >@@ -702,6 +702,7 @@ > expectedProblemAttributes.put("JavadocInvalidValueReference", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocUnexpectedText", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("JavadocInvalidParamTagName", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); >+ expectedProblemAttributes.put("JavadocForbiddenReference", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC)); > expectedProblemAttributes.put("DuplicateTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); > expectedProblemAttributes.put("IllegalTypeVariableSuperReference", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); > expectedProblemAttributes.put("NonStaticTypeFromStaticInvocation", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); >@@ -1311,6 +1312,7 @@ > expectedProblemAttributes.put("JavadocInvalidValueReference", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocUnexpectedText", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("JavadocInvalidParamTagName", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); >+ expectedProblemAttributes.put("JavadocForbiddenReference", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC)); > expectedProblemAttributes.put("DuplicateTypeVariable", SKIP); > expectedProblemAttributes.put("IllegalTypeVariableSuperReference", SKIP); > expectedProblemAttributes.put("NonStaticTypeFromStaticInvocation", SKIP); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.163 >diff -u -r1.163 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 27 May 2008 09:41:15 -0000 1.163 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 2 Jun 2008 13:17:31 -0000 >@@ -20,6 +20,7 @@ > import java.text.MessageFormat; > import java.util.ArrayList; > import java.util.Iterator; >+import java.util.Map; > > import junit.framework.Test; > >@@ -34,6 +35,7 @@ > import org.eclipse.jdt.internal.compiler.batch.ClasspathLocation; > import org.eclipse.jdt.internal.compiler.batch.Main; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > > public class BatchCompilerTest extends AbstractRegressionTest { > public static final String OUTPUT_DIR_PLACEHOLDER = "---OUTPUT_DIR_PLACEHOLDER---"; >@@ -338,6 +340,29 @@ > } > } > >+/* >+ * Return the custom compiler options handled by ExtraCompilerArguments >+ * or null when dealing with simple command line arguments (@see ExtraCompilerArguments class). >+ */ >+private Map getCompilerOptions(Object extraArguments) { >+ if (extraArguments instanceof ExtraCompilerArguments) { >+ return ((ExtraCompilerArguments) extraArguments).customCompilerOptions; >+ } >+ // we may want to return null when no extra compiler options were specified >+ return null; >+} >+ >+/* >+ * Return the command line arguments handled by ExtraCompilerArguments >+ * or the extraArguments as a String (@see ExtraCompilerArguments class). >+ */ >+private String getExtraArguments(Object extraArguments) { >+ if (extraArguments instanceof ExtraCompilerArguments) { >+ return ((ExtraCompilerArguments) extraArguments).extraArguments; >+ } >+ return (String) extraArguments; >+} >+ > private String getLibraryClassesAsQuotedString() { > String[] paths = Util.getJavaClassLibs(); > StringBuffer buffer = new StringBuffer(); >@@ -583,14 +608,14 @@ > // (need appropriate exception) > assertEquals( > "Unexpected standard output for invocation with arguments [" >- + extraArguments + "]", >+ + getExtraArguments(extraArguments) + "]", > expectedOutOutputString, > outOutputString); > } > if (!errCompareOK) { > assertEquals( > "Unexpected error output for invocation with arguments [" >- + extraArguments + "]", >+ + getExtraArguments(extraArguments) + "]", > expectedErrOutputString, > errOutputString); > } >@@ -598,8 +623,8 @@ > // in this case, extraArguments is expected to hold a command line (as a String) > protected boolean invokeCompiler(PrintWriter out, PrintWriter err, Object extraArguments, TestCompilationProgress compilationProgress) { > try { >- final String[] tokenizedCommandLine = Main.tokenize((String) extraArguments); >- return new Main(out, err, false, null /* customDefaultOptions */, compilationProgress /* compilationProgress*/).compile(tokenizedCommandLine); >+ final String[] tokenizedCommandLine = Main.tokenize(getExtraArguments(extraArguments)); >+ return new Main(out, err, false, getCompilerOptions(extraArguments) /* customDefaultOptions */, compilationProgress /* compilationProgress*/).compile(tokenizedCommandLine); > } catch (RuntimeException e) { > System.out.println(getClass().getName() + '#' + getName()); > e.printStackTrace(); >@@ -868,6 +893,23 @@ > static final Matcher ONE_FILE_GENERATED_MATCHER = new SubstringMatcher("[1 .class file generated]"); > static final Matcher TWO_FILES_GENERATED_MATCHER = new SubstringMatcher("[2 .class files generated]"); > /** >+ * Place holder for extra compiler arguments. >+ * These can be command line arguments combined with custom options >+ */ >+ static class ExtraCompilerArguments { >+ protected String extraArguments; >+ protected Map customCompilerOptions; >+ /** >+ * Getter for the custom compiler options. >+ * When none were set, will retrieve the default compiler options {@link CompilerOptions#getMap()} >+ * @return Map the map of custom compiler options. >+ */ >+ public Map getCustomOptions() { >+ return this.customCompilerOptions == null ? this.customCompilerOptions = new CompilerOptions().getMap() : this.customCompilerOptions; >+ } >+ } >+ >+ /** > * Abstract normalizer for output comparison. This class merely embodies a > * chain of responsibility, plus the signature of the method of interest > * here, that is {@link #normalized(String) normalized}. >@@ -10899,4 +10941,546 @@ > "incorrect classpath: p/Y.class\n", > false/*shouldFlushOutput*/); > } >+/** >+ * @bug 204234: [javadoc] AccessRestriction compiler error in JavaDoc >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=204234" >+ * An array of 5 tests that uses a combination of command line arguments >+ * and compiler options (javadoc report invalid reference visibility) >+ * Disable doc comment support in the last test (no warning expected) >+ */ >+public void test285_accessRestrictedReference_in_javadoc() { >+ String[] units = new String[] { >+ "pkg1/X.java", >+ "package pkg1;\n" + >+ "\n" + >+ "public class X {\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " private String foo;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " public String bar;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " String fooBar;\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " private void foo() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " protected void bar() {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " public void fooBar() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " private class foo {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " class bar {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " public class fooBar {\n" + >+ " }\n" + >+ "}", >+ "pkg2/Y.java", >+ "package pkg2;\n" + >+ "\n" + >+ "public class Y {" + >+ " public String E;" + >+ " public void foo() {}" + >+ "}\n" >+ }; >+ >+ String expectedWarnings = >+ "----------\n" + >+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 9)\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 28)\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 44)\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "3 problems (3 warnings)"; >+ >+ String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" >+ + " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" >+ + " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" >+ + "\"" + File.pathSeparator >+ + " -proceedOnError -d \"" + OUTPUT_DIR + "\""; >+ >+ ExtraCompilerArguments arguments = new ExtraCompilerArguments(); >+ // set command line options >+ arguments.extraArguments = commandLineArgs; >+ // set custom options >+ Map customOptions = arguments.getCustomOptions(); >+ // javadoc >+ customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.ENABLED); >+ // report invalid reference visibility: PUBLIC >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.PUBLIC); >+ // compiler >+ customOptions.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); >+ >+ // run test >+ runTest(true, units, arguments, "", expectedWarnings, true, null); >+} >+public void test286_accessRestrictedReference_in_javadoc() { >+ String[] units = new String[] { >+ "pkg1/X.java", >+ "package pkg1;\n" + >+ "\n" + >+ "public class X {\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " private String foo;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " public String bar;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " String fooBar;\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " private void foo() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " protected void bar() {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " public void fooBar() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " private class foo {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " class bar {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " public class fooBar {\n" + >+ " }\n" + >+ "}", >+ "pkg2/Y.java", >+ "package pkg2;\n" + >+ "\n" + >+ "public class Y {" + >+ " public String E;" + >+ " public void foo() {}" + >+ "}\n" >+ }; >+ >+ String expectedWarnings = >+ "----------\n" + >+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 5)\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 9)\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 13)\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 17)\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 22)\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 28)\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "7. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 33)\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "8. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 38)\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "9. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 44)\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "9 problems (9 warnings)"; >+ >+ String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" >+ + " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" >+ + " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" >+ + "\"" + File.pathSeparator >+ + " -proceedOnError -d \"" + OUTPUT_DIR + "\""; >+ >+ ExtraCompilerArguments arguments = new ExtraCompilerArguments(); >+ // set command line options >+ arguments.extraArguments = commandLineArgs; >+ // set custom options >+ Map customOptions = arguments.getCustomOptions(); >+ // javadoc >+ customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.ENABLED); >+ // report invalid reference visibility: PRIVATE >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.PRIVATE); >+ // compiler >+ customOptions.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); >+ >+ // run test >+ runTest(true, units, arguments, "", expectedWarnings, true, null); >+} >+public void test287_accessRestrictedReference_in_javadoc() { >+ String[] units = new String[] { >+ "pkg1/X.java", >+ "package pkg1;\n" + >+ "\n" + >+ "public class X {\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " private String foo;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " public String bar;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " String fooBar;\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " private void foo() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " protected void bar() {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " public void fooBar() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " private class foo {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " class bar {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " public class fooBar {\n" + >+ " }\n" + >+ "}", >+ "pkg2/Y.java", >+ "package pkg2;\n" + >+ "\n" + >+ "public class Y {" + >+ " public String E;" + >+ " public void foo() {}" + >+ "}\n" >+ }; >+ >+ String expectedWarnings = >+ "----------\n" + >+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 9)\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 22)\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 28)\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 44)\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "4 problems (4 warnings)"; >+ >+ String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" >+ + " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" >+ + " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" >+ + "\"" + File.pathSeparator >+ + " -proceedOnError -d \"" + OUTPUT_DIR + "\""; >+ >+ ExtraCompilerArguments arguments = new ExtraCompilerArguments(); >+ // set command line options >+ arguments.extraArguments = commandLineArgs; >+ // set custom options >+ Map customOptions = arguments.getCustomOptions(); >+ // javadoc >+ customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.ENABLED); >+ // report invalid reference visibility: PROTECTED >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.PROTECTED); >+ // compiler >+ customOptions.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); >+ >+ // run test >+ runTest(true, units, arguments, "", expectedWarnings, true, null); >+} >+public void test288_accessRestrictedReference_in_javadoc() { >+ String[] units = new String[] { >+ "pkg1/X.java", >+ "package pkg1;\n" + >+ "\n" + >+ "public class X {\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " private String foo;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " public String bar;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " String fooBar;\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " private void foo() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " protected void bar() {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " public void fooBar() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " private class foo {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " class bar {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " public class fooBar {\n" + >+ " }\n" + >+ "}", >+ "pkg2/Y.java", >+ "package pkg2;\n" + >+ "\n" + >+ "public class Y {" + >+ " public String E;" + >+ " public void foo() {}" + >+ "}\n" >+ }; >+ >+ String expectedWarnings = >+ "----------\n" + >+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 9)\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 13)\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 22)\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 28)\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 38)\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 44)\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " ^^^^^^\n" + >+ "Javadoc: Reference not visible due to access restriction\n" + >+ "----------\n" + >+ "6 problems (6 warnings)"; >+ >+ String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" >+ + " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" >+ + " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" >+ + "\"" + File.pathSeparator >+ + " -proceedOnError -d \"" + OUTPUT_DIR + "\""; >+ >+ ExtraCompilerArguments arguments = new ExtraCompilerArguments(); >+ // set command line options >+ arguments.extraArguments = commandLineArgs; >+ // set custom options >+ Map customOptions = arguments.getCustomOptions(); >+ // javadoc >+ customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.ENABLED); >+ // report invalid reference visibility: DEFAULT >+ customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.DEFAULT); >+ // compiler >+ customOptions.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); >+ >+ // run test >+ runTest(true, units, arguments, "", expectedWarnings, true, null); >+} >+public void test289_accessRestrictedReference_in_javadoc() { >+ // no warning expected as we do not validate javadoc content >+ String[] units = new String[] { >+ "pkg1/X.java", >+ "package pkg1;\n" + >+ "\n" + >+ "public class X {\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " private String foo;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " public String bar;\n" + >+ " /**\n" + >+ " * test field declaration visibility {@link pkg2.Y#E}\n" + >+ " */\n" + >+ " String fooBar;\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " private void foo() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " protected void bar() {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test method declaration visibility {@link pkg2.Y#foo()}\n" + >+ " */\n" + >+ " public void fooBar() {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " private class foo {\n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " class bar {\n" + >+ " \n" + >+ " }\n" + >+ " /**\n" + >+ " * test type declaration visibility {@link pkg2.Y}\n" + >+ " */\n" + >+ " public class fooBar {\n" + >+ " }\n" + >+ "}", >+ "pkg2/Y.java", >+ "package pkg2;\n" + >+ "\n" + >+ "public class Y {" + >+ " public String E;" + >+ " public void foo() {}" + >+ "}\n" >+ }; >+ String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" >+ + " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" >+ + " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" >+ + "\"" + File.pathSeparator >+ + " -proceedOnError -d \"" + OUTPUT_DIR + "\""; >+ >+ ExtraCompilerArguments arguments = new ExtraCompilerArguments(); >+ // set command line options >+ arguments.extraArguments = commandLineArgs; >+ >+ // run test >+ runTest(true, units, arguments, "", "", true, null); >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 204234
:
78949
|
78966
| 103110