Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8315735

VerifyError when switch statement used with synchronized block

    XMLWordPrintable

Details

    • b15
    • generic
    • generic

    Backports

      Description

        A DESCRIPTION OF THE PROBLEM :
        Using JDK 20.0.2, a switch expression containing a synchronized block will cause a VerifyError

        REGRESSION : Last worked in version 20.0.2

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Here is the code that reproduces the problem:

        // an instance field
        private final String content;

        // a constructor for a Name class that implements javax.lang.model.element.Name (not sure this matters)
        public Name(final CharSequence cs) {
          super();
          this.content = switch (cs) {
          case null -> "";
          case String s -> s;
          case Name n -> n.content;
          case javax.lang.model.element.Name n -> {
            synchronized (CompletionLock.monitor()) {
              yield n.toString();
            }
          }
          default -> cs.toString();
          };
        }

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Successful compilation
        ACTUAL -
        java.lang.VerifyError:
        Stack map does not match the one at exception handler 104

        ---------- BEGIN SOURCE ----------
        See reproduction steps
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Don't use switch expressions

        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

                jlahoda Jan Lahoda
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: