Skip to content

Conversation

@lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Jan 18, 2024

Consider code like:

public class Test {
    public static void main(String... args) {
        System.err.println((test() ? null : null) + "");
    }
    private static boolean test() {
        System.err.println("test called!");
        return true;
    }
}

This should print:

test called!
null

but it prints:

$ java /tmp/Test.java
null

The correct semantics can be achieved by using --source 8:

$ java --source 8 /tmp/Test.java
test called!
null

Or -XDstringConcat=inline when compiling.

The reason is that when StringConcat.IndyConstants converts String concatenation parameters, it will short-circuit any expressions whose type is BOT (i.e. basically the null type). But, in this case, the expression that has the BOT type is a complex expression with a side-effect, so short-circuiting it leads to a broken semantics.

My proposal is to "short-circuit" only null literals, and generate other expressions normally. There may be some corner cases where we'd generate the expression unnecessarily (if it does not have any side-effect), but looking for side-effects seems unnecessarily complex and fragile given I'd expect non-trivial expressions with the BOT type are very rare. (The only case which comes to mind is exactly the above one - a conditional expressions, whose both result values are null.)

Please note that when the expression is incorrectly short-circuited, it may lead to various other effects - the original bug report shows a case where the resulting code does not pass the verification.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8323657: Compilation of snippet results in VerifyError at runtime with --release 9 (and above) (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17483/head:pull/17483
$ git checkout pull/17483

Update a local copy of the PR:
$ git checkout pull/17483
$ git pull https://git.openjdk.org/jdk.git pull/17483/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17483

View PR using the GUI difftool:
$ git pr show -t 17483

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17483.diff

Webrev

Link to Webrev Comment

@lahodaj lahodaj marked this pull request as draft January 18, 2024 10:57
@bridgekeeper
Copy link

bridgekeeper bot commented Jan 18, 2024

👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jan 18, 2024

@lahodaj The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Jan 18, 2024
@lahodaj lahodaj marked this pull request as ready for review January 18, 2024 11:04
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 18, 2024
@mlbridge
Copy link

mlbridge bot commented Jan 18, 2024

Webrevs

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@openjdk
Copy link

openjdk bot commented Jan 20, 2024

@lahodaj This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8323657: Compilation of snippet results in VerifyError at runtime with --release 9 (and above)

Reviewed-by: vromero

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 28 new commits pushed to the master branch:

  • 9049402: 8323675: Race in jdk.javadoc-gendata
  • f1b7335: 8320113: [macos14] : ShapeNotSetSometimes.java fails intermittently on macOS 14
  • 8700de6: 8322744: VirtualThread.notifyJvmtiDisableSuspend should be static
  • 6c0bebc: 8159927: Add a test to verify JMOD files created in the images do not have debug symbols
  • 437342b: 8323556: CDS archive space addresses should be randomized with ArchiveRelocationMode=1
  • 39005e2: 8324041: ModuleOption.java failed with update release versioning scheme
  • 2865afe: 8323685: PrintSystemDictionaryAtExit has mutex rank assert
  • 6997bfc: 8323154: C2: assert(cmp != nullptr && cmp->Opcode() == Op_Cmp(bt)) failed: no exit test
  • 16be388: 8322383: G1: Only preserve marks on objects that are actually moved
  • 0081d8c: 8324147: Serial: Remove generation::compute_new_size
  • ... and 18 more: https://git.openjdk.org/jdk/compare/ff8cc268fdaaf85299c94088a226b73e7eaf6bdb...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 20, 2024
@lahodaj
Copy link
Contributor Author

lahodaj commented Jan 22, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Jan 22, 2024

Going to push as commit c9cacfb.
Since your change was applied there have been 40 commits pushed to the master branch:

  • bde650f: 8322282: Incorrect LoaderConstraintTable::add_entry after JDK-8298468
  • be943a9: 8321984: IGV: Upgrade to Netbeans Platform 20
  • d3b2ac1: 8314186: runtime/8176717/TestInheritFD.java failed with "Log file was leaked"
  • 72f1990: 8323057: Recoverable errors may be reported before unrecoverable errors when annotation processing is skipped
  • c84af49: 8324129: C2: Remove some ttyLocker usages in preparation for JDK-8306767
  • fd37262: 8323748: RISC-V: Add Zfh probe code
  • 76afa02: 8322572: AllocationMergesTests.java fails with "IRViolationException: There were one or multiple IR rule failures."
  • 2003610: 8323108: BufferedImage.setData(Raster) should not cast float and double values to integers
  • a474b37: 8324240: Remove unused GrowableArrayView::EMPTY
  • 68b5aab: 8324229: JFR: Temporarily disable assertion for missing object reference
  • ... and 30 more: https://git.openjdk.org/jdk/compare/ff8cc268fdaaf85299c94088a226b73e7eaf6bdb...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 22, 2024
@openjdk openjdk bot closed this Jan 22, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 22, 2024
@openjdk
Copy link

openjdk bot commented Jan 22, 2024

@lahodaj Pushed as commit c9cacfb.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@lahodaj
Copy link
Contributor Author

lahodaj commented Jan 25, 2024

/backport jdk22u

@openjdk
Copy link

openjdk bot commented Jan 25, 2024

@lahodaj the backport was successfully created on the branch backport-lahodaj-c9cacfb2 in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c9cacfb2 from the openjdk/jdk repository.

The commit being backported was authored by Jan Lahoda on 22 Jan 2024 and was reviewed by Vicente Romero.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-lahodaj-c9cacfb2:backport-lahodaj-c9cacfb2
$ git checkout backport-lahodaj-c9cacfb2
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-lahodaj-c9cacfb2

⚠️ @lahodaj You are not yet a collaborator in my fork openjdk-bots/jdk22u. An invite will be sent out and you need to accept it before you can proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

2 participants