Test Feature
Returns the value of the i record component.
""");
// 8325325: Breadcrumb navigation links should not contain PREVIEW link
checkOutput("java.base/preview/package-summary.html", true,
"""
- java.base
- preview
""");
checkOutput("java.base/preview/Core.html", true,
"""
- java.base
- preview
- Core
""",
"""
""",
"""
CoreRecord<\
/a>PREVIEW
core record""");
// 8331947: Support preview features without JEP should not be included in Preview API page
checkOutput("preview-list.html", false, "supportMethod");
}
// 8343239 pre-existing permanent API that is later retrofitted
// to extend a @PreviewFeature interface should not be flagged as a preview feature
@Test
public void nonPreviewExtendsPreview(Path base) throws IOException {
Path src = base.resolve("src");
tb.writeJavaFiles(src, """
package p;
import jdk.internal.javac.PreviewFeature;
/**
* Preview feature
*/
@PreviewFeature(feature= PreviewFeature.Feature.TEST)
public interface CoreInterface {
}
""", """
package p;
/**
* Non preview feature
*/
public interface NonPreviewExtendsPreview extends CoreInterface {
default int getNumber() {
return 0;
}
}
""");
javadoc("-d", "out-non-preview-extends-preview",
"--add-exports", "java.base/jdk.internal.javac=ALL-UNNAMED",
"--source-path",
src.toString(),
"p");
checkExit(Exit.OK);
checkOutput("p/NonPreviewExtendsPreview.html", false,
"""
NonPreviewExtendsPreview relies on preview features of the Java platform:
""",
"""
NonPreviewExtendsPreview refers to one or more preview APIs:
""");
checkOutput("p/CoreInterface.html", true,
"""
""");
}
@Test
public void test8277300() {
javadoc("-d", "out-8277300",
"--add-exports", "java.base/jdk.internal.javac=api2",
"--source-path", Paths.get(testSrc, "api2").toAbsolutePath().toString(),
"--show-packages=all",
"api2/api");
checkExit(Exit.OK);
checkOutput("api2/api/API.html", true,
"
test()
",
"
testNoPreviewInSig()
",
"title=\"interface in java.util\" class=\"external-link\">List<
APIPREVIEW>");
checkOutput("api2/api/API2.html", true,
"
API.test()PREVIEW",
"
API.testNoPreviewInSig()PREVIEW",
"
API3.test()PREVIEW");
checkOutput("api2/api/API3.html", true,
"
test()<"
+ "a href=\"#preview-test()\">PREVIEW");
}
@Test
public void test8282452() {
javadoc("-d", "out-8282452",
"--patch-module", "java.base=" + Paths.get(testSrc, "api").toAbsolutePath().toString(),
"--add-exports", "java.base/preview=m",
"--source-path", Paths.get(testSrc, "api").toAbsolutePath().toString(),
"--show-packages=all",
"preview");
checkExit(Exit.OK);
checkOutput("java.base/preview/NoPreview.html", false,
"refers to one or more preview");
}
@Test
public void testRequiresTransitiveJavaBase() {
Path src = Paths.get(testSrc, "requiresTransitiveJavaBase");
javadoc("-d", "out-requires-transitive-java-base",
"-XDforcePreview", "--enable-preview", "-source", System.getProperty("java.specification.version"),
"--module-source-path", src.toString(),
"--module", "m",
"--expand-requires", "transitive");
checkExit(Exit.OK);
checkOutput("m/module-summary.html", true,
"Indirect exports from the
java.base module are");
}
// Test for JDK hidden option to add an entry for a non-preview element
// in the preview page based on the presence of a javadoc tag.
@Test
public void testPreviewNoteTag(Path base) throws IOException {
Path src = base.resolve("src");
tb.writeJavaFiles(src, """
package p;
import jdk.internal.javac.PreviewFeature;
/**
* Preview feature
*/
@PreviewFeature(feature= PreviewFeature.Feature.TEST)
public interface CoreInterface {
}
""", """
package p;
/**
* Non preview feature.
* {@previewNote 2147483647 Preview API Note}
*/
public interface NonPrevieFeature {
}
""");
javadoc("-d", "out-preview-note-tag",
"--add-exports", "java.base/jdk.internal.javac=ALL-UNNAMED",
"-tag", "previewNote:a:Preview Note:",
"--preview-note-tag", "previewNote",
"--source-path",
src.toString(),
"p");
checkExit(Exit.OK);
checkOutput("preview-list.html", true,
"""
Contents
- Interfaces
- Permanent APIs affected by Preview Features
""",
"""
Permanent APIs affected by Preview Features
""",
"""
Test Feature
Non preview feature.
""");
}
}
CoreInterfacewhen preview features are enabled.