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

JShell: Completeness analysis infers an incomplete declaration as COMPLETE_WITH_SEMI, which is a first line of Allman style

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • tools
    • b140
    • generic
    • generic
    • Verified

      shinyafox(Shinya Yoshida) wrote:
      It seems to me that this is a corner case on completion analysis for general case (not only reading from a file or an editor but also on jshell).

      I see the same problem with typing on jshell:

      | Welcome to JShell -- Version 9-ea
      | For an introduction type: /help intro


      jshell> class Hoge { // K&R style for classes, DEFINITELY_INCOMPLETE
         ...> }
      | created class Hoge

      jshell> void f() // Allman style for methods, DEFINITELY_INCOMPLETE
         ...> {
         ...> }
      | created method f()

      jshell> class Hoge // Allman style for classes, should be DEFINITELY_INCOMPLETE but currently it's COMPLETE_WITH_SEMI
      | Error:
      | '{' expected
      | class Hoge;
      | ^
      | Error:
      | reached end of file while parsing
      | class Hoge;
      | ^



      Paul Deitel wrote:
      Ok.

      Just so you know, I did not add the semicolon after "public class Account”—that was somehow added by opening the .java source code file in JShell.

      I would think that loading a class from a file, should result in the same as me typing that same class one line at a time directly in JShell.

      So, opening a class from a file, should just be a shorthand for typing it yourself.


      Robert Field wrote:

      What I was saying is that the current strategy of adding terminal semicolons mostly works when they are actually terminal.

      In both cases where we have sequences of snippets it does not work well: editor and reading a *.java file.

      I'm not sure what the right solution is, but I'm convinced we need a different strategy for sequences of snippets.

      My base assumption would be that in these context we use something akin to standard Java parsing (no completion analysis / no auto semicolons) -- the semicolons would be in added on writing out the file (which is mostly done already).
      jshell commands in the input of /open make this somewhat more complex.

      -Robert

            shinyafox Shinya Yoshida
            shinyafox Shinya Yoshida
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: