### Running the Java Documentation Analysis Example Source: https://openjdk.org/groups/compiler/analyzing-doc-comments/analyze-doc-comments.html Command to run the Java example with demonstration files. This command executes the example class and processes the provided demo files. ```bash $ java examples/p/Example1.java demo-files ``` -------------------------------- ### GTest Demo Quicksort Test Source: https://openjdk.org/contribute A basic GTest example demonstrating a quicksort implementation with assertions. This test runs without starting the JVM. ```c++ static int demo_comparator(int a, int b) { if (a == b) { return 0; } if (a < b) { return -1; } return 1; } TEST(Demo, quicksort) { int test_array[] = {7,1,5,3,6,9,8,2,4,0}; int expected_array[] = {0,1,2,3,4,5,6,7,8,9}; QuickSort::sort(test_array, 10, demo_comparator, false); for (int i = 0; i < 10; i++) { ASSERT_EQ(expected_array[i], test_array[i]); } } ``` -------------------------------- ### Install OpenJDK 7 JRE (Fedora/RHEL) Source: https://openjdk.org/install Installs the Java Runtime Environment for OpenJDK 7 on Fedora, Oracle Linux, or RHEL systems. Install the -devel package for development. ```bash su -c "yum install java-1.7.0-openjdk" ``` -------------------------------- ### Install OpenJDK 6 JRE (Fedora/RHEL) Source: https://openjdk.org/install Installs the Java Runtime Environment for OpenJDK 6 on Fedora, Oracle Linux, or RHEL systems. Install the -devel package for development. ```bash su -c "yum install java-1.6.0-openjdk" ``` -------------------------------- ### Install OpenJDK 7 JRE (Debian/Ubuntu) Source: https://openjdk.org/install Installs the Java Runtime Environment for OpenJDK 7 on Debian or Ubuntu systems. Install the -jdk package for development. ```bash sudo apt-get install openjdk-7-jre ``` -------------------------------- ### Install OpenJDK 8 JRE (Fedora/RHEL) Source: https://openjdk.org/install Installs the Java Runtime Environment for OpenJDK 8 on Fedora, Oracle Linux, or RHEL systems. Install the -devel package for development. ```bash su -c "yum install java-1.8.0-openjdk" ``` -------------------------------- ### Package Info with Doc Comment Source: https://openjdk.org/groups/compiler/analyzing-doc-comments/analyze-doc-comments.html Example of a package-info.java file containing a documentation comment with an href attribute. ```java /** * Package p1. * package p1 */ package p1; ``` -------------------------------- ### Install OpenJDK 7 JDK (Debian/Ubuntu) Source: https://openjdk.org/install Installs the Java Development Kit for OpenJDK 7 on Debian or Ubuntu systems. Use this for developing Java programs. ```bash sudo apt-get install openjdk-7-jdk ``` -------------------------------- ### Install OpenJDK 7 JDK (Fedora/RHEL) Source: https://openjdk.org/install Installs the Java Development Kit for OpenJDK 7 on Fedora, Oracle Linux, or RHEL systems. Use this for developing Java programs. ```bash su -c "yum install java-1.7.0-openjdk-devel" ``` -------------------------------- ### Output of Documentation Analysis Source: https://openjdk.org/groups/compiler/analyzing-doc-comments/analyze-doc-comments.html Example output showing the URLs found in the documentation comments for each processed file. ```text *** file demo-files/m/module-info.java http://www.example.com/module/m *** file demo-files/m/p1/P1C.java http://www.example.com/class/P1C http://www.example.com/class/P1C/constructor *** file demo-files/m/p1/package-info.java http://www.example.com/package/p1 *** file demo-files/m/p2/P2C.java http://www.example.com/class/P2C http://www.example.com/class/P2C/constructor *** file demo-files/m/p2/package-info.java http://www.example.com/package/p2 ``` -------------------------------- ### Initialize Project Repository and Remotes Source: https://openjdk.org/contribute Set up a local clone of your project fork and define remotes for the upstream project and the JDK mainline. This is a one-time setup. ```bash git clone git@github.com:OpenDuke/my-project.git project-merge cd project-merge git remote add upstream git@github.com:openjdk/my-project.git git remote add mainline git@github.com:openjdk/jdk.git ``` -------------------------------- ### Install OpenJDK 6 JRE (Debian/Ubuntu) Source: https://openjdk.org/install Installs the Java Runtime Environment for OpenJDK 6 on Debian or Ubuntu systems. Install the -jdk package for development. ```bash sudo apt-get install openjdk-6-jre ``` -------------------------------- ### Build Release and Debug JDK Configurations Source: https://openjdk.org/contribute Demonstrates configuring and building both a release and a debug version of the JDK. Use CONF= to select which JDK to work with in subsequent make calls. ```bash sh ./configure --with-boot-jdk=$HOME/jdk-16/ --with-debug-level=slowdebug make CONF=slowdebug images ls build/ ``` -------------------------------- ### Running a Basic Doclet Source: https://openjdk.org/groups/compiler/using-new-doclet.html Example command to execute the BasicDoclet using the Javadoc tool. This demonstrates how to specify the doclet path, the doclet class, and the source file to process. ```bash $ /opt/jdk/11/bin/javadoc \ -docletpath _classes_ \ -doclet tips.BasicDoclet \ _src_/tips/BasicDoclet.java Loading source file src/tips/BasicDoclet.java... Constructing Javadoc information... tips.BasicDoclet ``` -------------------------------- ### Install OpenJDK 8 JRE (Debian/Ubuntu) Source: https://openjdk.org/install Installs the Java Runtime Environment for OpenJDK 8 on Debian or Ubuntu systems. Install the -jdk package for development. ```bash sudo apt-get install openjdk-8-jre ``` -------------------------------- ### Enabling Logging with -Xlog Source: https://openjdk.org/contribute Examples of enabling specific logging tags and levels using the -Xlog command-line option. ```bash -Xlog:gc+marking=info -Xlog:gc+marking -Xlog:gc* ``` -------------------------------- ### Build OpenJDK on Linux Source: https://openjdk.org/contribute Steps to download, extract, install dependencies, configure, and build OpenJDK on a Linux system. Ensure you run `./configure --help` to identify necessary packages for your system. ```bash $ wget https://download.java.net/java/GA/jdk16/7863447f0ab643c585b9bdebf67c69db/36/GPL/openjdk-16_linux-x64_bin.tar.gz $ tar xzf openjdk-16_linux-x64_bin.tar.gz $ sudo apt-get install autoconf zip make gcc g++ libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev libcups2-dev libfontconfig1-dev libasound2-dev $ cd jdk $ sh ./configure --with-boot-jdk=$HOME/jdk-16/ $ make images ``` -------------------------------- ### ReporterDoclet Example Source: https://openjdk.org/groups/compiler/using-new-doclet.html This doclet illustrates the use of the Reporter API to print the kind of elements specified on the command line. It requires initialization with a Locale and Reporter. ```java package tips; import java.util.Collections; import java.util.Locale; import java.util.Set; import javax.lang.model.SourceVersion; import javax.tools.Diagnostic; import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.Reporter; /** * A doclet to illustate the use of a {@link Reporter}. * * The doclet uses a reporter to print the name of the * selected types on the command line. * * Note: some versions of javadoc may incorrectly generate * warnings instead of notes. Bug JDK--8224083. */ public class ReporterDoclet implements Doclet { private Reporter reporter; @Override public void init(Locale locale, Reporter reporter) { this.reporter = reporter; } @Override public String getName() { return getClass().getSimpleName(); } @Override public Set getSupportedOptions() { return Collections.emptySet(); } @Override public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } private static final boolean OK = true; @Override public boolean run(DocletEnvironment environment) { environment.getSpecifiedElements().forEach(e -> reporter.print(Diagnostic.Kind.NOTE, e, e.getKind().toString())); return OK; } } ``` -------------------------------- ### GitHub Commit Query Example Source: https://openjdk.org/projects Example of a GitHub query to list commits by a specific author in the OpenJDK JDK main-line development repositories. ```html https://github.com/openjdk/jdk/commits?author=GHusername ``` -------------------------------- ### Example Public SSH Key Format Source: https://openjdk.org/contribute Illustrates the expected format of a public SSH key after it has been generated and its content is displayed. ```text ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO8+egiIgWV+tE7LVVJmlR7WS2Lr3Fj7dXVo9HiasD6T openjdk-jdk ``` -------------------------------- ### Java Annotation Processor Example Source: https://openjdk.org/groups/compiler/processing-code.html An example of a Java annotation processor that extends AbstractProcessor. It initializes with ProcessingEnvironment and processes annotations by analyzing root elements. ```Java package showcode; import java.io.PrintWriter; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; import javax.lang.model.element.TypeElement; import com.sun.source.util.DocTrees; @SupportedAnnotationTypes("*") @SupportedSourceVersion(SourceVersion.RELEASE_11) public class ShowProcessor extends AbstractProcessor { PrintWriter out; DocTrees treeUtils; @Override public void init(ProcessingEnvironment pEnv) { out = new PrintWriter(System.out); treeUtils = DocTrees.instance(pEnv); } @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { new ShowCode(treeUtils).show(roundEnv.getRootElements(), out); out.flush(); return false; } } ``` -------------------------------- ### Install OpenJDK 6 JDK (Debian/Ubuntu) Source: https://openjdk.org/install Installs the Java Development Kit for OpenJDK 6 on Debian or Ubuntu systems. Use this for developing Java programs. ```bash sudo apt-get install openjdk-6-jdk ```