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

8261606: Surprising behavior of step over in String switch #2569

Closed
wants to merge 1 commit into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Feb 15, 2021

Consider code like:

public class Test {
    public static void main(String... args) {
        new Test().test("a");
    }
    private void test(String s) {
        if (s != null) {
            switch (s) {
                case "a":
                    System.out.println("a"); //breakpoint here, and continue with step-over
                    break;
                default:
                    System.out.println("default"); //the program counter will be shown here eventually
            }
        } else {
            System.out.println("null");
        }
    }
} 

Placing breakpoint at the marked line (with System.out.println("a");), running debugger and performing step-over, the execution eventually is shown to stop at the line with System.out.println("default");.

The reason for this is (roughly) because the switch-over-string is desugared into a block, but that block does not have an end position set. So the LineNumberTable point for the closing bracket of the block is not generated, and hence the last previous point is used, which is the last line of the last case (branch) of the switch.

The proposal is to set the end position for the synthetic block generated for the switch-over-string.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8261606: Surprising behavior of step over in String switch

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2569/head:pull/2569
$ git checkout pull/2569

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 15, 2021

👋 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 openjdk bot added the rfr Pull request is ready for review label Feb 15, 2021
@openjdk
Copy link

openjdk bot commented Feb 15, 2021

@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 Feb 15, 2021
@mlbridge
Copy link

mlbridge bot commented Feb 15, 2021

Webrevs

Copy link
Contributor

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

looks sensible

@openjdk
Copy link

openjdk bot commented Feb 17, 2021

@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:

8261606: Surprising behavior of step over in String switch

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 78 new commits pushed to the master branch:

  • d547e1a: 8261123: Augment discussion of equivalence classes in Object.equals and comparison methods
  • 2677f6f: 8261675: ObjectValue::set_visited(bool) sets _visited false
  • e7e20d4: 8261711: Clhsdb "versioncheck true" throws NPE every time
  • 55d7bbc: 8261607: SA attach is exceeding JNI Local Refs capacity
  • 0a50688: 8241372: Several test failures due to javax.net.ssl.SSLException: Connection reset
  • 61a659f: 8260415: Remove unused class ReferenceProcessorMTProcMutator
  • 6b6f794: 8248223: KeyAgreement spec update on multi-party key exchange support
  • 8ba390d: 8261753: Test java/lang/System/OsVersionTest.java still failing on BigSur patch versions after JDK-8253702
  • 16bd7d3: 8261336: IGV: enhance default filters
  • 3f8819c: 8261501: Shenandoah: reconsider heap statistics memory ordering
  • ... and 68 more: https://git.openjdk.java.net/jdk/compare/52fc01b3ee4ddefd3be3e541a2c53c818d9292c7...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 Feb 17, 2021
@lahodaj
Copy link
Contributor Author

lahodaj commented Mar 2, 2021

/integrate

@openjdk openjdk bot closed this Mar 2, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 2, 2021
@openjdk
Copy link

openjdk bot commented Mar 2, 2021

@lahodaj Since your change was applied there have been 246 commits pushed to the master branch:

  • be67aaa: 8262726: AArch64: C1 StubAssembler::call_RT can corrupt stack
  • 0f6122b: 8262819: gc/shenandoah/compiler/TestLinkToNativeRBP.java fails with release VMs
  • dd33a8e: 8262461: handle wcstombsdmp return value correctly in unix awt_InputMethod.c
  • 3b350ad: 8261710: SA DSO objects have sizes that are too large
  • fdd1093: 8261552: s390: MacroAssembler::encode_klass_not_null() may produce wrong results for non-zero values of narrow klass base
  • f5ab7f6: 8262472: Buffer overflow in UNICODE::as_utf8 for zero length output buffer
  • 6635d7a: 8261670: Add javadoc for the XML processing limits
  • 85b774a: 8255859: Incorrect comments in log.hpp
  • c3eb80e: 8262500: HostName entry in VM.info should be a new line
  • 9f0f0c9: 8260933: runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java fails without CompactStrings
  • ... and 236 more: https://git.openjdk.java.net/jdk/compare/52fc01b3ee4ddefd3be3e541a2c53c818d9292c7...master

Your commit was automatically rebased without conflicts.

Pushed as commit 85a5ae8.

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

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
2 participants