-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to create object named 'io' of type Integer #55
Comments
Hi @eveningsamurai, thanks for all the details with the issue. Just gave this a try and I can indeed reproduce this but strangely it is related to the name Renaming the variable to Also very strange is that if you run it a bunch of times it switches between:
and
After the issue occurs it also breaks all the builtins like If you wouldn't mind, please keep this open until we can find what the issue is with the name |
Thanks @SpencerPark for looking into it. I never tried with a differently named variable because never thought that could be an issue :) I will edit the title to reflect the issue |
Alright this is really confusing me. Not sure what is so special about The import java.io.*;
int io = 10 // OK import java.io.*;
import java.math.*;
int io = 10 // BAD first run import java.io.*;
//----------- new cell
import java.math.*;
int io = 10 // OK Running a second time seems to fix the issue and it never happens again... This doesn't happen in jshell
Just keeping some notes here to come back to. |
Aha! I think I've found it. It is not the execution but still IJava's fault. The startup scripts use some fully qualified names which start in the It seems to only be a problem in a snippet that triggers a redeclaration of a signature that both uses the package in a static call in the body of the additional declaration. Can reproduce this in jshell as well which makes things a bit better: C:\Users\Spencer>jshell
| Welcome to JShell -- Version 10.0.1
| For an introduction type: /help intro
jshell> java.util.List t() {
...> return null;
...> }
| created method t()
jshell> java.util.List t(Object u) {
...> java.util.List.of();
...> return null;
...> }
| created method t(Object)
jshell> Object java = null
| Error:
| cannot find symbol
| symbol: class
| Object java = null;
| ^
| Error:
| static import only from classes and interfaces
| Object java = null;
| ^
| created variable java, however, it cannot be referenced until these errors are corrected:
| cannot find symbol
| symbol: class
| Object java = null;
| ^
| static import only from classes and interfaces
| Object java = null;
| ^ Here is a version to copy-paste to try: java.util.List t() {
return null;
}
java.util.List t(Object u) {
java.util.List.of();
return null;
}
Object java = null So this is just something to be careful of. Since changing to the direct execution control we can actually get away with a simple static import and don't need all the initialization scripts anyways. I'll switch to that and hopefully just step around this :) |
I have been trying to create an object of type Integer
but seem to be running into issues
I can do it for the Long wrapper fine
Long lo = new Long(10);
I have tried this in a jshell and that works. I have verified that the jshell is using the jdk
java --list-modules | grep "jdk.jshell" jdk.jshell@10.0.2
The text was updated successfully, but these errors were encountered: