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

Compiler Error when try-catch miss closing brace } before catch clause

    XMLWordPrintable

Details

    • 21
    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      NAME="Ubuntu"
      VERSION_ID="22.04"
      VERSION="22.04.3 LTS (Jammy Jellyfish)"
      6.2.0-26-generic #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Jul 13 16:27:29 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
      -------------------------------------------------
      openjdk version "21" 2023-09-19
      OpenJDK Runtime Environment (build 21+35-2513)
      OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      Compiler Error when try-catch miss closing brace } before catch clause.

      REGRESSION : Last worked in version 17

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      use java 21

      try compile code with try catch without } before the catch;

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      VirtualThreadTest.java:2: error: class, interface, enum, or record expected
      void main () {
      ^
      VirtualThreadTest.java:5: error: class, interface, enum, or record expected
      } catch(Exception e) {
      ^
      2 errors

      ACTUAL -
      An exception has occurred in the compiler (21). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
      java.lang.AssertionError
      at jdk.compiler/com.sun.tools.javac.parser.VirtualParser$VirtualScanner.errPos(VirtualParser.java:151)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.doRecover(JavacParser.java:3122)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.parseSimpleStatement(JavacParser.java:3097)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatement(JavacParser.java:2819)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatements(JavacParser.java:2756)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2726)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2740)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.parseSimpleStatement(JavacParser.java:3025)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatement(JavacParser.java:2819)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatements(JavacParser.java:2756)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2726)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2740)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.methodDeclaratorRest(JavacParser.java:4898)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.topLevelMethodOrFieldDeclaration(JavacParser.java:4772)
      at jdk.compiler/com.sun.tools.javac.parser.JavacParser.parseCompilationUnit(JavacParser.java:3989)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:652)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:629)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:689)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:1038)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler$InitialFileParser.parse(JavaCompiler.java:1972)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:1025)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:951)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)


      ---------- BEGIN SOURCE ----------
      void main () {
              try {
                   System.out.println("Hello world");
               catch(Exception e) {}
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: