|
Lines 20-25
Link Here
|
| 20 |
import java.text.MessageFormat; |
20 |
import java.text.MessageFormat; |
| 21 |
import java.util.ArrayList; |
21 |
import java.util.ArrayList; |
| 22 |
import java.util.Iterator; |
22 |
import java.util.Iterator; |
|
|
23 |
import java.util.Map; |
| 23 |
|
24 |
|
| 24 |
import junit.framework.Test; |
25 |
import junit.framework.Test; |
| 25 |
|
26 |
|
|
Lines 34-39
Link Here
|
| 34 |
import org.eclipse.jdt.internal.compiler.batch.ClasspathLocation; |
35 |
import org.eclipse.jdt.internal.compiler.batch.ClasspathLocation; |
| 35 |
import org.eclipse.jdt.internal.compiler.batch.Main; |
36 |
import org.eclipse.jdt.internal.compiler.batch.Main; |
| 36 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
37 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
|
|
38 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
| 37 |
|
39 |
|
| 38 |
public class BatchCompilerTest extends AbstractRegressionTest { |
40 |
public class BatchCompilerTest extends AbstractRegressionTest { |
| 39 |
public static final String OUTPUT_DIR_PLACEHOLDER = "---OUTPUT_DIR_PLACEHOLDER---"; |
41 |
public static final String OUTPUT_DIR_PLACEHOLDER = "---OUTPUT_DIR_PLACEHOLDER---"; |
|
Lines 338-343
Link Here
|
| 338 |
} |
340 |
} |
| 339 |
} |
341 |
} |
| 340 |
|
342 |
|
|
|
343 |
/* |
| 344 |
* Return the custom compiler options handled by ExtraCompilerArguments |
| 345 |
* or null when dealing with simple command line arguments (@see ExtraCompilerArguments class). |
| 346 |
*/ |
| 347 |
private Map getCompilerOptions(Object extraArguments) { |
| 348 |
if (extraArguments instanceof ExtraCompilerArguments) { |
| 349 |
return ((ExtraCompilerArguments) extraArguments).customCompilerOptions; |
| 350 |
} |
| 351 |
// we may want to return null when no extra compiler options were specified |
| 352 |
return null; |
| 353 |
} |
| 354 |
|
| 355 |
/* |
| 356 |
* Return the command line arguments handled by ExtraCompilerArguments |
| 357 |
* or the extraArguments as a String (@see ExtraCompilerArguments class). |
| 358 |
*/ |
| 359 |
private String getExtraArguments(Object extraArguments) { |
| 360 |
if (extraArguments instanceof ExtraCompilerArguments) { |
| 361 |
return ((ExtraCompilerArguments) extraArguments).extraArguments; |
| 362 |
} |
| 363 |
return (String) extraArguments; |
| 364 |
} |
| 365 |
|
| 341 |
private String getLibraryClassesAsQuotedString() { |
366 |
private String getLibraryClassesAsQuotedString() { |
| 342 |
String[] paths = Util.getJavaClassLibs(); |
367 |
String[] paths = Util.getJavaClassLibs(); |
| 343 |
StringBuffer buffer = new StringBuffer(); |
368 |
StringBuffer buffer = new StringBuffer(); |
|
Lines 583-596
Link Here
|
| 583 |
// (need appropriate exception) |
608 |
// (need appropriate exception) |
| 584 |
assertEquals( |
609 |
assertEquals( |
| 585 |
"Unexpected standard output for invocation with arguments [" |
610 |
"Unexpected standard output for invocation with arguments [" |
| 586 |
+ extraArguments + "]", |
611 |
+ getExtraArguments(extraArguments) + "]", |
| 587 |
expectedOutOutputString, |
612 |
expectedOutOutputString, |
| 588 |
outOutputString); |
613 |
outOutputString); |
| 589 |
} |
614 |
} |
| 590 |
if (!errCompareOK) { |
615 |
if (!errCompareOK) { |
| 591 |
assertEquals( |
616 |
assertEquals( |
| 592 |
"Unexpected error output for invocation with arguments [" |
617 |
"Unexpected error output for invocation with arguments [" |
| 593 |
+ extraArguments + "]", |
618 |
+ getExtraArguments(extraArguments) + "]", |
| 594 |
expectedErrOutputString, |
619 |
expectedErrOutputString, |
| 595 |
errOutputString); |
620 |
errOutputString); |
| 596 |
} |
621 |
} |
|
Lines 598-605
Link Here
|
| 598 |
// in this case, extraArguments is expected to hold a command line (as a String) |
623 |
// in this case, extraArguments is expected to hold a command line (as a String) |
| 599 |
protected boolean invokeCompiler(PrintWriter out, PrintWriter err, Object extraArguments, TestCompilationProgress compilationProgress) { |
624 |
protected boolean invokeCompiler(PrintWriter out, PrintWriter err, Object extraArguments, TestCompilationProgress compilationProgress) { |
| 600 |
try { |
625 |
try { |
| 601 |
final String[] tokenizedCommandLine = Main.tokenize((String) extraArguments); |
626 |
final String[] tokenizedCommandLine = Main.tokenize(getExtraArguments(extraArguments)); |
| 602 |
return new Main(out, err, false, null /* customDefaultOptions */, compilationProgress /* compilationProgress*/).compile(tokenizedCommandLine); |
627 |
return new Main(out, err, false, getCompilerOptions(extraArguments) /* customDefaultOptions */, compilationProgress /* compilationProgress*/).compile(tokenizedCommandLine); |
| 603 |
} catch (RuntimeException e) { |
628 |
} catch (RuntimeException e) { |
| 604 |
System.out.println(getClass().getName() + '#' + getName()); |
629 |
System.out.println(getClass().getName() + '#' + getName()); |
| 605 |
e.printStackTrace(); |
630 |
e.printStackTrace(); |
|
Lines 868-873
Link Here
|
| 868 |
static final Matcher ONE_FILE_GENERATED_MATCHER = new SubstringMatcher("[1 .class file generated]"); |
893 |
static final Matcher ONE_FILE_GENERATED_MATCHER = new SubstringMatcher("[1 .class file generated]"); |
| 869 |
static final Matcher TWO_FILES_GENERATED_MATCHER = new SubstringMatcher("[2 .class files generated]"); |
894 |
static final Matcher TWO_FILES_GENERATED_MATCHER = new SubstringMatcher("[2 .class files generated]"); |
| 870 |
/** |
895 |
/** |
|
|
896 |
* Place holder for extra compiler arguments. |
| 897 |
* These can be command line arguments combined with custom options |
| 898 |
*/ |
| 899 |
static class ExtraCompilerArguments { |
| 900 |
protected String extraArguments; |
| 901 |
protected Map customCompilerOptions; |
| 902 |
/** |
| 903 |
* Getter for the custom compiler options. |
| 904 |
* When none were set, will retrieve the default compiler options {@link CompilerOptions#getMap()} |
| 905 |
* @return Map the map of custom compiler options. |
| 906 |
*/ |
| 907 |
public Map getCustomOptions() { |
| 908 |
return this.customCompilerOptions == null ? this.customCompilerOptions = new CompilerOptions().getMap() : this.customCompilerOptions; |
| 909 |
} |
| 910 |
} |
| 911 |
|
| 912 |
/** |
| 871 |
* Abstract normalizer for output comparison. This class merely embodies a |
913 |
* Abstract normalizer for output comparison. This class merely embodies a |
| 872 |
* chain of responsibility, plus the signature of the method of interest |
914 |
* chain of responsibility, plus the signature of the method of interest |
| 873 |
* here, that is {@link #normalized(String) normalized}. |
915 |
* here, that is {@link #normalized(String) normalized}. |
|
Lines 10899-10902
Link Here
|
| 10899 |
"incorrect classpath: p/Y.class\n", |
10941 |
"incorrect classpath: p/Y.class\n", |
| 10900 |
false/*shouldFlushOutput*/); |
10942 |
false/*shouldFlushOutput*/); |
| 10901 |
} |
10943 |
} |
|
|
10944 |
/** |
| 10945 |
* @bug 204234: [javadoc] AccessRestriction compiler error in JavaDoc |
| 10946 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=204234" |
| 10947 |
* An array of 5 tests that uses a combination of command line arguments |
| 10948 |
* and compiler options (javadoc report invalid reference visibility) |
| 10949 |
* Disable doc comment support in the last test (no warning expected) |
| 10950 |
*/ |
| 10951 |
public void test285_accessRestrictedReference_in_javadoc() { |
| 10952 |
String[] units = new String[] { |
| 10953 |
"pkg1/X.java", |
| 10954 |
"package pkg1;\n" + |
| 10955 |
"\n" + |
| 10956 |
"public class X {\n" + |
| 10957 |
" /**\n" + |
| 10958 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 10959 |
" */\n" + |
| 10960 |
" private String foo;\n" + |
| 10961 |
" /**\n" + |
| 10962 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 10963 |
" */\n" + |
| 10964 |
" public String bar;\n" + |
| 10965 |
" /**\n" + |
| 10966 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 10967 |
" */\n" + |
| 10968 |
" String fooBar;\n" + |
| 10969 |
" /**\n" + |
| 10970 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 10971 |
" */\n" + |
| 10972 |
" private void foo() {\n" + |
| 10973 |
" }\n" + |
| 10974 |
" /**\n" + |
| 10975 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 10976 |
" */\n" + |
| 10977 |
" protected void bar() {\n" + |
| 10978 |
" \n" + |
| 10979 |
" }\n" + |
| 10980 |
" /**\n" + |
| 10981 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 10982 |
" */\n" + |
| 10983 |
" public void fooBar() {\n" + |
| 10984 |
" }\n" + |
| 10985 |
" /**\n" + |
| 10986 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 10987 |
" */\n" + |
| 10988 |
" private class foo {\n" + |
| 10989 |
" }\n" + |
| 10990 |
" /**\n" + |
| 10991 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 10992 |
" */\n" + |
| 10993 |
" class bar {\n" + |
| 10994 |
" \n" + |
| 10995 |
" }\n" + |
| 10996 |
" /**\n" + |
| 10997 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 10998 |
" */\n" + |
| 10999 |
" public class fooBar {\n" + |
| 11000 |
" }\n" + |
| 11001 |
"}", |
| 11002 |
"pkg2/Y.java", |
| 11003 |
"package pkg2;\n" + |
| 11004 |
"\n" + |
| 11005 |
"public class Y {" + |
| 11006 |
" public String E;" + |
| 11007 |
" public void foo() {}" + |
| 11008 |
"}\n" |
| 11009 |
}; |
| 11010 |
|
| 11011 |
String expectedWarnings = |
| 11012 |
"----------\n" + |
| 11013 |
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 9)\n" + |
| 11014 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11015 |
" ^^^^^^\n" + |
| 11016 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11017 |
"----------\n" + |
| 11018 |
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 28)\n" + |
| 11019 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11020 |
" ^^^^^^\n" + |
| 11021 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11022 |
"----------\n" + |
| 11023 |
"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 44)\n" + |
| 11024 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11025 |
" ^^^^^^\n" + |
| 11026 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11027 |
"----------\n" + |
| 11028 |
"3 problems (3 warnings)"; |
| 11029 |
|
| 11030 |
String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" |
| 11031 |
+ " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" |
| 11032 |
+ " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" |
| 11033 |
+ "\"" + File.pathSeparator |
| 11034 |
+ " -proceedOnError -d \"" + OUTPUT_DIR + "\""; |
| 11035 |
|
| 11036 |
ExtraCompilerArguments arguments = new ExtraCompilerArguments(); |
| 11037 |
// set command line options |
| 11038 |
arguments.extraArguments = commandLineArgs; |
| 11039 |
// set custom options |
| 11040 |
Map customOptions = arguments.getCustomOptions(); |
| 11041 |
// javadoc |
| 11042 |
customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); |
| 11043 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); |
| 11044 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); |
| 11045 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.ENABLED); |
| 11046 |
// report invalid reference visibility: PUBLIC |
| 11047 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.PUBLIC); |
| 11048 |
// compiler |
| 11049 |
customOptions.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); |
| 11050 |
|
| 11051 |
// run test |
| 11052 |
runTest(true, units, arguments, "", expectedWarnings, true, null); |
| 11053 |
} |
| 11054 |
public void test286_accessRestrictedReference_in_javadoc() { |
| 11055 |
String[] units = new String[] { |
| 11056 |
"pkg1/X.java", |
| 11057 |
"package pkg1;\n" + |
| 11058 |
"\n" + |
| 11059 |
"public class X {\n" + |
| 11060 |
" /**\n" + |
| 11061 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11062 |
" */\n" + |
| 11063 |
" private String foo;\n" + |
| 11064 |
" /**\n" + |
| 11065 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11066 |
" */\n" + |
| 11067 |
" public String bar;\n" + |
| 11068 |
" /**\n" + |
| 11069 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11070 |
" */\n" + |
| 11071 |
" String fooBar;\n" + |
| 11072 |
" /**\n" + |
| 11073 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11074 |
" */\n" + |
| 11075 |
" private void foo() {\n" + |
| 11076 |
" }\n" + |
| 11077 |
" /**\n" + |
| 11078 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11079 |
" */\n" + |
| 11080 |
" protected void bar() {\n" + |
| 11081 |
" \n" + |
| 11082 |
" }\n" + |
| 11083 |
" /**\n" + |
| 11084 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11085 |
" */\n" + |
| 11086 |
" public void fooBar() {\n" + |
| 11087 |
" }\n" + |
| 11088 |
" /**\n" + |
| 11089 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11090 |
" */\n" + |
| 11091 |
" private class foo {\n" + |
| 11092 |
" }\n" + |
| 11093 |
" /**\n" + |
| 11094 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11095 |
" */\n" + |
| 11096 |
" class bar {\n" + |
| 11097 |
" \n" + |
| 11098 |
" }\n" + |
| 11099 |
" /**\n" + |
| 11100 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11101 |
" */\n" + |
| 11102 |
" public class fooBar {\n" + |
| 11103 |
" }\n" + |
| 11104 |
"}", |
| 11105 |
"pkg2/Y.java", |
| 11106 |
"package pkg2;\n" + |
| 11107 |
"\n" + |
| 11108 |
"public class Y {" + |
| 11109 |
" public String E;" + |
| 11110 |
" public void foo() {}" + |
| 11111 |
"}\n" |
| 11112 |
}; |
| 11113 |
|
| 11114 |
String expectedWarnings = |
| 11115 |
"----------\n" + |
| 11116 |
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 5)\n" + |
| 11117 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11118 |
" ^^^^^^\n" + |
| 11119 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11120 |
"----------\n" + |
| 11121 |
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 9)\n" + |
| 11122 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11123 |
" ^^^^^^\n" + |
| 11124 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11125 |
"----------\n" + |
| 11126 |
"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 13)\n" + |
| 11127 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11128 |
" ^^^^^^\n" + |
| 11129 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11130 |
"----------\n" + |
| 11131 |
"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 17)\n" + |
| 11132 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11133 |
" ^^^^^^\n" + |
| 11134 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11135 |
"----------\n" + |
| 11136 |
"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 22)\n" + |
| 11137 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11138 |
" ^^^^^^\n" + |
| 11139 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11140 |
"----------\n" + |
| 11141 |
"6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 28)\n" + |
| 11142 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11143 |
" ^^^^^^\n" + |
| 11144 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11145 |
"----------\n" + |
| 11146 |
"7. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 33)\n" + |
| 11147 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11148 |
" ^^^^^^\n" + |
| 11149 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11150 |
"----------\n" + |
| 11151 |
"8. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 38)\n" + |
| 11152 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11153 |
" ^^^^^^\n" + |
| 11154 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11155 |
"----------\n" + |
| 11156 |
"9. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 44)\n" + |
| 11157 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11158 |
" ^^^^^^\n" + |
| 11159 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11160 |
"----------\n" + |
| 11161 |
"9 problems (9 warnings)"; |
| 11162 |
|
| 11163 |
String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" |
| 11164 |
+ " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" |
| 11165 |
+ " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" |
| 11166 |
+ "\"" + File.pathSeparator |
| 11167 |
+ " -proceedOnError -d \"" + OUTPUT_DIR + "\""; |
| 11168 |
|
| 11169 |
ExtraCompilerArguments arguments = new ExtraCompilerArguments(); |
| 11170 |
// set command line options |
| 11171 |
arguments.extraArguments = commandLineArgs; |
| 11172 |
// set custom options |
| 11173 |
Map customOptions = arguments.getCustomOptions(); |
| 11174 |
// javadoc |
| 11175 |
customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); |
| 11176 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); |
| 11177 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); |
| 11178 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.ENABLED); |
| 11179 |
// report invalid reference visibility: PRIVATE |
| 11180 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.PRIVATE); |
| 11181 |
// compiler |
| 11182 |
customOptions.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); |
| 11183 |
|
| 11184 |
// run test |
| 11185 |
runTest(true, units, arguments, "", expectedWarnings, true, null); |
| 11186 |
} |
| 11187 |
public void test287_accessRestrictedReference_in_javadoc() { |
| 11188 |
String[] units = new String[] { |
| 11189 |
"pkg1/X.java", |
| 11190 |
"package pkg1;\n" + |
| 11191 |
"\n" + |
| 11192 |
"public class X {\n" + |
| 11193 |
" /**\n" + |
| 11194 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11195 |
" */\n" + |
| 11196 |
" private String foo;\n" + |
| 11197 |
" /**\n" + |
| 11198 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11199 |
" */\n" + |
| 11200 |
" public String bar;\n" + |
| 11201 |
" /**\n" + |
| 11202 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11203 |
" */\n" + |
| 11204 |
" String fooBar;\n" + |
| 11205 |
" /**\n" + |
| 11206 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11207 |
" */\n" + |
| 11208 |
" private void foo() {\n" + |
| 11209 |
" }\n" + |
| 11210 |
" /**\n" + |
| 11211 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11212 |
" */\n" + |
| 11213 |
" protected void bar() {\n" + |
| 11214 |
" \n" + |
| 11215 |
" }\n" + |
| 11216 |
" /**\n" + |
| 11217 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11218 |
" */\n" + |
| 11219 |
" public void fooBar() {\n" + |
| 11220 |
" }\n" + |
| 11221 |
" /**\n" + |
| 11222 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11223 |
" */\n" + |
| 11224 |
" private class foo {\n" + |
| 11225 |
" }\n" + |
| 11226 |
" /**\n" + |
| 11227 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11228 |
" */\n" + |
| 11229 |
" class bar {\n" + |
| 11230 |
" \n" + |
| 11231 |
" }\n" + |
| 11232 |
" /**\n" + |
| 11233 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11234 |
" */\n" + |
| 11235 |
" public class fooBar {\n" + |
| 11236 |
" }\n" + |
| 11237 |
"}", |
| 11238 |
"pkg2/Y.java", |
| 11239 |
"package pkg2;\n" + |
| 11240 |
"\n" + |
| 11241 |
"public class Y {" + |
| 11242 |
" public String E;" + |
| 11243 |
" public void foo() {}" + |
| 11244 |
"}\n" |
| 11245 |
}; |
| 11246 |
|
| 11247 |
String expectedWarnings = |
| 11248 |
"----------\n" + |
| 11249 |
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 9)\n" + |
| 11250 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11251 |
" ^^^^^^\n" + |
| 11252 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11253 |
"----------\n" + |
| 11254 |
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 22)\n" + |
| 11255 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11256 |
" ^^^^^^\n" + |
| 11257 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11258 |
"----------\n" + |
| 11259 |
"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 28)\n" + |
| 11260 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11261 |
" ^^^^^^\n" + |
| 11262 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11263 |
"----------\n" + |
| 11264 |
"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 44)\n" + |
| 11265 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11266 |
" ^^^^^^\n" + |
| 11267 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11268 |
"----------\n" + |
| 11269 |
"4 problems (4 warnings)"; |
| 11270 |
|
| 11271 |
String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" |
| 11272 |
+ " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" |
| 11273 |
+ " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" |
| 11274 |
+ "\"" + File.pathSeparator |
| 11275 |
+ " -proceedOnError -d \"" + OUTPUT_DIR + "\""; |
| 11276 |
|
| 11277 |
ExtraCompilerArguments arguments = new ExtraCompilerArguments(); |
| 11278 |
// set command line options |
| 11279 |
arguments.extraArguments = commandLineArgs; |
| 11280 |
// set custom options |
| 11281 |
Map customOptions = arguments.getCustomOptions(); |
| 11282 |
// javadoc |
| 11283 |
customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); |
| 11284 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); |
| 11285 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); |
| 11286 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.ENABLED); |
| 11287 |
// report invalid reference visibility: PROTECTED |
| 11288 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.PROTECTED); |
| 11289 |
// compiler |
| 11290 |
customOptions.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); |
| 11291 |
|
| 11292 |
// run test |
| 11293 |
runTest(true, units, arguments, "", expectedWarnings, true, null); |
| 11294 |
} |
| 11295 |
public void test288_accessRestrictedReference_in_javadoc() { |
| 11296 |
String[] units = new String[] { |
| 11297 |
"pkg1/X.java", |
| 11298 |
"package pkg1;\n" + |
| 11299 |
"\n" + |
| 11300 |
"public class X {\n" + |
| 11301 |
" /**\n" + |
| 11302 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11303 |
" */\n" + |
| 11304 |
" private String foo;\n" + |
| 11305 |
" /**\n" + |
| 11306 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11307 |
" */\n" + |
| 11308 |
" public String bar;\n" + |
| 11309 |
" /**\n" + |
| 11310 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11311 |
" */\n" + |
| 11312 |
" String fooBar;\n" + |
| 11313 |
" /**\n" + |
| 11314 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11315 |
" */\n" + |
| 11316 |
" private void foo() {\n" + |
| 11317 |
" }\n" + |
| 11318 |
" /**\n" + |
| 11319 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11320 |
" */\n" + |
| 11321 |
" protected void bar() {\n" + |
| 11322 |
" \n" + |
| 11323 |
" }\n" + |
| 11324 |
" /**\n" + |
| 11325 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11326 |
" */\n" + |
| 11327 |
" public void fooBar() {\n" + |
| 11328 |
" }\n" + |
| 11329 |
" /**\n" + |
| 11330 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11331 |
" */\n" + |
| 11332 |
" private class foo {\n" + |
| 11333 |
" }\n" + |
| 11334 |
" /**\n" + |
| 11335 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11336 |
" */\n" + |
| 11337 |
" class bar {\n" + |
| 11338 |
" \n" + |
| 11339 |
" }\n" + |
| 11340 |
" /**\n" + |
| 11341 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11342 |
" */\n" + |
| 11343 |
" public class fooBar {\n" + |
| 11344 |
" }\n" + |
| 11345 |
"}", |
| 11346 |
"pkg2/Y.java", |
| 11347 |
"package pkg2;\n" + |
| 11348 |
"\n" + |
| 11349 |
"public class Y {" + |
| 11350 |
" public String E;" + |
| 11351 |
" public void foo() {}" + |
| 11352 |
"}\n" |
| 11353 |
}; |
| 11354 |
|
| 11355 |
String expectedWarnings = |
| 11356 |
"----------\n" + |
| 11357 |
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 9)\n" + |
| 11358 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11359 |
" ^^^^^^\n" + |
| 11360 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11361 |
"----------\n" + |
| 11362 |
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 13)\n" + |
| 11363 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11364 |
" ^^^^^^\n" + |
| 11365 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11366 |
"----------\n" + |
| 11367 |
"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 22)\n" + |
| 11368 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11369 |
" ^^^^^^\n" + |
| 11370 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11371 |
"----------\n" + |
| 11372 |
"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 28)\n" + |
| 11373 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11374 |
" ^^^^^^\n" + |
| 11375 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11376 |
"----------\n" + |
| 11377 |
"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 38)\n" + |
| 11378 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11379 |
" ^^^^^^\n" + |
| 11380 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11381 |
"----------\n" + |
| 11382 |
"6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/pkg1/X.java (at line 44)\n" + |
| 11383 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11384 |
" ^^^^^^\n" + |
| 11385 |
"Javadoc: Reference not visible due to access restriction\n" + |
| 11386 |
"----------\n" + |
| 11387 |
"6 problems (6 warnings)"; |
| 11388 |
|
| 11389 |
String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" |
| 11390 |
+ " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" |
| 11391 |
+ " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" |
| 11392 |
+ "\"" + File.pathSeparator |
| 11393 |
+ " -proceedOnError -d \"" + OUTPUT_DIR + "\""; |
| 11394 |
|
| 11395 |
ExtraCompilerArguments arguments = new ExtraCompilerArguments(); |
| 11396 |
// set command line options |
| 11397 |
arguments.extraArguments = commandLineArgs; |
| 11398 |
// set custom options |
| 11399 |
Map customOptions = arguments.getCustomOptions(); |
| 11400 |
// javadoc |
| 11401 |
customOptions.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); |
| 11402 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); |
| 11403 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); |
| 11404 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsNotVisibleRef, CompilerOptions.ENABLED); |
| 11405 |
// report invalid reference visibility: DEFAULT |
| 11406 |
customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.DEFAULT); |
| 11407 |
// compiler |
| 11408 |
customOptions.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); |
| 11409 |
|
| 11410 |
// run test |
| 11411 |
runTest(true, units, arguments, "", expectedWarnings, true, null); |
| 11412 |
} |
| 11413 |
public void test289_accessRestrictedReference_in_javadoc() { |
| 11414 |
// no warning expected as we do not validate javadoc content |
| 11415 |
String[] units = new String[] { |
| 11416 |
"pkg1/X.java", |
| 11417 |
"package pkg1;\n" + |
| 11418 |
"\n" + |
| 11419 |
"public class X {\n" + |
| 11420 |
" /**\n" + |
| 11421 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11422 |
" */\n" + |
| 11423 |
" private String foo;\n" + |
| 11424 |
" /**\n" + |
| 11425 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11426 |
" */\n" + |
| 11427 |
" public String bar;\n" + |
| 11428 |
" /**\n" + |
| 11429 |
" * test field declaration visibility {@link pkg2.Y#E}\n" + |
| 11430 |
" */\n" + |
| 11431 |
" String fooBar;\n" + |
| 11432 |
" /**\n" + |
| 11433 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11434 |
" */\n" + |
| 11435 |
" private void foo() {\n" + |
| 11436 |
" }\n" + |
| 11437 |
" /**\n" + |
| 11438 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11439 |
" */\n" + |
| 11440 |
" protected void bar() {\n" + |
| 11441 |
" \n" + |
| 11442 |
" }\n" + |
| 11443 |
" /**\n" + |
| 11444 |
" * test method declaration visibility {@link pkg2.Y#foo()}\n" + |
| 11445 |
" */\n" + |
| 11446 |
" public void fooBar() {\n" + |
| 11447 |
" }\n" + |
| 11448 |
" /**\n" + |
| 11449 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11450 |
" */\n" + |
| 11451 |
" private class foo {\n" + |
| 11452 |
" }\n" + |
| 11453 |
" /**\n" + |
| 11454 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11455 |
" */\n" + |
| 11456 |
" class bar {\n" + |
| 11457 |
" \n" + |
| 11458 |
" }\n" + |
| 11459 |
" /**\n" + |
| 11460 |
" * test type declaration visibility {@link pkg2.Y}\n" + |
| 11461 |
" */\n" + |
| 11462 |
" public class fooBar {\n" + |
| 11463 |
" }\n" + |
| 11464 |
"}", |
| 11465 |
"pkg2/Y.java", |
| 11466 |
"package pkg2;\n" + |
| 11467 |
"\n" + |
| 11468 |
"public class Y {" + |
| 11469 |
" public String E;" + |
| 11470 |
" public void foo() {}" + |
| 11471 |
"}\n" |
| 11472 |
}; |
| 11473 |
String commandLineArgs = "\"" + OUTPUT_DIR + File.separator + "pkg1" + File.separator + "X.java\"" |
| 11474 |
+ " -g -preserveAllLocals -warn:-unusedLocal,-unusedPrivate" |
| 11475 |
+ " -proc:none -cp \"" + OUTPUT_DIR + "[-pkg2/Y]" |
| 11476 |
+ "\"" + File.pathSeparator |
| 11477 |
+ " -proceedOnError -d \"" + OUTPUT_DIR + "\""; |
| 11478 |
|
| 11479 |
ExtraCompilerArguments arguments = new ExtraCompilerArguments(); |
| 11480 |
// set command line options |
| 11481 |
arguments.extraArguments = commandLineArgs; |
| 11482 |
|
| 11483 |
// run test |
| 11484 |
runTest(true, units, arguments, "", "", true, null); |
| 11485 |
} |
| 10902 |
} |
11486 |
} |