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

JShell: determine incorrectly the type of the expression which is array type of captured type

XMLWordPrintable

    • b99
    • generic
    • generic
    • Verified

      -> class Test1<T> {T[] get() {return null;}}
      | Added class Test1

      -> Test1<? extends String> test1 = new Test1<>()
      | Added variable test1 of type Test1<? extends String> with initial value Test1@2f410acf

      -> test1.get()
      Compiling: test1.get()
      Kind: EXPRESSION_STATEMENT -- test1.get();
      compileAndLoad [Unit($1)]
      ++setCompilationInfo() Snippet:VariableKey($1)#12-test1.get()
      package REPL;
      import java.util.*;import java.io.*;import java.math.*;import java.net.*;import java.util.concurrent.*;import java.util.prefs.*;import java.util.regex.*;import static REPL.$REPL8.printf;
      import static REPL.$REPL9.Test1;
      import static REPL.$REPL10.test1;
      class $REPL12 {
          public static
          ? extends String[] $1;
          public static Object do_it$() throws Throwable {
              return $1 =
              test1.get();
          }
      }

      -- diags: [WrappedDiagnostic(型の開始が不正です:0), WrappedDiagnostic(staticでない変数 $1をstaticコンテキストから参照することはできません:0)]
      setStatus() Snippet:VariableKey($1)#12-test1.get() - status: REJECTED
      compileAndLoad ins = [Unit($1)] -- legit = []
      compileAndLoad [Unit($1)] -- deps: [] success: true
      recordCompilation: Snippet:VariableKey($1)#12-test1.get() -- status REJECTED, unresolved []
      | Error:
      | 型の開始が不正です
      | test1.get()
      | ^
      printDiagnostics start-pos = 0 ==> 0 -- wrap = jdk.internal.jshell.tool.JShellTool@6f7923a5
      Code: compiler.err.illegal.start.of.type
      Pos: 0 (0 - 0)
      | Error:
      | staticでない変数 $1をstaticコンテキストから参照することはできません
      | test1.get()
      | ^
      printDiagnostics start-pos = 0 ==> 0 -- wrap = jdk.internal.jshell.tool.JShellTool@6f7923a5
      Code: compiler.err.non-static.cant.be.ref
      Pos: 0 (0 - 0)

      -> "".getClass().getEnumConstants()
      Compiling: "".getClass().getEnumConstants()
      Kind: EXPRESSION_STATEMENT -- "".getClass().getEnumConstants();
      compileAndLoad [Unit($2)]
      ++setCompilationInfo() Snippet:VariableKey($2)#13-"".getClass().getEnumConstants()
      package REPL;
      import java.util.*;import java.io.*;import java.math.*;import java.net.*;import java.util.concurrent.*;import java.util.prefs.*;import java.util.regex.*;import static REPL.$REPL8.printf;
      import static REPL.$REPL9.Test1;
      import static REPL.$REPL10.test1;
      class $REPL13 {
          public static
          ? extends String[] $2;
          public static Object do_it$() throws Throwable {
              return $2 =
              "".getClass().getEnumConstants();
          }
      }

      -- diags: [WrappedDiagnostic(型の開始が不正です:0), WrappedDiagnostic(staticでない変数 $2をstaticコンテキストから参照することはできません:0)]
      setStatus() Snippet:VariableKey($2)#13-"".getClass().getEnumConstants() - status: REJECTED
      compileAndLoad ins = [Unit($2)] -- legit = []
      compileAndLoad [Unit($2)] -- deps: [] success: true
      recordCompilation: Snippet:VariableKey($2)#13-"".getClass().getEnumConstants() -- status REJECTED, unresolved []
      | Error:
      | 型の開始が不正です
      | "".getClass().getEnumConstants()
      | ^
      printDiagnostics start-pos = 0 ==> 0 -- wrap = jdk.internal.jshell.tool.JShellTool@6f7923a5
      Code: compiler.err.illegal.start.of.type
      Pos: 0 (0 - 0)
      | Error:
      | staticでない変数 $2をstaticコンテキストから参照することはできません
      | "".getClass().getEnumConstants()
      | ^
      printDiagnostics start-pos = 0 ==> 0 -- wrap = jdk.internal.jshell.tool.JShellTool@6f7923a5
      Code: compiler.err.non-static.cant.be.ref
      Pos: 0 (0 - 0)

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

              Created:
              Updated:
              Resolved: