|  | ||
|---|---|---|
| .. | ||
| tests | ||
| README.md | ||
| common_util.py | ||
| install_tools.sh | ||
| ojluni_modify_expectation.py | ||
| ojluni_refresh_files.py | ||
| ojluni_upgrade_identicals.py | ||
| ojluni_versions_report.py | ||
		
			
				
				README.md
			
		
		
			
			
		
	
	If you want to import files from the OpenJDK into libcore/, you are reading
the right documentation.
The general idea is to get a change from OpenJDK into libcore in AOSP by
git merge from an OpenJDK branch. However, each file in ojluni/ can come
from a different OpenJDK version. expected_upstream is a staging branch
storing the OpenJDK version of each file. Thus, we can use git merge when
we update an ojluni/ file from a new upstream version, and the command should
automatically merge the file if no merge conflict.
Directory Layout
in the aosp/expected_upstream branch.
- ojluni/- It has the same layout as the ojluni/ files in aosp/master
 
- It has the same layout as the ojluni/ files in 
- EXPECTED_UPSTREAMfile- The table has 3 columns, i.e.
- Destination path in ojluni/
- Expected upstream version / an upstream git tag
- Upstream source path
 
- Destination path in 
- The file format is like .csv file using a ,separator
 
- The table has 3 columns, i.e.
- tools/expected_upstream/- Contains the tools
 
Understanding your change
Changes that shouldn't happen in the aosp/expected_upstream branch
In general, if you want to change an ojluni/ file by a text editor / IDE
manually, you should make the change on aosp/master.
- Changes to non-OpenJDK files
- Those files are usually under the luni/folder, you can make the change directly onaosp/master
 
- Those files are usually under the 
- Adding / updating a patch to an existing ojluni/file- You can make the change directly on aosp/master. Please follow this patch style guideline.
 
- You can make the change directly on 
- Cherry-picking a commit from upstream
- You should first try to update an ojluni/file to a particular upstream version. If you can't but still want to cherry-pick a upstream fix, you should do so on theaosp/masterbranch.
 
- You should first try to update an 
- Changes to non-OpenJDK files in ojluni/- Files, e.g. Android.bp, don't come from the upstream. You can make the
change directly on aosp/master.
 
- Files, e.g. Android.bp, don't come from the upstream. You can make the
change directly on 
Changes that should be made via the aosp/expected_upstream branch
- Add or upgrade a file from the upstream OpenJDK
- You are reading the right document! This documentation tells you how to
import the file from the upstream. Later, you can merge the file and
expected_upstreamintoaosp/masterbranch.
 
- You are reading the right document! This documentation tells you how to
import the file from the upstream. Later, you can merge the file and
- Remove an ojluni/file that originally came from the OpenJDK- Please remove the file on both aosp/masterandaosp/expected_upstreambranches. Don't forget to remove the entry in theEXPECTED_UPSTREAMtoo.
 
- Please remove the file on both 
- Revert the merge commit on aosp/masterfromexpected_upstream- If you don't plan to re-land your change on aosp/master, you should probably revert the changeaosp/expected_upstreamas well.
- If you plan to re-land your change, your re-landing commit won't be
a merge commit, because gitdoesn't allow you to merge the same commit twice into the same branch. You have 2 options- Revert your change on expected_upsteamtoo and start over again when you reland your change
- Just accept that the re-landing commit won't be a merge commit.
 
- Revert your change on 
 
- If you don't plan to re-land your change on 
Life of a typical change
Commit graph of a typical change
----11.0.13-ga----------------   openjdk/jdk11u
         \
          A
           \
------------B-----C------------   expected_upstream
                   \
--------------------D---E------   master
Typically, you will need 5 CLs
- Commit Aimports the file and moves the file in theojluni/folder
- Commit Bmerges the file into the expected_upstream with otherojlunifiles- Commit AandBare created by theojluni_refresh_filesscript
 
- Commit 
- Commit Cedits the entry in theEXPECTED_UPSTREAMfile
- Commit Dis a merge commit created bygit merge
- Commit Eadds Android patches- Includes other changes to non-OpenJDK files, e.g. Android.bp,api/current.txt.
 
- Includes other changes to non-OpenJDK files, e.g. 
Why can't have a single commit to replace the commits A, B and C?
- Preserve the upstream history. We can later git blamewith the upstream history.
Tools
Prerequisite
- python3
- pip3
- A remote aospis setup in your local git repository
List of the scripts
tools/expected_upstream/install_tools.sh
- Installs the dependency libraries
- Installs the other tools into your current shell process
ojluni_modify_expectation
- Command line tool that can help modify the EXPECTED_UPSTREAM file
ojluni_refresh_files
- Reads the EXPECTED_UPSTREAM file and updates the files contents in ojluni/ accordingly
Workflow in command lines
Setup
- Switch to the expected_upstream branch
git branch <local_branch> aosp/expected_upstream
git checkout <local_branch>
- Install tools
source ./tools/expected_upstream/install_tools.sh
Upgrade a java class to a higher OpenJDK version
For example, upgrade java.lang.String to 11.0.13-ga version:
ojluni_modify_expectation modify java.lang.String jdk11u/jdk-11.0.13-ga
ojluni_refresh_files
or if java.lang.String is missing in EXPECTED_UPSTREAM:
ojluni_modify_expectation add jdk11u/jdk-11.0.13-ga java.lang.String
ojluni_refresh_files
2 commits should be created to update the ojluni/src/main/java/java/lang/String.java.
You can verify and view the diff by the following command
git diff aosp/expected_upstream -- ojluni/src/main/java/java/lang/String.java
You can then upload your change to AOSP gerrit.
repo upload --cbr -t . # -t sets a topic to the CLs in the gerrit
Remember to commit your EXPECTED_UPSTREAM file change into a new commit
git commit -- EXPECTED_UPSTREAM
Then upload your change to AOSP gerrit.
repo upload --cbr .
Then you can switch back to your local master branch to apply the changes
git checkout <local_master_branch>
git merge local_expected_upstream
# Resolve any merge conflict
git commit --amend # Amend the commit message and add the bug number you are working on
repo upload .
Add a java test from the upstream
The process is similar to the above commands, but needs to run
ojluni_modify_expectation with an add subcommand.
For example, add a test for String.isEmpty() method:
ojluni_modify_expectation add jdk8u/jdk8u121-b13 java.lang.String.IsEmpty
Note: java.lang.String.IsEmpty is a test class in the upstream repository.
Submit your change in AOSP gerrit
----11.0.13-ga----------------   openjdk/jdk11u
         \
          A
           \
------------B-----C------------   expected_upstream
                   \
--------------------D---E------   master
Here are the order of events / votes required to submit your CL on gerrit as of Nov 2021.
- Presubmit-Verified +2on all 5 CLs- Due to b/204973624, you may Bypass-Presubmit +1on commitAandBif the presubmit fails.
 
- Due to b/204973624, you may 
- Code-review +2on all 5 CLs from an Android Core Library team member
- If needed, API-review +1on commitEfrom an Android API council member
- Click the submit button / Autosubmit +1on commitB,CandE- Never submit commit Aindividually without submittingBtogether.- Otherwise, gerrit will create another merge commit from Awithout submittingB.
 
- Otherwise, gerrit will create another merge commit from 
- Due a Gerrit bug, you can't submit the commit Cbefore submittingBfirst manually, even thoughBis the direct parent ofC. So just submitByourself manually.
- If you can't submit the CL due a permission issue, ask an Android Core Library member to submit.
 
- Never submit commit 
Known bugs
- repo uploadmay not succeed because gerrit returns error.- Just try to run repo uploadagain!- The initial upload takes a long time because it tries to sync with the
remote AOSP gerrit server. The second upload is much faster because
the gitobjects have been uploaded.
 
- The initial upload takes a long time because it tries to sync with the
remote AOSP gerrit server. The second upload is much faster because
the 
- repo uploadreturns TimeOutException, but the CL has been uploaded. Just find your CL in http://r.android.com/. See http://b/202848945
- Try to upload the merge commits 1 by 1
 - git rev-parse HEAD # a sha is printed and you will need it later git reset HEAD~1 # reset to a earlier commit repo upload --cbr . # try to upload it again git reset <the sha printed above>
- Just try to run 
- After ojluni_modify_expectation addandojluni_refresh_files, agit commit -awould include more files than just EXPECTED_UPSTREAM, becausegit, e.g.git status, isn't aware of changes in the working tree / in the file system. This can lead to an error when checking out the branch that is based on master.- Do a git checkout --hard <initial commit before the add>
- Rerun the ojluni_modify_expectation addandojluni_refresh_files
- git stash && git stash pop
- Commit the updated EXPECTED_UPSTREAM and proceed
 
- Do a 
Report bugs
- Report bugs if the git repository is corrupt!
- Sometimes, you can recover the repository by running git reset aosp/expected_upstream
 
- Sometimes, you can recover the repository by running