ADDITIONAL SYSTEM INFORMATION :
java version "24.0.1" 2025-04-15
Java(TM) SE Runtime Environment Oracle GraalVM 24.0.1+9.1 (build 24.0.1+9-jvmci-b01)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 24.0.1+9.1 (build 24.0.1+9-jvmci-b01, mixed mode, sharing)
macOS: 15.5 (24F74)
A DESCRIPTION OF THE PROBLEM :
When using local execution mode and a --startup option, jshell does not recognise prior declared reference type variables, in combination with the use of JSR-494: Module Import Declarations: https://openjdk.org/jeps/494
Primitive types and primitive arrays are recognised however.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a file called test.jsh with the following content
```jsh
String[] arr = {"one"};
import module java.base;
import static java.util.stream.Collectors.*;
System.out.println(arr);
/exit
```
Execute the above with the following:
jshell --enable-preview -J--enable-preview --startup=DEFAULT --execution=local ./test.jsh
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Array reference should be printed
ACTUAL -
null is produced
The behaviour can be corrected by changing the order of the imports so the module import is after the static import.
java version "24.0.1" 2025-04-15
Java(TM) SE Runtime Environment Oracle GraalVM 24.0.1+9.1 (build 24.0.1+9-jvmci-b01)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 24.0.1+9.1 (build 24.0.1+9-jvmci-b01, mixed mode, sharing)
macOS: 15.5 (24F74)
A DESCRIPTION OF THE PROBLEM :
When using local execution mode and a --startup option, jshell does not recognise prior declared reference type variables, in combination with the use of JSR-494: Module Import Declarations: https://openjdk.org/jeps/494
Primitive types and primitive arrays are recognised however.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a file called test.jsh with the following content
```jsh
String[] arr = {"one"};
import module java.base;
import static java.util.stream.Collectors.*;
System.out.println(arr);
/exit
```
Execute the above with the following:
jshell --enable-preview -J--enable-preview --startup=DEFAULT --execution=local ./test.jsh
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Array reference should be printed
ACTUAL -
null is produced
The behaviour can be corrected by changing the order of the imports so the module import is after the static import.
- relates to
-
JDK-8335987 JEP 494: Module Import Declarations (Second Preview)
-
- Closed
-