-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
Milestone
Description
As observed in ceylon/ceylon-compiler#2371, forward-reference checks can be circumvented. Issues with statement ordering with respect to declarations may exist as well.
This example produces surprising results where an immutable value seemingly changes, due to first being used in an uninitialized state:
shared native class C() {
shared native Integer a = 1;
shared native Integer b = 2;
shared void printA() => print("a=``a``");
shared void printB() => print("b=``b``");
}
shared native("jvm") class C() {
shared native("jvm") Integer a = -b;
printB();
}
shared void run() {
value c = C(); // b=0
c.printB(); // b=2
c.printA(); // a=0
}Similarly, a NullPointerException can occur:
shared native class C() {
shared native Integer a = -1;
shared native String b = "b";
}
shared native("jvm") class C() {
shared native("jvm") Integer a = b.size;
//java.lang.NullPointerException
// at ceylon.language.String.getSize(String.java:242)
}ps - I realize this is not for 1.2.
Reactions are currently unavailable