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

IllegalArgumentException thrown by SourceCodeAnalysisImpl.highlights()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • 26
    • 25
    • tools
    • None
    • generic
    • generic

      It appears in some scenarios JShell can cause a `JCDiagnostic`s to be generated in a scenario where there is a source code position defined but no current source file defined, which explicitly disallowed by the `JCDiagnostic` constructor. As a result, an `IllegalArgumentException` is thrown.

      Reproducer:

          $ jshell
          | Welcome to JShell -- Version 25-ea
          | For an introduction type: /help intro
          
          jshell> import jdk.jshell.*
          
          jshell> JShell jsh = JShell.builder().out(System.out).build();
          jsh ==> jdk.jshell.JShell@1134affc
          
          jshell> var sca = jsh.sourceCodeAnalysis()
          sca ==> jdk.jshell.SourceCodeAnalysisImpl@73f792cf
          
          jshell> sca.highlights("System.out.println(\"");
          | Exception java.lang.IllegalArgumentException
          | at JCDiagnostic.<init> (JCDiagnostic.java:659)
          | at JCDiagnostic.<init> (JCDiagnostic.java:641)
          | at JCDiagnostic$Factory.create (JCDiagnostic.java:294)
          | at JCDiagnostic$Factory.error (JCDiagnostic.java:111)
          | at AbstractLog.error (AbstractLog.java:144)
          | at JavaTokenizer.lexError (JavaTokenizer.java:201)
          | at JavaTokenizer.scanString (JavaTokenizer.java:470)
          | at JavaTokenizer.readToken (JavaTokenizer.java:1017)
          | at Scanner.nextToken (Scanner.java:124)
          | at SourceCodeAnalysisImpl.lambda$highlights$0 (SourceCodeAnalysisImpl.java:680)
          | at TaskFactory.lambda$runTask$1 (TaskFactory.java:218)
          | at JavacTaskPool.getTask (JavacTaskPool.java:193)
          | at TaskFactory.runTask (TaskFactory.java:211)
          | at TaskFactory.analyze (TaskFactory.java:180)
          | at TaskFactory.analyze (TaskFactory.java:166)
          | at TaskFactory.analyze (TaskFactory.java:155)
          | at SourceCodeAnalysisImpl.highlights (SourceCodeAnalysisImpl.java:651)
          | at (#4:1)
          

            jlahoda Jan Lahoda
            acobbs Archie Cobbs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: