Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite the JavaDoc logic in Java 11 APIs and use multi-release jar to ensure backward compatibility #929

Merged
merged 15 commits into from
Sep 20, 2023

Conversation

JoeJoe1989
Copy link
Contributor

@JoeJoe1989 JoeJoe1989 commented Aug 11, 2023

Background

Currently, RestLi uses Java 8 APIs, such as com.sun.javadoc, to generate JavaDoc. However, these APIs have been removed in Java 17, making RestLi incompatible with Java 17. This PR aims to resolve the issue by rewriting the JavaDoc related logic using Java 11 APIs, which are compatibility with JDK 17.

Furthermore, since RestLi has a mix of Java 8 and Java 11 consumers and we are using Java 11 APIs, we will utilize a multi-release JAR to ensure backward compatibility with Java 8 consumers. On a high level, a multi-release JAR compiles the code using Java 11 and sets the target version to either Java 11 or Java 8, depending on whether Java 11 APIs are used or not. As a result, the JAR contains different versions of bytecode and is compatible with different versions of consumers.

Changes

  1. Rewrite the JavaDoc logic in Java 11 APIs.
  2. Use multi-release jar to ensure compatibility with Java 8, Java 11 and Java 17 consumers.
  3. Change the GitHub workflow action to use Java 11 to compile RestLi.

Tests Done

Build in Java 11:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk11.0.13.8-msft.jdk/Contents/Home/
./gradlew build

I tested the build process of 16 consumers who are using Java 8, Java 11, and Java 17 against the local snapshot of RestLi.

I also ran a wc-test of container against RestLi and noticed some IDL changes caused by the difference between Java 8 and Java 11 APIs in terms of handling comments in unexpected formats in source files. For example, there is an extra comma after the parameter name count:

* @param count, the number of the recommendations

Java 8 APIs are not able to handle this case, so no JavaDoc is generated for count. However, Java 11 APIs can handle it and generate JavaDoc as follows:

"doc" : ", the number of the recommendations""

Consumers who encounter such IDL changes during build can commit the changes as normal. Ideally, they should fix the comments in unexpected formats in source files.

@JoeJoe1989 JoeJoe1989 changed the title Rewrite the JavaDoc logic in Java 11 APIs and use multi-release jar Rewrite the JavaDoc logic in Java 11 APIs and use multi-release jar to ensure backward compatibility Aug 11, 2023
@JoeJoe1989 JoeJoe1989 force-pushed the yanzhou/use_multi_release_jar branch from 03a3494 to 7a44056 Compare August 23, 2023 01:21
@JoeJoe1989 JoeJoe1989 force-pushed the yanzhou/use_multi_release_jar branch from a9e6c7e to c3cc6e4 Compare August 25, 2023 16:42
@JoeJoe1989 JoeJoe1989 force-pushed the yanzhou/use_multi_release_jar branch from c3cc6e4 to 033487c Compare August 26, 2023 01:18
@junchuanwang junchuanwang temporarily deployed to jfrog-publish August 28, 2023 17:17 — with GitHub Actions Inactive
@JoeJoe1989 JoeJoe1989 force-pushed the yanzhou/use_multi_release_jar branch from d8f542f to 1b70e14 Compare August 30, 2023 00:26
@junchuanwang junchuanwang temporarily deployed to jfrog-publish August 30, 2023 03:40 — with GitHub Actions Inactive
@junchuanwang junchuanwang merged commit faeee43 into linkedin:master Sep 20, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants