-
Enhancement
-
Resolution: Fixed
-
P4
-
26
-
master
Just a note from playing with the EA build. Minimal example:
import java.util.ArrayList;
value class HittableList2 {
private final ArrayList<Object> objects
= new ArrayList<>();
HittableList2() {}
HittableList2(Object object) {
add(object);
}
void add(Object object) {
objects.add(object);
}
}
This gives the error
/Users/<username>/Development/raytracer/src/HittableList2.java:10: error: cannot reference add(Object) before constructor has been called
add(object);
^
I know this means the superclass's constructor (and that I need to put an explicit super() at the top of the method), but reading that straight "cannot reference ... before constructor has been called - I'm in the constructor!"
import java.util.ArrayList;
value class HittableList2 {
private final ArrayList<Object> objects
= new ArrayList<>();
HittableList2() {}
HittableList2(Object object) {
add(object);
}
void add(Object object) {
objects.add(object);
}
}
This gives the error
/Users/<username>/Development/raytracer/src/HittableList2.java:10: error: cannot reference add(Object) before constructor has been called
add(object);
^
I know this means the superclass's constructor (and that I need to put an explicit super() at the top of the method), but reading that straight "cannot reference ... before constructor has been called - I'm in the constructor!"
- links to
-
Commit(lworld)
openjdk/valhalla/ef116822
-
Commit(master)
openjdk/jdk/20e55faf
-
Review(lworld)
openjdk/valhalla/1705
-
Review(master)
openjdk/jdk/28007