0

When I run jshell 17 / 19 in windows powershell at my home dir, i.e. C:\Users\my_user_name, jshell throws exception as following.

Jdk 19 installed with oracle win10 msi binary, path updated by $env:PATH='C:\Program Files\Java\jdk-19\bin;'+$env:PATH

Exception in thread "main" java.lang.InternalError: Exception during analyze - java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Scope$StarImportScope.isFilled()" because "tree.starImportScope" is null
        at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:415)
        at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.<init>(TaskFactory.java:406)
        at jdk.jshell/jdk.jshell.TaskFactory.lambda$analyze$1(TaskFactory.java:178)
        at jdk.jshell/jdk.jshell.TaskFactory.lambda$runTask$4(TaskFactory.java:213)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:193)
        at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:206)
        at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:175)
        at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:161)
        at jdk.jshell/jdk.jshell.Eval.compileAndLoad(Eval.java:1060)
        at jdk.jshell/jdk.jshell.Eval.declare(Eval.java:893)
        at jdk.jshell/jdk.jshell.Eval.eval(Eval.java:140)
        at jdk.jshell/jdk.jshell.JShell.eval(JShell.java:493)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3624)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1348)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1246)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1217)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.startUpRun(JShellTool.java:1178)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.resetState(JShellTool.java:1125)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:951)
        at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:261)
        at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
Caused by: java.lang.IllegalStateException: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Scope$StarImportScope.isFilled()" because "tree.starImportScope" is null
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:383)
        at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:412)
        ... 20 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Scope$StarImportScope.isFilled()" because "tree.starImportScope" is null
        at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.ensureImportsChecked(TypeEnter.java:170)
        at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:628)
        at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:588)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1042)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:345)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:399)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$analyze$1(JavacTaskImpl.java:379)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:379)
        ... 21 more

But jshell works when I first cd to any other dir or when I use jshell 11 at my home dir.

  • Update 1: run with jshell --no-startup the internalError disappeared at startup, but when I type import java.util.ArrayList; in jshell and type enter, jshell exits with same the error as following.
  • Update 2: The error only occured when I execute jshell at my home dir, i.e. C:\Users\my_user_name, but I didn't find out why. (Have delete several suspicious folders and files at home dir, still not work). Maybe jshell reads something when startup from its pwd/cwd and get confused by some of my file at home directory ?
djy
  • 737
  • 6
  • 14
  • 1
    probably because some folder/file used for startup is not accessible to normal users. Maybe it is the startup script, try `jshell --no-startup` or `jshell -` – user16320675 Jan 19 '23 at 10:21
  • Do you have your path setup correctly? If your in the bin folder, then all the files there should be on the path. When you run as administrator, does it have a different path variable than when run as a normal user. ( %PATH% it might be called?) – matt Jan 19 '23 at 10:28
  • @user16320675 `jshell --no-startup` has no error, `jshell -` same error – djy Jan 19 '23 at 11:00
  • @matt I checked `$env:PATH` is correct and same for admin and normal user – djy Jan 19 '23 at 11:03
  • Hi, I updated description, this error seems only occur when I execute `jshell` at my home dir, i.e. `C:\Users\my_user_name`, error disappears when I switch to any other folder at powershell, I had delete several suspicious folders and files at home dir, `jshell` still not work there. – djy Jan 20 '23 at 06:39
  • (1) Maybe the problem is not jshell, maybe it is xxx.jsh content problem. (2) In the user directory, create `Main.jsh`, the content is: `import javax.swing.*; JFrame f = new JFrame("frame"); JOptionPane. showMessageDialog(f, "Hello Wolrd!"); /exit` (3) Open powershell, execute in the user directory, `jshell --startup Main.jsh`, (4) It can be executed normally, no error message is generated (5) After installing Oracle JDK 19, Windows installer msi, there is no Make any settings, do not set JAVA_HOME or PATH, execute to open powershell, execute jshell directly, and there is no error message. – life888888 Jan 20 '23 at 12:16

0 Answers0